ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject ambari git commit: AMBARI-14603. Components marked for auto-start seemingly starting even after STOP has been issued - II (smohanty)
Date Fri, 15 Jan 2016 22:08:22 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 5436fa243 -> 846b4ab90


AMBARI-14603. Components marked for auto-start seemingly starting even after STOP has been
issued - II (smohanty)


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

Branch: refs/heads/trunk
Commit: 846b4ab9086ce141a722bcdc086e47fa4110e011
Parents: 5436fa2
Author: Sumit Mohanty <smohanty@hortonworks.com>
Authored: Fri Jan 15 14:07:36 2016 -0800
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Fri Jan 15 14:08:04 2016 -0800

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/Controller.py      | 16 +++++++++-------
 .../src/main/python/ambari_agent/RecoveryManager.py |  7 ++++++-
 .../src/test/python/ambari_agent/TestController.py  |  7 +++++--
 3 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/846b4ab9/ambari-agent/src/main/python/ambari_agent/Controller.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Controller.py b/ambari-agent/src/main/python/ambari_agent/Controller.py
index c4993c7..eb2c363 100644
--- a/ambari-agent/src/main/python/ambari_agent/Controller.py
+++ b/ambari-agent/src/main/python/ambari_agent/Controller.py
@@ -171,19 +171,20 @@ class Controller(threading.Thread):
         logger.info("Registration Successful (response id = %s)", self.responseId)
 
         self.isRegistered = True
-        if 'statusCommands' in ret.keys():
-          logger.debug("Got status commands on registration.")
-          self.addToStatusQueue(ret['statusCommands'])
-        else:
-          self.hasMappedComponents = False
 
         # always update cached cluster configurations on registration
+        # must be prior to any other operation
         self.cluster_configuration.update_configurations_from_heartbeat(ret)
-
         self.recovery_manager.update_configuration_from_registration(ret)
         self.config.update_configuration_from_registration(ret)
         logger.debug("Updated config:" + str(self.config))
 
+        if 'statusCommands' in ret.keys():
+          logger.debug("Got status commands on registration.")
+          self.addToStatusQueue(ret['statusCommands'])
+        else:
+          self.hasMappedComponents = False
+
         # always update alert definitions on registration
         self.alert_scheduler_handler.update_definitions(ret)
       except ssl.SSLError:
@@ -224,7 +225,9 @@ class Controller(threading.Thread):
     else:
       if not LiveStatus.SERVICES:
         self.updateComponents(commands[0]['clusterName'])
+      self.recovery_manager.process_status_commands(commands)
       self.actionQueue.put_status(commands)
+    pass
 
   # For testing purposes
   DEBUG_HEARTBEAT_RETRIES = 0
@@ -300,7 +303,6 @@ class Controller(threading.Thread):
 
         if 'statusCommands' in response_keys:
           # try storing execution command details and desired state
-          self.recovery_manager.process_status_commands(response['statusCommands'])
           self.addToStatusQueue(response['statusCommands'])
 
         if not self.actionQueue.tasks_in_progress_or_pending():

http://git-wip-us.apache.org/repos/asf/ambari/blob/846b4ab9/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py b/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py
index 0692f1f..b5795b2 100644
--- a/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py
+++ b/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py
@@ -174,10 +174,13 @@ class RecoveryManager:
           component_status = copy.deepcopy(self.default_component_status)
           component_status["current"] = state
           self.statuses[component] = component_status
+          logger.info("New status, current status is set to %s for %s", self.statuses[component]["current"],
component)
       finally:
         self.__status_lock.release()
       pass
 
+    if self.statuses[component]["current"] != state:
+      logger.info("current status is set to %s for %s", state, component)
     self.statuses[component]["current"] = state
     if self.statuses[component]["current"] == self.statuses[component]["desired"] and \
             self.statuses[component]["stale_config"] == False:
@@ -196,12 +199,14 @@ class RecoveryManager:
           component_status = copy.deepcopy(self.default_component_status)
           component_status["desired"] = state
           self.statuses[component] = component_status
+          logger.info("New status, desired status is set to %s for %s", self.statuses[component]["desired"],
component)
       finally:
         self.__status_lock.release()
       pass
 
+    if self.statuses[component]["desired"] != state:
+      logger.info("desired status is set to %s for %s", state, component)
     self.statuses[component]["desired"] = state
-    logger.info("desired status is set to %s for %s", self.statuses[component]["desired"],
component)
     if self.statuses[component]["current"] == self.statuses[component]["desired"] and \
             self.statuses[component]["stale_config"] == False:
       self.remove_command(component)

http://git-wip-us.apache.org/repos/asf/ambari/blob/846b4ab9/ambari-agent/src/test/python/ambari_agent/TestController.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestController.py b/ambari-agent/src/test/python/ambari_agent/TestController.py
index 045f077..05448da 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestController.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestController.py
@@ -165,6 +165,9 @@ class TestController(unittest.TestCase):
     commands = ambari_simplejson.loads('[{"clusterName":"dummy_cluster"}]')
     actionQueue = MagicMock()
     self.controller.actionQueue = actionQueue
+    process_status_commands = MagicMock(name="process_status_commands")
+    self.controller.recovery_manager.process_status_commands = process_status_commands
+
     updateComponents = Mock()
     self.controller.updateComponents = updateComponents
     self.controller.addToStatusQueue(None)
@@ -179,6 +182,7 @@ class TestController(unittest.TestCase):
     self.controller.addToStatusQueue(commands)
     self.assertTrue(updateComponents.called)
     self.assertTrue(actionQueue.put_status.called)
+    self.assertTrue(process_status_commands.called)
 
 
   @patch("subprocess.Popen")
@@ -726,9 +730,8 @@ class TestController(unittest.TestCase):
     self.controller.heartbeatWithServer()
     self.assertTrue(sendRequest.called)
     self.assertTrue(process_execution_commands.called)
-    self.assertTrue(process_status_commands.called)
+    self.assertFalse(process_status_commands.called)
     process_execution_commands.assert_called_with("commands1")
-    process_status_commands.assert_called_with("commands2")
     set_paused.assert_called_with(True)
 
     self.controller.heartbeatWithServer()


Mime
View raw message