Repository: ambari
Updated Branches:
  refs/heads/trunk 0909d7cdb -> e7c027c96


AMBARI-19392. Status command executor may use obsolete settings. (stoader)


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

Branch: refs/heads/trunk
Commit: e7c027c96d0c319552e68008304777e2642b3f7a
Parents: 0909d7c
Author: Toader, Sebastian <[email protected]>
Authored: Fri Jan 6 23:45:31 2017 +0100
Committer: Toader, Sebastian <[email protected]>
Committed: Fri Jan 6 23:45:31 2017 +0100

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/ActionQueue.py | 10 +++++++---
 ambari-agent/src/main/python/ambari_agent/Controller.py  |  7 ++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e7c027c9/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py 
b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
index d70b344..3726286 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
@@ -101,9 +101,13 @@ class ActionQueue(threading.Thread):
     if not self.statusCommandQueue.empty():
       #Clear all status commands. Was supposed that we got all set of 
statuses, we don't need to keep old ones
       statusCommandQueueSize = 0
-      while not self.statusCommandQueue.empty():
-        self.statusCommandQueue.get()
-        statusCommandQueueSize = statusCommandQueueSize + 1
+      try:
+        while not self.statusCommandQueue.empty():
+          self.statusCommandQueue.get(False)
+          statusCommandQueueSize = statusCommandQueueSize + 1
+      except Queue.Empty:
+        pass
+
       logger.info("Number of status commands removed from queue : " + 
str(statusCommandQueueSize))
 
     for command in commands:

http://git-wip-us.apache.org/repos/asf/ambari/blob/e7c027c9/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 56b1992..f6bda1e 100644
--- a/ambari-agent/src/main/python/ambari_agent/Controller.py
+++ b/ambari-agent/src/main/python/ambari_agent/Controller.py
@@ -198,6 +198,12 @@ class Controller(threading.Thread):
         self.config.update_configuration_from_registration(ret)
         logger.debug("Updated config:" + str(self.config))
 
+        if self.statusCommandsExecutor is None:
+          self.spawnStatusCommandsExecutorProcess()
+        elif self.statusCommandsExecutor.is_alive():
+          logger.info("Terminating statusCommandsExecutor as agent 
re-registered with server.")
+          self.statusCommandsExecutor.kill()
+
         if 'statusCommands' in ret.keys():
           logger.debug("Got status commands on registration.")
           self.addToStatusQueue(ret['statusCommands'])
@@ -461,7 +467,6 @@ class Controller(threading.Thread):
     try:
       self.actionQueue = ActionQueue(self.config, controller=self)
       self.actionQueue.start()
-      self.spawnStatusCommandsExecutorProcess()
       self.register = Register(self.config)
       self.heartbeat = Heartbeat(self.actionQueue, self.config, 
self.alert_scheduler_handler.collector())
 

Reply via email to