You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2013/07/26 00:57:59 UTC

git commit: AMBARI-2734. ambari-agent is logging too much status check details every minute. (Andrew Onischuk via smohanty)

Updated Branches:
  refs/heads/trunk c77941197 -> c48c649f2


AMBARI-2734. ambari-agent is logging too much status check details every minute. (Andrew Onischuk via smohanty)


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

Branch: refs/heads/trunk
Commit: c48c649f27b1a59354742cf2e4135a9ea80c981d
Parents: c779411
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Thu Jul 25 15:57:44 2013 -0700
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Thu Jul 25 15:57:44 2013 -0700

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/StatusCheck.py | 10 ++++++----
 ambari-agent/src/test/python/TestStatusCheck.py | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/c48c649f/ambari-agent/src/main/python/ambari_agent/StatusCheck.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/StatusCheck.py b/ambari-agent/src/main/python/ambari_agent/StatusCheck.py
index daaccc1..63abe97 100644
--- a/ambari-agent/src/main/python/ambari_agent/StatusCheck.py
+++ b/ambari-agent/src/main/python/ambari_agent/StatusCheck.py
@@ -31,6 +31,7 @@ logger = logging.getLogger()
 class StatusCheck:
     
   USER_PATTERN='{USER}'
+  firstInit = True
 
   def listFiles(self, dir):
     basedir = dir
@@ -79,9 +80,6 @@ class StatusCheck:
     for pidPath in self.pidPathes:
       self.listFiles(pidPath)
 
-    logger.info('serToPidDict:')
-    logger.info(self.serToPidDict.items())
-
     for service, pid in self.serToPidDict.items():
       if self.servicesToLinuxUser.has_key(service):
         linuxUserKey = self.servicesToLinuxUser[service]
@@ -92,7 +90,11 @@ class StatusCheck:
         if self.USER_PATTERN in pid:
           logger.error('There is no linux user mapping for component: ' + service)
 
-    logger.debug('Service to pid dictionary: ' + str(self.serToPidDict))
+    if StatusCheck.firstInit:
+      logger.info('Service to pid dictionary: ' + str(self.serToPidDict))
+      StatusCheck.firstInit = False
+    else:
+      logger.debug('Service to pid dictionary: ' + str(self.serToPidDict))
 
   def getIsLive(self, pidPath):
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/c48c649f/ambari-agent/src/test/python/TestStatusCheck.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestStatusCheck.py b/ambari-agent/src/test/python/TestStatusCheck.py
index e2d0ee6..5432c76 100644
--- a/ambari-agent/src/test/python/TestStatusCheck.py
+++ b/ambari-agent/src/test/python/TestStatusCheck.py
@@ -93,6 +93,26 @@ class TestStatusCheck(TestCase):
     
     status = statusCheck.getStatus(COMPONENT_LIVE)
     self.assertEqual(status, True)
+    
+  @patch.object(logger, 'info')
+  def test_dont_relog_serToPidDict(self, logger_info_mock):
+    TestStatusCheck.timesLogged = 0
+    
+    def my_side_effect(*args, **kwargs):
+      TestStatusCheck.timesLogged += args[0].find('Service to pid dictionary: ')+1
+      
+
+    logger_info_mock.side_effect = my_side_effect
+    
+    # call this three times
+    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathesVars,
+      self.globalConfig, self.servicesToLinuxUser)
+    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathesVars,
+      self.globalConfig, self.servicesToLinuxUser)
+    statusCheck = StatusCheck(self.serviceToPidDict, self.pidPathesVars,
+      self.globalConfig, self.servicesToLinuxUser)
+    # and really only once logged        
+    self.assertEqual(TestStatusCheck.timesLogged, 1)
 
   # Ensure that status checker return True for running process even if multiple
   # pids for a service component exist