Forráskód Böngészése

AMBARI-20906 : made view directory watcher service optional by introducing views.directory.watcher.disable property in ambari.properties (nitirajrathore)

Nitiraj Singh Rathore 8 éve
szülő
commit
5b347cc8ce

+ 16 - 0
ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java

@@ -359,6 +359,13 @@ public class Configuration {
   public static final ConfigurationProperty<String> VIEWS_VALIDATE = new ConfigurationProperty<>(
       "views.validate", "false");
 
+  /**
+   * Determines whether the view directory watcher service should be disabled.
+   */
+  @Markdown(description = "Determines whether the view directory watcher service should be disabled.")
+  public static final ConfigurationProperty<String> DISABLE_VIEW_DIRECTORY_WATCHER = new ConfigurationProperty<>(
+      "views.directory.watcher.disable", "false");
+
   /**
    * Determines whether remove undeployed views from the Ambari database.
    */
@@ -3251,6 +3258,15 @@ public class Configuration {
     return Boolean.parseBoolean(getProperty(VIEWS_REMOVE_UNDEPLOYED));
   }
 
+  /**
+   * Determines whether the view directory watcher service should be disabled
+   *
+   * @return true view directory watcher service should be disabled
+   */
+  public boolean isViewDirectoryWatcherServiceDisabled() {
+    return Boolean.parseBoolean(getProperty(DISABLE_VIEW_DIRECTORY_WATCHER));
+  }
+
   /**
    * @return conventional Java version number, e.g. 7.
    * Integer is used here to simplify comparisons during usage.

+ 5 - 1
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java

@@ -450,7 +450,6 @@ public class AmbariServer {
       SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
 
       viewRegistry.readViewArchives();
-      viewDirectoryWatcher.start();
 
       enableLog4jMonitor(configsMap);
 
@@ -555,6 +554,11 @@ public class AmbariServer {
       serverForAgent.start();
       LOG.info("********* Started Server **********");
 
+      if( !configs.isViewDirectoryWatcherServiceDisabled()) {
+        LOG.info("Starting View Directory Watcher");
+        viewDirectoryWatcher.start();
+      }
+
       manager.start();
       LOG.info("********* Started ActionManager **********");
 

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java

@@ -1811,7 +1811,7 @@ public class ViewRegistry {
   }
 
   // read a view archive
-  private void readViewArchive(ViewEntity viewDefinition,
+  private synchronized void readViewArchive(ViewEntity viewDefinition,
                                File archiveFile,
                                File extractedArchiveDirFile,
                                String serverVersion) {