AMBARI-19088 : Make sure AMS in embedded mode cannot have more than 1 deployed 
instance. (avijayan)


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

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: c711850a8e53d3c838a4f7c5b9b81f7b133afbdf
Parents: edf8ab2
Author: Aravindan Vijayan <[email protected]>
Authored: Mon Dec 5 14:30:16 2016 -0800
Committer: Aravindan Vijayan <[email protected]>
Committed: Mon Dec 5 14:30:16 2016 -0800

----------------------------------------------------------------------
 .../0.1.0/package/scripts/metrics_collector.py              | 2 ++
 .../AMBARI_METRICS/0.1.0/package/scripts/params.py          | 9 +++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c711850a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_collector.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_collector.py
 
b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_collector.py
index c26eafc..7073de6 100644
--- 
a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_collector.py
+++ 
b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_collector.py
@@ -38,6 +38,8 @@ class AmsCollector(Script):
   def configure(self, env, action = None):
     import params
     env.set_params(params)
+    if action == 'start' and params.embedded_mode_multiple_instances:
+      raise Fail("AMS in embedded mode cannot have more than 1 instance. 
Delete all but 1 instances or switch to Distributed mode ")
     hbase('master', action)
     hbase('regionserver', action)
     ams(name='collector')

http://git-wip-us.apache.org/repos/asf/ambari/blob/c711850a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params.py
 
b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params.py
index 4bda033..529cf4c 100644
--- 
a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params.py
+++ 
b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/params.py
@@ -55,10 +55,16 @@ pass
 
 #AMBARI_METRICS data
 ams_pid_dir = status_params.ams_collector_pid_dir
-
+is_ams_distributed = 
config['configurations']['ams-site']['timeline.metrics.service.operation.mode'] 
== 'distributed'
 ams_collector_script = "/usr/sbin/ambari-metrics-collector"
 ams_collector_pid_dir = status_params.ams_collector_pid_dir
 ams_collector_hosts = 
",".join(default("/clusterHostInfo/metrics_collector_hosts", []))
+ams_collector_list = default("/clusterHostInfo/metrics_collector_hosts", [])
+embedded_mode_multiple_instances = False
+
+if not is_ams_distributed and len(ams_collector_list) > 1:
+  embedded_mode_multiple_instances = True
+
 failover_strategy_blacklisted_interval_seconds = 
default("/configurations/ams-env/failover_strategy_blacklisted_interval", "600")
 failover_strategy = default("/configurations/ams-site/failover.strategy", 
"round-robin")
 if default("/configurations/ams-site/timeline.metrics.service.http.policy", 
"HTTP_ONLY") == "HTTPS_ONLY":
@@ -180,7 +186,6 @@ hbase_pid_dir = status_params.hbase_pid_dir
 
 is_hbase_distributed = 
config['configurations']['ams-hbase-site']['hbase.cluster.distributed']
 is_local_fs_rootdir = hbase_root_dir.startswith('file://')
-is_ams_distributed = 
config['configurations']['ams-site']['timeline.metrics.service.operation.mode'] 
== 'distributed'
 
 # security is disabled for embedded mode, when HBase is backed by file
 security_enabled = False if not is_hbase_distributed else 
config['configurations']['cluster-env']['security_enabled']

Reply via email to