瀏覽代碼

AMBARI-13827: hawq standby stop is not working (bhuvnesh2703 via jaoki)

Jun Aoki 9 年之前
父節點
當前提交
dd17417072

+ 2 - 2
ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/hawqsegment.py

@@ -50,7 +50,7 @@ class HawqSegment(Script):
     return utils.exec_hawq_operation(
           constants.START, 
           "{0} -a".format(constants.SEGMENT), 
-          not_if=utils.chk_postgres_status_cmd(params.hawq_segment_address_port))
+          not_if=utils.chk_hawq_process_status_cmd(params.hawq_segment_address_port))
 
   def start(self, env):
     self.configure(env)
@@ -67,7 +67,7 @@ class HawqSegment(Script):
   def stop(self, env):
     import params
 
-    utils.exec_hawq_operation(constants.STOP, "{0} -a".format(constants.SEGMENT), only_if=utils.chk_postgres_status_cmd(
+    utils.exec_hawq_operation(constants.STOP, "{0} -a".format(constants.SEGMENT), only_if=utils.chk_hawq_process_status_cmd(
                                 params.hawq_segment_address_port))
 
 

+ 6 - 4
ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/master_helper.py

@@ -121,10 +121,11 @@ def __start_local_master():
   Starts HAWQ Master or HAWQ Standby Master component on the host
   """
   import params
+  component_name = __get_component_name()
   utils.exec_hawq_operation(
         constants.START, 
-        "{0} -a".format(__get_component_name()), 
-        not_if=utils.chk_postgres_status_cmd(params.hawq_master_address_port))
+        "{0} -a".format(component_name),
+        not_if=utils.chk_hawq_process_status_cmd(params.hawq_master_address_port, component_name))
 
   
 def __is_local_initialized():
@@ -183,10 +184,11 @@ def stop_master():
   Stops the HAWQ Master/Standby
   """
   import params
+  component_name = __get_component_name()
   utils.exec_hawq_operation(
                 constants.STOP,
-                "{0} -a".format(__get_component_name()),
-                only_if=utils.chk_postgres_status_cmd(params.hawq_master_address_port))
+                "{0} -a".format(component_name),
+                only_if=utils.chk_hawq_process_status_cmd(params.hawq_master_address_port, component_name))
 
 
 def __is_active_master():

+ 4 - 3
ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/utils.py

@@ -23,11 +23,12 @@ from resource_management.core.logger import Logger
 
 import constants
 
-def chk_postgres_status_cmd(port):
+def chk_hawq_process_status_cmd(port, component_name=None):
   """
-  Checks if the postgres port is occupied
+  Check if hawq postgres / gpsyncmaster process is running
   """
-  return "netstat -tupln | egrep ':{0}\s' | egrep postgres".format(port)
+  process = "gpsyncmaster" if component_name == constants.STANDBY else "postgres"
+  return "netstat -tupln | egrep ':{0}\s' | egrep {1}".format(port, process)
 
 
 def create_dir_as_hawq_user(directory):