Repository: ambari
Updated Branches:
  refs/heads/trunk 479ec12db -> 07a3a3cff


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/07a3a3cf
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/07a3a3cf
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/07a3a3cf

Branch: refs/heads/trunk
Commit: 07a3a3cff17d5df91e77fde0f6f5e0a9cac8aec5
Parents: 479ec12
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:38:26 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/07a3a3cf/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 f1058b6..2e850ef 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
@@ -2346,6 +2346,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);
 
@@ -4888,6 +4898,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/07a3a3cf/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 0e6e6b1..5e498f0 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
@@ -941,6 +941,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