ambari git commit: AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)
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 OnishukAuthored: Fri Oct 9 14:45:48 2015 +0300 Committer: Andrew Onishuk 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
ambari git commit: AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)
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 OnishukAuthored: Thu Oct 8 13:08:54 2015 +0300 Committer: Andrew Onishuk 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
ambari git commit: AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)
Repository: ambari Updated Branches: refs/heads/trunk 361f0a49d -> 664bde1c6 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/664bde1c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/664bde1c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/664bde1c Branch: refs/heads/trunk Commit: 664bde1c6e15961b39eb673b337be9f7bc6a50d2 Parents: 361f0a4 Author: Andrew OnishukAuthored: Thu Oct 8 18:22:20 2015 +0300 Committer: Andrew Onishuk Committed: Thu Oct 8 18:22:20 2015 +0300 -- .../python/resource_management/libraries/script/script.py| 4 ++-- .../src/test/python/stacks/2.0.6/FLUME/test_flume.py | 8 +++- 2 files changed, 5 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/664bde1c/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 3e15898..e647c11 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 @@ -116,7 +116,7 @@ class Script(object): Script.structuredOut = json.load(fp) except Exception: errMsg = 'Unable to read structured output from ' + self.stroutfile -Logging.logger.exception(errMsg) +Logger.logger.exception(errMsg) pass # version is only set in a specific way and should not be carried @@ -211,7 +211,7 @@ class Script(object): Script.passwords[get_path_from_configuration(k, Script.config)] = get_path_from_configuration(v, Script.config) except IOError: - Logging.logger.exception("Can not read json file with command parameters: ") + Logger.logger.exception("Can not read json file with command parameters: ") sys.exit(1) # Run class method depending on a command type http://git-wip-us.apache.org/repos/asf/ambari/blob/664bde1c/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py -- diff --git a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py index 28b0802..6642603 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py +++ b/ambari-server/src/test/python/stacks/2.0.6/FLUME/test_flume.py @@ -163,20 +163,18 @@ class TestFlumeHandler(RMFTestCase): self.assertFalse("version" in script.structuredOut) - @patch("resource_management.libraries.script.Script.logger", autospec = True) - def test_bad_struct_out(self, logger_mock): + def test_bad_struct_out(self): from resource_management.libraries.script import Script - - logger_mock.warn = MagicMock() + from resource_management.core.logger import Logger configs_path = os.path.join(RMFTestCase.get_src_folder(), "test/python/stacks", self.STACK_VERSION, "configs") + Logger.initialize_logger() script = Script() script.stroutfile = os.path.join(configs_path, "structured-out-status-bad.json") script.load_structured_out() - self.assertTrue(logger_mock.warn.called) self.assertTrue(script.structuredOut == {}) @patch("resource_management.libraries.script.Script.put_structured_out")
[06/31] ambari git commit: AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)
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/b8be80b0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b8be80b0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b8be80b0 Branch: refs/heads/branch-dev-patch-upgrade Commit: b8be80b08cf50436fb1285b5deaa6a4ca8fe8739 Parents: a125f97 Author: Andrew OnishukAuthored: Mon Oct 5 12:12:34 2015 +0300 Committer: Andrew Onishuk Committed: Mon Oct 5 12:12:34 2015 +0300 -- ambari-common/src/main/python/resource_management/core/logger.py | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/b8be80b0/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..0ea34ff 100644 --- a/ambari-common/src/main/python/resource_management/core/logger.py +++ b/ambari-common/src/main/python/resource_management/core/logger.py @@ -37,6 +37,10 @@ class Logger: @staticmethod def initialize_logger(name='resource_management', logging_level=logging.INFO, format='%(asctime)s - %(message)s'): # set up logging (two separate loggers for stderr and stdout with different loglevels) + +if Logger.logger: + return + logger = logging.getLogger(name) logger.setLevel(logging_level) formatter = logging.Formatter(format)
ambari git commit: AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)
Repository: ambari Updated Branches: refs/heads/branch-2.1 00aabde5e -> 32a5c51c9 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/32a5c51c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/32a5c51c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/32a5c51c Branch: refs/heads/branch-2.1 Commit: 32a5c51c90b0c522be2ea640d34e38b11849550a Parents: 00aabde Author: Andrew OnishukAuthored: Tue Oct 6 18:01:33 2015 +0300 Committer: Andrew Onishuk Committed: Tue Oct 6 18:01:33 2015 +0300 -- .../src/main/python/resource_management/core/logger.py | 6 +- .../python/resource_management/libraries/script/script.py | 9 +++-- 2 files changed, 4 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/32a5c51c/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 0ea34ff..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,11 +36,9 @@ class Logger: @staticmethod def initialize_logger(name='resource_management', logging_level=logging.INFO, format='%(asctime)s - %(message)s'): -# set up logging (two separate loggers for stderr and stdout with different loglevels) - 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) formatter = logging.Formatter(format) @@ -55,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/32a5c51c/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
[2/2] ambari git commit: AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)
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/13f808e3 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/13f808e3 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/13f808e3 Branch: refs/heads/branch-2.1 Commit: 13f808e3cb7bd27af2781757e97bfd8ea540308c Parents: 9e0ca3e Author: Andrew OnishukAuthored: Mon Oct 5 12:12:36 2015 +0300 Committer: Andrew Onishuk Committed: Mon Oct 5 12:12:36 2015 +0300 -- ambari-common/src/main/python/resource_management/core/logger.py | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/13f808e3/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..0ea34ff 100644 --- a/ambari-common/src/main/python/resource_management/core/logger.py +++ b/ambari-common/src/main/python/resource_management/core/logger.py @@ -37,6 +37,10 @@ class Logger: @staticmethod def initialize_logger(name='resource_management', logging_level=logging.INFO, format='%(asctime)s - %(message)s'): # set up logging (two separate loggers for stderr and stdout with different loglevels) + +if Logger.logger: + return + logger = logging.getLogger(name) logger.setLevel(logging_level) formatter = logging.Formatter(format)
[1/2] ambari git commit: AMBARI-13307. Agent instance memory footprint likely gradually growing (aonishuk)
Repository: ambari Updated Branches: refs/heads/branch-2.1 9e0ca3eab -> 13f808e3c refs/heads/trunk a125f978c -> b8be80b08 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/b8be80b0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b8be80b0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b8be80b0 Branch: refs/heads/trunk Commit: b8be80b08cf50436fb1285b5deaa6a4ca8fe8739 Parents: a125f97 Author: Andrew OnishukAuthored: Mon Oct 5 12:12:34 2015 +0300 Committer: Andrew Onishuk Committed: Mon Oct 5 12:12:34 2015 +0300 -- ambari-common/src/main/python/resource_management/core/logger.py | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/b8be80b0/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..0ea34ff 100644 --- a/ambari-common/src/main/python/resource_management/core/logger.py +++ b/ambari-common/src/main/python/resource_management/core/logger.py @@ -37,6 +37,10 @@ class Logger: @staticmethod def initialize_logger(name='resource_management', logging_level=logging.INFO, format='%(asctime)s - %(message)s'): # set up logging (two separate loggers for stderr and stdout with different loglevels) + +if Logger.logger: + return + logger = logging.getLogger(name) logger.setLevel(logging_level) formatter = logging.Formatter(format)