You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2016/12/07 21:18:01 UTC
[16/41] ambari git commit: AMBARI-19101 : Merge AMS service check
support for HA from trunk. (dsen, avijayan via avijayan)
AMBARI-19101 : Merge AMS service check support for HA from trunk. (dsen, avijayan via avijayan)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9a938e6c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9a938e6c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9a938e6c
Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 9a938e6cc27811057895d495f700a8e874c69a10
Parents: 6418861
Author: Aravindan Vijayan <av...@hortonworks.com>
Authored: Tue Dec 6 12:50:45 2016 -0800
Committer: Aravindan Vijayan <av...@hortonworks.com>
Committed: Tue Dec 6 12:50:54 2016 -0800
----------------------------------------------------------------------
.../ambari_commons/ambari_metrics_helper.py | 26 ++++++++++----------
.../package/scripts/metrics_grafana_util.py | 2 +-
.../0.1.0/package/scripts/service_check.py | 2 +-
.../2.1/hooks/before-START/scripts/params.py | 2 +-
4 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9a938e6c/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py b/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py
index f6f4068..bfc786c 100644
--- a/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py
+++ b/ambari-common/src/main/python/ambari_commons/ambari_metrics_helper.py
@@ -29,15 +29,15 @@ def select_metric_collector_for_sink(sink_name):
# TODO check '*' sink_name
all_collectors_string = get_metric_collectors_from_properties_file(sink_name)
- if all_collectors_string:
- all_collectors_list = all_collectors_string.split(',')
- return select_metric_collector_hosts_from_hostnames(all_collectors_list)
+ return select_metric_collector_hosts_from_hostnames(all_collectors_string)
+
+def select_metric_collector_hosts_from_hostnames(comma_separated_hosts):
+ if comma_separated_hosts:
+ hosts = comma_separated_hosts.split(',')
+ return get_random_host(hosts)
else:
return 'localhost'
-def select_metric_collector_hosts_from_hostnames(hosts):
- return get_random_host(hosts)
-
def get_random_host(hosts):
return random.choice(hosts)
@@ -53,10 +53,10 @@ def load_properties_from_file(filepath, sep='=', comment_char='#'):
props = {}
with open(filepath, "rt") as f:
for line in f:
- l = line.strip()
- if l and not l.startswith(comment_char):
- key_value = l.split(sep)
- key = key_value[0].strip()
- value = sep.join(key_value[1:]).strip('" \t')
- props[key] = value
- return props
+ l = line.strip()
+ if l and not l.startswith(comment_char):
+ key_value = l.split(sep)
+ key = key_value[0].strip()
+ value = sep.join(key_value[1:]).strip('" \t')
+ props[key] = value
+ return props
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/9a938e6c/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_grafana_util.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_grafana_util.py b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_grafana_util.py
index 41bd2b4..75740f8 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_grafana_util.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/metrics_grafana_util.py
@@ -215,7 +215,7 @@ def create_ams_datasource():
Create AMS datasource in Grafana, if exsists make sure the collector url is accurate
"""
Logger.info("Trying to find working metric collector")
- results = execute_in_parallel(do_ams_collector_post, params.ams_collector_hosts, params)
+ results = execute_in_parallel(do_ams_collector_post, params.ams_collector_hosts.split(','), params)
new_datasource_host = ""
for host in params.ams_collector_hosts:
http://git-wip-us.apache.org/repos/asf/ambari/blob/9a938e6c/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py
index b4e9b8f..305fe73 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/package/scripts/service_check.py
@@ -144,7 +144,7 @@ class AMSServiceCheck(Script):
Logger.info("Ambari Metrics service check was started.")
env.set_params(params)
- results = execute_in_parallel(self.service_check_for_single_host, params.ams_collector_hosts, params)
+ results = execute_in_parallel(self.service_check_for_single_host, params.ams_collector_hosts.split(','), params)
for host in str(params.ams_collector_hosts).split(","):
if host in results:
http://git-wip-us.apache.org/repos/asf/ambari/blob/9a938e6c/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py
index a22eb90..1058c75 100644
--- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/hooks/before-START/scripts/params.py
@@ -29,7 +29,7 @@ if has_metric_collector:
'metrics_collector_vip_host' in config['configurations']['cluster-env']:
metric_collector_host = config['configurations']['cluster-env']['metrics_collector_vip_host']
else:
- metric_collector_host = select_metric_collector_hosts_from_hostnames(ams_collector_hosts.split(","))
+ metric_collector_host = select_metric_collector_hosts_from_hostnames(ams_collector_hosts)
if 'cluster-env' in config['configurations'] and \
'metrics_collector_vip_port' in config['configurations']['cluster-env']:
metric_collector_port = config['configurations']['cluster-env']['metrics_collector_vip_port']