فهرست منبع

AMBARI-14351: Add custom action to stop hawq cluster and segments with immediate mode(bhuvnesh2703 via jaoki)

Jun Aoki 9 سال پیش
والد
کامیت
4196801e8f

+ 20 - 0
ambari-server/src/main/resources/common-services/HAWQ/2.0.0/metainfo.xml

@@ -36,6 +36,16 @@
             <scriptType>PYTHON</scriptType>
             <timeout>1200</timeout>
           </commandScript>
+          <customCommands>
+            <customCommand>
+              <name>IMMEDIATE_STOP_CLUSTER</name>
+              <commandScript>
+                <script>scripts/hawqmaster.py</script>
+                <scriptType>PYTHON</scriptType>
+                <timeout>1200</timeout>
+              </commandScript>
+            </customCommand>
+          </customCommands>
           <dependencies>
             <dependency>
               <name>HDFS/NAMENODE</name>
@@ -85,6 +95,16 @@
             <scriptType>PYTHON</scriptType>
             <timeout>600</timeout>
           </commandScript>
+          <customCommands>
+            <customCommand>
+              <name>IMMEDIATE_STOP</name>
+              <commandScript>
+                <script>scripts/hawqsegment.py</script>
+                <scriptType>PYTHON</scriptType>
+                <timeout>1200</timeout>
+              </commandScript>
+            </customCommand>
+          </customCommands>
         </component>
       </components> 
       <requiredServices>

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

@@ -24,6 +24,9 @@ START = "start"
 INIT = "init"
 STOP = "stop"
 YARN = "yarn"
+CLUSTER = "cluster"
+IMMEDIATE = "immediate"
+FAST = "fast"
 
 # Users
 root_user = "root"

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

@@ -45,11 +45,14 @@ class HawqMaster(Script):
     master_helper.start_master()
 
   def stop(self, env):
-    master_helper.stop_master()
+    master_helper.stop()
 
   def status(self, env):
     from hawqstatus import get_pid_file
     check_process_status(get_pid_file())
 
+  def immediate_stop_cluster(self, env):
+    master_helper.stop(hawq_constants.IMMEDIATE, hawq_constants.CLUSTER)
+
 if __name__ == "__main__":
   HawqMaster().execute()

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

@@ -49,7 +49,7 @@ class HawqSegment(Script):
     import params
     return utils.exec_hawq_operation(
           hawq_constants.START, 
-          "{0} -a".format(hawq_constants.SEGMENT), 
+          "{0} -a -v".format(hawq_constants.SEGMENT), 
           not_if=utils.chk_hawq_process_status_cmd(params.hawq_segment_address_port))
 
   def start(self, env):
@@ -64,10 +64,9 @@ class HawqSegment(Script):
     self.__init_segment()
 
 
-  def stop(self, env):
+  def stop(self, env, mode=hawq_constants.FAST):
     import params
-
-    utils.exec_hawq_operation(hawq_constants.STOP, "{0} -a".format(hawq_constants.SEGMENT), only_if=utils.chk_hawq_process_status_cmd(
+    utils.exec_hawq_operation(hawq_constants.STOP, "{0} -M {1} -a -v".format(hawq_constants.SEGMENT, mode), only_if=utils.chk_hawq_process_status_cmd(
                                 params.hawq_segment_address_port))
 
 
@@ -75,6 +74,9 @@ class HawqSegment(Script):
     from hawqstatus import get_pid_file
     check_process_status(get_pid_file())
 
+  def immediate_stop(self, env):
+    self.stop(env, mode=hawq_constants.IMMEDIATE)
+
 
   @staticmethod
   def __init_segment():

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

@@ -45,7 +45,7 @@ class HawqStandby(Script):
     master_helper.start_master()
 
   def stop(self, env):
-    master_helper.stop_master()
+    master_helper.stop()
 
   def status(self, env):
     from hawqstatus import get_pid_file

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

@@ -131,7 +131,7 @@ def __start_local_master():
   component_name = __get_component_name()
   utils.exec_hawq_operation(
         hawq_constants.START, 
-        "{0} -a".format(component_name),
+        "{0} -a -v".format(component_name),
         not_if=utils.chk_hawq_process_status_cmd(params.hawq_master_address_port, component_name))
 
   
@@ -186,15 +186,15 @@ def start_master():
     __init_standby()
 
 
-def stop_master():
+def stop(mode=hawq_constants.FAST, component=None):
   """
-  Stops the HAWQ Master/Standby
+  Stops the HAWQ Master/Standby, if component is cluster performs cluster level operation from master
   """
   import params
-  component_name = __get_component_name()
+  component_name = component if component else __get_component_name()
   utils.exec_hawq_operation(
                 hawq_constants.STOP,
-                "{0} -a".format(component_name),
+                "{0} -M {1} -a -v".format(component_name, mode),
                 only_if=utils.chk_hawq_process_status_cmd(params.hawq_master_address_port, component_name))