Repository: ambari
Updated Branches:
  refs/heads/branch-2.1.2 a9290ec85 -> 39b964a7d


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/39b964a7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/39b964a7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/39b964a7

Branch: refs/heads/branch-2.1.2
Commit: 39b964a7d5d869c9244dc1de324aeff8ab2346b7
Parents: a9290ec
Author: Andrew Onishuk <aonis...@hortonworks.com>
Authored: Fri Oct 9 14:45:48 2015 +0300
Committer: Andrew Onishuk <aonis...@hortonworks.com>
Committed: Fri Oct 9 14:45:48 2015 +0300

----------------------------------------------------------------------
 .../src/main/python/resource_management/core/logger.py      | 4 ++--
 .../python/resource_management/libraries/script/script.py   | 9 +++------
 2 files changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/39b964a7/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/39b964a7/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 f43c414..efd34e3 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
@@ -171,11 +171,9 @@ 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)
 
@@ -188,8 +186,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
@@ -208,7 +205,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

Reply via email to