Repository: ambari Updated Branches: refs/heads/trunk 54a6525f8 -> 76ee1b114
AMBARI-18413: RecoveryManager may be logging too often Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/76ee1b11 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/76ee1b11 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/76ee1b11 Branch: refs/heads/trunk Commit: 76ee1b114e233288ebb849820e707a6afefcd3cc Parents: 54a6525 Author: Nahappan Somasundaram <nsomasunda...@hortonworks.com> Authored: Fri Sep 16 12:00:56 2016 -0700 Committer: Nahappan Somasundaram <nsomasunda...@hortonworks.com> Committed: Fri Sep 16 14:36:24 2016 -0700 ---------------------------------------------------------------------- .../src/main/python/ambari_agent/Controller.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/76ee1b11/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 a05011a..7100656 100644 --- a/ambari-agent/src/main/python/ambari_agent/Controller.py +++ b/ambari-agent/src/main/python/ambari_agent/Controller.py @@ -268,6 +268,10 @@ class Controller(threading.Thread): # we log the message at the same interval as 'state interval' heartbeat_running_msg_timestamp = 0.0 + # Prevent excessive logging by logging only at specific intervals + getrecoverycommands_timestamp = 0.0 + getrecoverycommands_interval = self.netutil.HEARTBEAT_IDLE_INTERVAL_DEFAULT_MAX_SEC + while not self.DEBUG_STOP_HEARTBEATING: heartbeat_interval = self.netutil.HEARTBEAT_IDLE_INTERVAL_DEFAULT_MAX_SEC @@ -362,12 +366,14 @@ class Controller(threading.Thread): # try storing execution command details and desired state self.addToStatusQueue(response['statusCommands']) - if not self.actionQueue.tasks_in_progress_or_pending(): - recovery_commands = self.recovery_manager.get_recovery_commands() - for recovery_command in recovery_commands: - logger.info("Adding recovery command %s for component %s", - recovery_command['roleCommand'], recovery_command['role']) - self.addToQueue([recovery_command]) + if crt_time - getrecoverycommands_timestamp > int(getrecoverycommands_interval): + getrecoverycommands_timestamp = crt_time + if not self.actionQueue.tasks_in_progress_or_pending(): + recovery_commands = self.recovery_manager.get_recovery_commands() + for recovery_command in recovery_commands: + logger.info("Adding recovery command %s for component %s", + recovery_command['roleCommand'], recovery_command['role']) + self.addToQueue([recovery_command]) if 'alertDefinitionCommands' in response_keys: self.alert_scheduler_handler.update_definitions(response)