Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 e51799b52 -> 5b347cc8c


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


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5b347cc8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5b347cc8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5b347cc8

Branch: refs/heads/branch-2.5
Commit: 5b347cc8ce410025a9626efe89661278546f822b
Parents: e51799b
Author: Nitiraj Singh Rathore <nitiraj.rath...@gmail.com>
Authored: Tue May 2 14:24:55 2017 +0530
Committer: Nitiraj Singh Rathore <nitiraj.rath...@gmail.com>
Committed: Tue May 2 14:25:57 2017 +0530

----------------------------------------------------------------------
 .../ambari/server/configuration/Configuration.java  | 16 ++++++++++++++++
 .../ambari/server/controller/AmbariServer.java      |  6 +++++-
 .../org/apache/ambari/server/view/ViewRegistry.java |  2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5b347cc8/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index f01df9b..d7321d9 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -360,6 +360,13 @@ public class Configuration {
       "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.
    */
   @Markdown(description = "Determines whether remove undeployed views from the 
Ambari database.")
@@ -3252,6 +3259,15 @@ public class Configuration {
   }
 
   /**
+   * 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.
    * If java version is not supported, returns -1

http://git-wip-us.apache.org/repos/asf/ambari/blob/5b347cc8/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index e266dd5..3de2b87 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ 
b/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 **********");
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/5b347cc8/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java 
b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
index 24eceb2..d136db7 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java
+++ 
b/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) {

Reply via email to