ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rz...@apache.org
Subject [49/50] ambari git commit: AMBARI-18262 - When Enabling NameNode HA Via the UI Wizard, the Second NN Fails to Start (jonathanhurley)
Date Fri, 26 Aug 2016 20:48:20 GMT
AMBARI-18262 - When Enabling NameNode HA Via the UI Wizard, the Second NN Fails to Start (jonathanhurley)


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

Branch: refs/heads/2.4.0-maint
Commit: 5eecadb6e21353c7d0c0a5f2b87c0b3eeb156dff
Parents: 3f67ec8
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Thu Aug 25 13:25:15 2016 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Thu Aug 25 13:25:15 2016 -0400

----------------------------------------------------------------------
 .../2.1.0.2.0/package/scripts/hdfs_namenode.py  | 21 ++++++-----
 .../python/stacks/2.0.6/HDFS/test_namenode.py   | 38 ++++++++++++++++++++
 2 files changed, 51 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5eecadb6/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
index 63d72aa..db52ee1 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/hdfs_namenode.py
@@ -525,23 +525,28 @@ def is_this_namenode_active():
 
   # returns ([('nn1', 'c6401.ambari.apache.org:50070')], [('nn2', 'c6402.ambari.apache.org:50070')],
[])
   #                  0                                           1                      
            2
+  # or
+  # returns ([], [('nn1', 'c6401.ambari.apache.org:50070')], [('nn2', 'c6402.ambari.apache.org:50070')],
[])
+  #          0                                              1                           
                 2
   #
   namenode_states = namenode_ha_utils.get_namenode_states(params.hdfs_site, params.security_enabled,
     params.hdfs_user, times=5, sleep_time=5, backoff_factor=2)
 
-  # unwraps ('nn1', 'c6401.ambari.apache.org:50070')
-  active_namenodes = [] if len(namenode_states[0]) < 1 else namenode_states[0][0]
+  # unwraps [('nn1', 'c6401.ambari.apache.org:50070')]
+  active_namenodes = [] if len(namenode_states[0]) < 1 else namenode_states[0]
 
-  # unwraps ('nn2', 'c6402.ambari.apache.org:50070')
-  standby_namenodes = [] if len(namenode_states[1]) < 1 else namenode_states[1][0]
+  # unwraps [('nn2', 'c6402.ambari.apache.org:50070')]
+  standby_namenodes = [] if len(namenode_states[1]) < 1 else namenode_states[1]
 
   # check to see if this is the active NameNode
-  if params.namenode_id in active_namenodes:
-    return True
+  for entry in active_namenodes:
+    if params.namenode_id in entry:
+      return True
 
   # if this is not the active NameNode, then we must wait for it to register as standby
-  if params.namenode_id in standby_namenodes:
-    return False
+  for entry in standby_namenodes:
+    if params.namenode_id in entry:
+      return False
 
   # this this point, this NameNode is neither active nor standby - we must wait to ensure
it
   # enters at least one of these roles before returning a verdict - the annotation will catch

http://git-wip-us.apache.org/repos/asf/ambari/blob/5eecadb6/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py
index 72949bb..cf9beb1 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py
@@ -1787,6 +1787,44 @@ class TestNamenode(RMFTestCase):
 
     self.assertNoMoreResources()
 
+  @patch.object(time, "sleep")
+  @patch("resource_management.libraries.functions.namenode_ha_utils.get_namenode_states")
+  def test_namenode_active_detection_works_with_tuples(self, get_namenode_states_mock, sleep_mock):
+    """
+    Checks to ensure that when detecting the NN state, we take into account that both NNs
could
+    be returned with the same state forcing us to iterate over the tuple to find the right
one
+    """
+    import params
+    from hdfs_namenode import is_this_namenode_active
+
+    # mock out the NN ID
+    params.namenode_id = "nn1"
+
+    # first test the singular case
+    active_namenodes = [('nn1', 'c6401.ambari.apache.org:50070')]
+    standby_namenodes = [('nn2', 'c6402.ambari.apache.org:50070')]
+    unknown_namenodes = []
+
+    get_namenode_states_mock.return_value = active_namenodes, standby_namenodes, unknown_namenodes
+    self.assertTrue(is_this_namenode_active())
+
+    # now test the harder tuple
+    active_namenodes = [('nn1', 'c6401.ambari.apache.org:50070'), ('nn2', 'c6402.ambari.apache.org:50070')]
+    standby_namenodes = []
+    unknown_namenodes = []
+
+    get_namenode_states_mock.return_value = active_namenodes, standby_namenodes, unknown_namenodes
+    self.assertTrue(is_this_namenode_active())
+
+    # and the negative for good measure
+    active_namenodes = []
+    standby_namenodes = [('nn1', 'c6401.ambari.apache.org:50070'), ('nn2', 'c6402.ambari.apache.org:50070')]
+    unknown_namenodes = []
+
+    get_namenode_states_mock.return_value = active_namenodes, standby_namenodes, unknown_namenodes
+    self.assertFalse(is_this_namenode_active())
+
+
 class Popen_Mock:
   return_value = 1
   lines = ['Time Stamp               Iteration#  Bytes Already Moved  Bytes Left To Move
 Bytes Being Moved\n',


Mime
View raw message