Repository: ambari Updated Branches: refs/heads/trunk 77937e383 -> 7c7769b1a
AMBARI-19746 Ambari HDFS Metric alerts turns to UNKNOWN status with error "argument of type 'NoneType' is not iterable" (dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7c7769b1 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7c7769b1 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7c7769b1 Branch: refs/heads/trunk Commit: 7c7769b1a00ebeb9a7cf10ae5e7865f13ece7f5e Parents: 77937e3 Author: Dmytro Sen <d...@apache.org> Authored: Fri Jan 27 19:06:52 2017 +0200 Committer: Dmytro Sen <d...@apache.org> Committed: Fri Jan 27 19:06:52 2017 +0200 ---------------------------------------------------------------------- .../src/main/python/ambari_commons/ambari_metrics_helper.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7c7769b1/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 bfc786c..7841bde 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 @@ -24,6 +24,7 @@ from resource_management.libraries.functions import conf_select DEFAULT_COLLECTOR_SUFFIX = '.sink.timeline.collector.hosts' DEFAULT_METRICS2_PROPERTIES_FILE_NAME = 'hadoop-metrics2.properties' +DEFAULT_HADOOP_CONF_DIR_PATH = '/usr/hdp/current/hadoop-client/conf/' def select_metric_collector_for_sink(sink_name): # TODO check '*' sink_name @@ -42,7 +43,11 @@ def get_random_host(hosts): return random.choice(hosts) def get_metric_collectors_from_properties_file(sink_name): - hadoop_conf_dir = conf_select.get_hadoop_conf_dir() + try: + hadoop_conf_dir = conf_select.get_hadoop_conf_dir() + except Exception as e: + print "Can't get hadoop conf directory from conf_select.get_hadoop_conf_dir() - " + str(e) + hadoop_conf_dir = DEFAULT_HADOOP_CONF_DIR_PATH props = load_properties_from_file(os.path.join(hadoop_conf_dir, DEFAULT_METRICS2_PROPERTIES_FILE_NAME)) return props.get(sink_name + DEFAULT_COLLECTOR_SUFFIX) @@ -59,4 +64,4 @@ def load_properties_from_file(filepath, sep='=', comment_char='#'): key = key_value[0].strip() value = sep.join(key_value[1:]).strip('" \t') props[key] = value - return props \ No newline at end of file + return props