ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-12534 When NameNode HA is enabled and JMX info is not available, RM/HBase Master, and other masters cannot be started (dsen)
Date Fri, 24 Jul 2015 17:59:22 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 768bcdaf4 -> 17ac0d69d


AMBARI-12534 When NameNode HA is enabled and JMX info is not available, RM/HBase Master, and
other masters cannot be started (dsen)


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

Branch: refs/heads/trunk
Commit: 17ac0d69d01366f2cfd376de23c1e6b8b61cd670
Parents: 768bcda
Author: Dmytro Sen <dsen@apache.org>
Authored: Thu Jul 23 19:02:42 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Fri Jul 24 20:58:37 2015 +0300

----------------------------------------------------------------------
 .../libraries/functions/namenode_ha_utils.py         | 15 +++++++++++++--
 .../2.1.0.2.0/package/scripts/namenode_ha_state.py   | 13 ++++++++++++-
 2 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/17ac0d69/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 8267172..99f90b8 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
@@ -22,6 +22,8 @@ from resource_management.libraries.functions.is_empty import is_empty
 from resource_management.libraries.functions.format import format
 from resource_management.libraries.functions.jmx import get_value_from_jmx
 from resource_management.core.base import Fail
+from resource_management.core import shell
+
 __all__ = ["get_namenode_states", "get_active_namenode", "get_property_for_active_namenode"]
 
 HDFS_NN_STATE_ACTIVE = 'active'
@@ -63,14 +65,23 @@ def get_namenode_states(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)
-      
+      # If JMX parsing failed
+      if not state:
+        check_service_cmd = "hdfs haadmin -getServiceState {0}".format(nn_unique_id)
+        code, out = shell.call(check_service_cmd, logoutput=True, user=run_user)
+        if code == 0 and out:
+          if HDFS_NN_STATE_STANDBY in out:
+            state = HDFS_NN_STATE_STANDBY
+          elif HDFS_NN_STATE_ACTIVE in out:
+            state = HDFS_NN_STATE_ACTIVE
+
       if state == HDFS_NN_STATE_ACTIVE:
         active_namenodes.append((nn_unique_id, value))
       elif state == HDFS_NN_STATE_STANDBY:
         standby_namenodes.append((nn_unique_id, value))
       else:
         unknown_namenodes.append((nn_unique_id, value))
-        
+
   return active_namenodes, standby_namenodes, unknown_namenodes
 
 def is_ha_enabled(hdfs_site):

http://git-wip-us.apache.org/repos/asf/ambari/blob/17ac0d69/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode_ha_state.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode_ha_state.py
b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode_ha_state.py
index 0b9c940..e8c142c 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode_ha_state.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/namenode_ha_state.py
@@ -17,7 +17,7 @@ limitations under the License.
 
 """
 
-
+from resource_management.core import shell
 from resource_management.core.logger import Logger
 from resource_management.libraries.functions.default import default
 from resource_management.libraries.functions.jmx import get_value_from_jmx
@@ -83,6 +83,17 @@ class NamenodeHAState:
         jmx_uri = jmx_uri_fragment.format(actual_value)
         state = get_value_from_jmx(jmx_uri, "tag.HAState", params.security_enabled, params.hdfs_user,
params.is_https_enabled)
 
+        # If JMX parsing failed
+        if not state:
+          run_user = default("/configurations/hadoop-env/hdfs_user", "hdfs")
+          check_service_cmd = "hdfs haadmin -getServiceState {0}".format(nn_unique_id)
+          code, out = shell.call(check_service_cmd, logoutput=True, user=run_user)
+          if code == 0 and out:
+            if NAMENODE_STATE.STANDBY in out:
+              state = NAMENODE_STATE.STANDBY
+            elif NAMENODE_STATE.ACTIVE in out:
+              state = NAMENODE_STATE.ACTIVE
+
         if not state:
           raise Exception("Could not retrieve Namenode state from URL " + jmx_uri)
 


Mime
View raw message