You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ji...@apache.org on 2024/08/05 08:38:31 UTC

(ambari) branch revert-3656-fix_repeat_initialize_objects created (now 11e86cb307)

This is an automated email from the ASF dual-hosted git repository.

jialiang pushed a change to branch revert-3656-fix_repeat_initialize_objects
in repository https://gitbox.apache.org/repos/asf/ambari.git


      at 11e86cb307 Revert "AMBARI-25883: init function of InitializerModule called twice #3656"

This branch includes the following new commits:

     new 11e86cb307 Revert "AMBARI-25883: init function of InitializerModule called twice #3656"

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ambari.apache.org
For additional commands, e-mail: commits-help@ambari.apache.org


(ambari) 01/01: Revert "AMBARI-25883: init function of InitializerModule called twice #3656"

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jialiang pushed a commit to branch revert-3656-fix_repeat_initialize_objects
in repository https://gitbox.apache.org/repos/asf/ambari.git

commit 11e86cb307f3de4c86908af3499bcc174b0aded9
Author: jialiang <25...@qq.com>
AuthorDate: Mon Aug 5 16:38:25 2024 +0800

    Revert "AMBARI-25883: init function of InitializerModule called twice #3656"
    
    This reverts commit d91f7a4079263a3c5f3e65197b006b30267fde96.
---
 .../main/python/ambari_agent/InitializerModule.py  |  2 ++
 ambari-agent/src/main/python/ambari_agent/main.py  | 36 +++++++++-------------
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/ambari-agent/src/main/python/ambari_agent/InitializerModule.py b/ambari-agent/src/main/python/ambari_agent/InitializerModule.py
index c256a8ddf5..18b0d8faa9 100644
--- a/ambari-agent/src/main/python/ambari_agent/InitializerModule.py
+++ b/ambari-agent/src/main/python/ambari_agent/InitializerModule.py
@@ -76,6 +76,8 @@ class InitializerModule:
     self.action_queue = None
     self.alert_scheduler_handler = None
 
+    self.init()
+
   def init(self):
     """
     Initialize properties
diff --git a/ambari-agent/src/main/python/ambari_agent/main.py b/ambari-agent/src/main/python/ambari_agent/main.py
index 9c8432cb0a..1107e2693f 100644
--- a/ambari-agent/src/main/python/ambari_agent/main.py
+++ b/ambari-agent/src/main/python/ambari_agent/main.py
@@ -316,8 +316,12 @@ def run_threads(initializer_module):
   initializer_module.heartbeat_thread.join()
   initializer_module.action_queue.join()
 
-# parse the options from command line
-def setup_option_parser():
+# event - event, that will be passed to Controller and NetUtil to make able to interrupt loops form outside process
+# we need this for windows os, where no sigterm available
+def main(initializer_module, heartbeat_stop_callback=None):
+  global config
+  global home_dir
+
   parser = OptionParser()
   parser.add_option("-v", "--verbose", dest="verbose", action="store_true", help="verbose log output", default=False)
   parser.add_option("-e", "--expected-hostname", dest="expected_hostname", action="store",
@@ -325,34 +329,24 @@ def setup_option_parser():
   parser.add_option("--home", dest="home_dir", action="store", help="Home directory", default="")
   (options, args) = parser.parse_args()
 
-  return options
-
-# initialize the loggers
-def init_loggers(options):
-  global is_logger_setup
+  expected_hostname = options.expected_hostname
+  home_dir = options.home_dir
 
   logging_level = logging.DEBUG if options.verbose else logging.INFO
 
   setup_logging(logger, AmbariConfig.AmbariConfig.getLogFile(), logging_level)
+  global is_logger_setup
+  is_logger_setup = True
   setup_logging(alerts_logger, AmbariConfig.AmbariConfig.getAlertsLogFile(), logging_level)
   setup_logging(alerts_logger_2, AmbariConfig.AmbariConfig.getAlertsLogFile(), logging_level)
   setup_logging(alerts_logger_global, AmbariConfig.AmbariConfig.getAlertsLogFile(), logging_level)
   setup_logging(apscheduler_logger, AmbariConfig.AmbariConfig.getAlertsLogFile(), logging_level)
   setup_logging(apscheduler_logger_global, AmbariConfig.AmbariConfig.getAlertsLogFile(), logging_level)
   Logger.initialize_logger('resource_management', logging_level=logging_level)
+  #with Environment() as env:
+  #  File("/abc")
 
-  is_logger_setup = True
-
-# event - event, that will be passed to Controller and NetUtil to make able to interrupt loops form outside process
-# we need this for windows os, where no sigterm available
-def main(options, initializer_module, heartbeat_stop_callback=None):
-  global config
-  global home_dir
-
-  expected_hostname = options.expected_hostname
-  home_dir = options.home_dir
-
-  # init data.
+  # init data, once loggers are setup to see exceptions/errors of initialization.
   initializer_module.init()
 
   if home_dir != "":
@@ -460,12 +454,10 @@ def main(options, initializer_module, heartbeat_stop_callback=None):
 if __name__ == "__main__":
   is_logger_setup = False
   try:
-    options = setup_option_parser()
-    init_loggers(options)
     initializer_module = InitializerModule()
     heartbeat_stop_callback = bind_signal_handlers(agentPid, initializer_module.stop_event)
 
-    main(options, initializer_module, heartbeat_stop_callback)
+    main(initializer_module, heartbeat_stop_callback)
   except SystemExit:
     raise
   except BaseException:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ambari.apache.org
For additional commands, e-mail: commits-help@ambari.apache.org