ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [30/34] ambari git commit: AMBARI-20754 get_value_from_jmx constantly prints exception message in retry mechanism, which brings bad user experience (Yuanbo Liu via dili)
Date Mon, 17 Apr 2017 20:18:24 GMT
AMBARI-20754 get_value_from_jmx constantly prints exception message in retry mechanism, which
brings bad user experience (Yuanbo Liu via dili)


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

Branch: refs/heads/branch-feature-AMBARI-12556
Commit: 22b114defc43858798f6f20211c0d04b440ee7ce
Parents: dd3fdc2
Author: Di Li <dili@apache.org>
Authored: Mon Apr 17 11:36:19 2017 -0400
Committer: Di Li <dili@apache.org>
Committed: Mon Apr 17 11:36:19 2017 -0400

----------------------------------------------------------------------
 .../python/resource_management/libraries/functions/jmx.py     | 7 ++++---
 .../libraries/functions/namenode_ha_utils.py                  | 6 +++---
 2 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/22b114de/ambari-common/src/main/python/resource_management/libraries/functions/jmx.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/jmx.py
b/ambari-common/src/main/python/resource_management/libraries/functions/jmx.py
index 9a4ff5f..dbd0092 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/jmx.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/jmx.py
@@ -23,7 +23,7 @@ from resource_management.core import shell
 from resource_management.core.logger import Logger
 from resource_management.libraries.functions.get_user_call_output import get_user_call_output
 
-def get_value_from_jmx(qry, property, security_enabled, run_user, is_https_enabled):
+def get_value_from_jmx(qry, property, security_enabled, run_user, is_https_enabled, last_retry=True):
   try:
     if security_enabled:
       cmd = ['curl', '--negotiate', '-u', ':', '-s']
@@ -41,5 +41,6 @@ def get_value_from_jmx(qry, property, security_enabled, run_user, is_https_enabl
       data_dict = json.loads(data)
       return data_dict["beans"][0][property]
   except:
-    Logger.logger.exception("Getting jmx metrics from NN failed. URL: " + str(qry))
-    return None
\ No newline at end of file
+    if last_retry:
+      Logger.logger.exception("Getting jmx metrics from NN failed. URL: " + str(qry))
+    return None

http://git-wip-us.apache.org/repos/asf/ambari/blob/22b114de/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py
b/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py
index 665a8e4..8a2ff25 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/namenode_ha_utils.py
@@ -51,7 +51,7 @@ def get_namenode_states(hdfs_site, security_enabled, run_user, times=10,
sleep_t
   @retry(times=times, sleep_time=sleep_time, backoff_factor=backoff_factor, err_class=Fail)
   def doRetries(hdfs_site, security_enabled, run_user):
     doRetries.attempt += 1
-    active_namenodes, standby_namenodes, unknown_namenodes = get_namenode_states_noretries(hdfs_site,
security_enabled, run_user)
+    active_namenodes, standby_namenodes, unknown_namenodes = get_namenode_states_noretries(hdfs_site,
security_enabled, run_user, doRetries.attempt == times)
     Logger.info(
       "NameNode HA states: active_namenodes = {0}, standby_namenodes = {1}, unknown_namenodes
= {2}".format(
         active_namenodes, standby_namenodes, unknown_namenodes))
@@ -65,7 +65,7 @@ def get_namenode_states(hdfs_site, security_enabled, run_user, times=10,
sleep_t
   doRetries.attempt = 0
   return doRetries(hdfs_site, security_enabled, run_user)
 
-def get_namenode_states_noretries(hdfs_site, security_enabled, run_user):
+def get_namenode_states_noretries(hdfs_site, security_enabled, run_user, last_retry=True):
   """
   return format [('nn1', 'hdfs://hostname1:port1'), ('nn2', 'hdfs://hostname2:port2')] ,
[....], [....]
   """
@@ -102,7 +102,7 @@ def get_namenode_states_noretries(hdfs_site, security_enabled, run_user):
 
       jmx_uri = JMX_URI_FRAGMENT.format(protocol, value)
       
-      state = get_value_from_jmx(jmx_uri, 'tag.HAState', security_enabled, run_user, is_https_enabled)
+      state = get_value_from_jmx(jmx_uri, 'tag.HAState', security_enabled, run_user, is_https_enabled,
last_retry)
       # If JMX parsing failed
       if not state:
         check_service_cmd = "hdfs haadmin -ns {0} -getServiceState {1}".format(get_nameservice(hdfs_site),
nn_unique_id)


Mime
View raw message