ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject ambari git commit: AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)
Date Thu, 08 Oct 2015 10:09:27 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk e9389246d -> c6303b67b


AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)


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

Branch: refs/heads/trunk
Commit: c6303b67b363790128eea12f99e7d8ad14ecb6d7
Parents: e938924
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Thu Oct 8 13:08:54 2015 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Thu Oct 8 13:08:54 2015 +0300

----------------------------------------------------------------------
 .../main/python/resource_management/core/logger.py   |  4 ++--
 .../resource_management/libraries/script/script.py   | 15 +++++----------
 2 files changed, 7 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c6303b67/ambari-common/src/main/python/resource_management/core/logger.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/logger.py b/ambari-common/src/main/python/resource_management/core/logger.py
index 7642c6d..f126f1e 100644
--- a/ambari-common/src/main/python/resource_management/core/logger.py
+++ b/ambari-common/src/main/python/resource_management/core/logger.py
@@ -36,6 +36,8 @@ class Logger:
   
   @staticmethod
   def initialize_logger(name='resource_management', logging_level=logging.INFO, format='%(asctime)s
- %(message)s'):
+    if Logger.logger:
+      return
     # set up logging (two separate loggers for stderr and stdout with different loglevels)
     logger = logging.getLogger(name)
     logger.setLevel(logging_level)
@@ -51,8 +53,6 @@ class Logger:
     logger.addHandler(chout)
 
     Logger.logger = logger
-    
-    return logger, chout, cherr
 
   @staticmethod
   def error(text):

http://git-wip-us.apache.org/repos/asf/ambari/blob/c6303b67/ambari-common/src/main/python/resource_management/libraries/script/script.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py
b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index fc0428d..3e15898 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -96,7 +96,6 @@ class Script(object):
   basedir = ""
   stroutfile = ""
   logging_level = ""
-  logger = None
 
   # Class variable
   tmp_dir = ""
@@ -117,7 +116,7 @@ class Script(object):
             Script.structuredOut = json.load(fp)
           except Exception:
             errMsg = 'Unable to read structured output from ' + self.stroutfile
-            self.logger.warn(errMsg)
+            Logging.logger.exception(errMsg)
             pass
 
     # version is only set in a specific way and should not be carried
@@ -178,15 +177,12 @@ class Script(object):
     Sets up logging;
     Parses command parameters and executes method relevant to command type
     """
-    logger, chout, cherr = Logger.initialize_logger(__name__)
-    
     # parse arguments
     if len(sys.argv) < 7:
-     logger.error("Script expects at least 6 arguments")
+     print "Script expects at least 6 arguments"
      print USAGE.format(os.path.basename(sys.argv[0])) # print to stdout
      sys.exit(1)
-
-    self.logger = logger
+     
     self.command_name = str.lower(sys.argv[1])
     self.command_data_file = sys.argv[2]
     self.basedir = sys.argv[3]
@@ -196,8 +192,7 @@ class Script(object):
     Script.tmp_dir = sys.argv[6]
 
     logging_level_str = logging._levelNames[self.logging_level]
-    chout.setLevel(logging_level_str)
-    logger.setLevel(logging_level_str)
+    Logger.initialize_logger(__name__, logging_level=logging_level_str)
 
     # on windows we need to reload some of env variables manually because there is no default
paths for configs(like
     # /etc/something/conf on linux. When this env vars created by one of the Script execution,
they can not be updated
@@ -216,7 +211,7 @@ class Script(object):
             Script.passwords[get_path_from_configuration(k, Script.config)] = get_path_from_configuration(v,
Script.config)
 
     except IOError:
-      logger.exception("Can not read json file with command parameters: ")
+      Logging.logger.exception("Can not read json file with command parameters: ")
       sys.exit(1)
 
     # Run class method depending on a command type


Mime
View raw message