ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject ambari git commit: AMBARI-21532. Namenode restart - PID file delete happens before the call to check status (dlysnichenko)
Date Mon, 14 Aug 2017 13:29:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 5e498c665 -> d9d58fda7


AMBARI-21532. Namenode restart - PID file delete happens before the call to check status (dlysnichenko)


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

Branch: refs/heads/branch-2.6
Commit: d9d58fda7b9942b89dc611486595509ad8df664d
Parents: 5e498c6
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Mon Aug 14 16:28:12 2017 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Mon Aug 14 16:28:12 2017 +0300

----------------------------------------------------------------------
 .../libraries/functions/check_process_status.py | 20 ++++++++++++++++++++
 .../libraries/script/script.py                  |  4 ++--
 .../HDFS/2.1.0.2.0/package/scripts/utils.py     |  1 +
 .../0.8/services/HDFS/package/scripts/utils.py  |  3 +++
 .../4.0/services/HDFS/package/scripts/utils.py  |  2 ++
 .../4.2/services/HDFS/package/scripts/utils.py  |  2 ++
 6 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d9d58fda/ambari-common/src/main/python/resource_management/libraries/functions/check_process_status.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/check_process_status.py
b/ambari-common/src/main/python/resource_management/libraries/functions/check_process_status.py
index 7961f00..ac54bc9 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/check_process_status.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/check_process_status.py
@@ -59,3 +59,23 @@ def check_process_status(pid_file):
     Logger.info("Process with pid {0} is not running. Stale pid file"
               " at {1}".format(pid, pid_file))
     raise ComponentIsNotRunning()
+
+
+def wait_process_stopped(pid_file):
+  """
+    Waits until component is actually stopped (check is performed using
+    check_process_status() method.
+    """
+  import time
+  component_is_stopped = False
+  counter = 0
+  while not component_is_stopped:
+    try:
+      if counter % 10 == 0:
+        Logger.logger.info("Waiting for actual component stop")
+      check_process_status(pid_file)
+      time.sleep(1)
+      counter += 1
+    except ComponentIsNotRunning, e:
+      Logger.logger.debug(" reports ComponentIsNotRunning")
+      component_is_stopped = True

http://git-wip-us.apache.org/repos/asf/ambari/blob/d9d58fda/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 abbada4..54a7e6d 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
@@ -387,7 +387,7 @@ class Script(object):
     status_method = getattr(self, 'status')
     component_is_stopped = False
     counter = 0
-    while not component_is_stopped :
+    while not component_is_stopped:
       try:
         if counter % 100 == 0:
           Logger.logger.info("Waiting for actual component stop")
@@ -1019,4 +1019,4 @@ class Script(object):
 
   def __init__(self):
     if Script.instance is not None:
-      raise Fail("An instantiation already exists! Use, get_instance() method.")
\ No newline at end of file
+      raise Fail("An instantiation already exists! Use, get_instance() method.")

http://git-wip-us.apache.org/repos/asf/ambari/blob/d9d58fda/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
index e2d60a0..f178d23 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/scripts/utils.py
@@ -25,6 +25,7 @@ import ambari_simplejson as json # simplejson is much faster comparing to
Python
 from resource_management.core.resources.system import Directory, File, Execute
 from resource_management.libraries.functions.format import format
 from resource_management.libraries.functions import check_process_status
+from resource_management.libraries.functions.check_process_status import wait_process_stopped
 from resource_management.libraries.functions import StackFeature
 from resource_management.libraries.functions.stack_features import check_stack_feature
 from resource_management.core import shell

http://git-wip-us.apache.org/repos/asf/ambari/blob/d9d58fda/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HDFS/package/scripts/utils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HDFS/package/scripts/utils.py
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HDFS/package/scripts/utils.py
index 7dcbca8..b9f5242 100644
--- a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HDFS/package/scripts/utils.py
+++ b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HDFS/package/scripts/utils.py
@@ -21,6 +21,7 @@ import os
 from resource_management import *
 import re
 
+from resource_management.libraries.functions.check_process_status import wait_process_stopped
 
 def service(action=None, name=None, user=None, create_pid_dir=False,
             create_log_dir=False):
@@ -123,6 +124,8 @@ def service(action=None, name=None, user=None, create_pid_dir=False,
           not_if=service_is_up
   )
   if action == "stop":
+    wait_process_stopped(pid_file)
+
     File(pid_file,
          action="delete",
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/d9d58fda/ambari-server/src/main/resources/stacks/BigInsights/4.0/services/HDFS/package/scripts/utils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/BigInsights/4.0/services/HDFS/package/scripts/utils.py
b/ambari-server/src/main/resources/stacks/BigInsights/4.0/services/HDFS/package/scripts/utils.py
index 5cd1735..4eaa676 100755
--- a/ambari-server/src/main/resources/stacks/BigInsights/4.0/services/HDFS/package/scripts/utils.py
+++ b/ambari-server/src/main/resources/stacks/BigInsights/4.0/services/HDFS/package/scripts/utils.py
@@ -26,6 +26,7 @@ from resource_management.libraries.functions.format import format
 from resource_management.core.shell import call, checked_call
 from resource_management.core.exceptions import ComponentIsNotRunning
 from resource_management.libraries.functions.curl_krb_request import curl_krb_request
+from resource_management.libraries.functions.check_process_status import wait_process_stopped
 
 from zkfc_slave import ZkfcSlave
 
@@ -251,6 +252,7 @@ def service(action=None, name=None, user=None, options="", create_pid_dir=False,
   )
 
   if action == "stop":
+    wait_process_stopped(pid_file)
     File(pid_file,
          action="delete",
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/d9d58fda/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/HDFS/package/scripts/utils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/HDFS/package/scripts/utils.py
b/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/HDFS/package/scripts/utils.py
index 4f5124b..e9a299a 100755
--- a/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/HDFS/package/scripts/utils.py
+++ b/ambari-server/src/main/resources/stacks/BigInsights/4.2/services/HDFS/package/scripts/utils.py
@@ -22,6 +22,7 @@ import urllib2
 import ambari_simplejson as json # simplejson is much faster comparing to Python 2.6 json
module and has the same functions set.
 
 from resource_management.core.resources.system import Directory, File, Execute
+from resource_management.libraries.functions.check_process_status import wait_process_stopped
 from resource_management.libraries.functions.format import format
 from resource_management.libraries.functions import check_process_status
 from resource_management.libraries.functions.version import compare_versions
@@ -280,6 +281,7 @@ def service(action=None, name=None, user=None, options="", create_pid_dir=False,
 
   elif action == "stop":
     Execute(daemon_cmd, only_if=process_id_exists_command, environment=hadoop_env_exports)
+    wait_process_stopped(pid_file)
     File(pid_file, action="delete")
 
 


Mime
View raw message