Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 b90636121 -> 5d2325b6b


AMBARI-18426: Active ambari server check required in ambari server JAR


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

Branch: refs/heads/branch-2.5
Commit: 5d2325b6bb322dc1bd1f9f663b3ac26bd00570ab
Parents: b906361
Author: Nahappan Somasundaram <nsomasunda...@hortonworks.com>
Authored: Wed Sep 21 11:53:47 2016 -0700
Committer: Nahappan Somasundaram <nsomasunda...@hortonworks.com>
Committed: Wed Sep 21 17:45:20 2016 -0700

----------------------------------------------------------------------
 .../server/configuration/Configuration.java      | 19 +++++++++++++++++++
 .../ambari/server/controller/AmbariServer.java   |  8 ++++++++
 2 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5d2325b6/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 f13a4b6..cedafb8 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
@@ -2347,6 +2347,16 @@ public class Configuration {
   public static final ConfigurationProperty<Integer> TASK_ID_LIST_LIMIT = new 
ConfigurationProperty<>(
       "task.query.parameterlist.size", 999);
 
+  /**
+   * Indicates whether the current ambari server instance is the active 
instance.
+   * If this property is missing, the value will be considered to be true.
+   * If present, it should be explicitly set to "true" to set this as the 
active instance.
+   * Any other value will be taken as a false.
+   */
+  @Markdown(description = "Indicates whether the current ambari server 
instance is active or not.")
+  public static final ConfigurationProperty<Boolean> ACTIVE_INSTANCE = new 
ConfigurationProperty<>(
+          "active.instance", Boolean.TRUE);
+
   private static final Logger LOG = LoggerFactory.getLogger(
     Configuration.class);
 
@@ -4891,6 +4901,15 @@ public class Configuration {
   }
 
   /**
+   * Get whether the current ambari server instance the active instance
+   *
+   * @return true / false
+   */
+  public boolean isActiveInstance() {
+    return Boolean.parseBoolean(getProperty(ACTIVE_INSTANCE));
+  }
+
+  /**
    * Generates a markdown table which includes:
    * <ul>
    * <li>Property key name</li>

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d2325b6/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 56bafbb..eee7fee 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
@@ -907,6 +907,14 @@ public class AmbariServer {
     try {
       LOG.info("Getting the controller");
 
+      // check if this instance is the active instance
+      Configuration config = injector.getInstance(Configuration.class);
+      if (!config.isActiveInstance()) {
+        String errMsg = "This instance of ambari server is not designated as 
active. Cannot start ambari server." +
+                            "The property active.instance is set to false in 
ambari.properties";
+        throw new AmbariException(errMsg);
+      }
+
       setupProxyAuth();
 
       injector.getInstance(GuiceJpaInitializer.class);

Reply via email to