Ver código fonte

AMBARI-15022: Add Custom action to sync Standby with Master (goutamtadi via jaoki)

Jun Aoki 9 anos atrás
pai
commit
f41fccfc82

+ 11 - 3
ambari-server/src/main/resources/common-services/HAWQ/2.0.0/metainfo.xml

@@ -39,7 +39,7 @@
           </commandScript>
           </commandScript>
           <customCommands>
           <customCommands>
             <customCommand>
             <customCommand>
-              <name>IMMEDIATE_STOP_CLUSTER</name>
+              <name>IMMEDIATE_STOP_HAWQ_SERVICE</name>
               <commandScript>
               <commandScript>
                 <script>scripts/hawqmaster.py</script>
                 <script>scripts/hawqmaster.py</script>
                 <scriptType>PYTHON</scriptType>
                 <scriptType>PYTHON</scriptType>
@@ -78,7 +78,15 @@
           </commandScript>
           </commandScript>
           <customCommands>
           <customCommands>
             <customCommand>
             <customCommand>
-              <name>ACTIVATE_STANDBY</name>
+              <name>ACTIVATE_HAWQ_STANDBY</name>
+              <commandScript>
+                <script>scripts/hawqstandby.py</script>
+                <scriptType>PYTHON</scriptType>
+                <timeout>1200</timeout>
+              </commandScript>
+            </customCommand>
+            <customCommand>
+              <name>RESYNC_HAWQ_STANDBY</name>
               <commandScript>
               <commandScript>
                 <script>scripts/hawqstandby.py</script>
                 <script>scripts/hawqstandby.py</script>
                 <scriptType>PYTHON</scriptType>
                 <scriptType>PYTHON</scriptType>
@@ -110,7 +118,7 @@
           </commandScript>
           </commandScript>
           <customCommands>
           <customCommands>
             <customCommand>
             <customCommand>
-              <name>IMMEDIATE_STOP</name>
+              <name>IMMEDIATE_STOP_HAWQ_SEGMENT</name>
               <commandScript>
               <commandScript>
                 <script>scripts/hawqsegment.py</script>
                 <script>scripts/hawqsegment.py</script>
                 <scriptType>PYTHON</scriptType>
                 <scriptType>PYTHON</scriptType>

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

@@ -51,7 +51,7 @@ class HawqMaster(Script):
     from hawqstatus import get_pid_file
     from hawqstatus import get_pid_file
     check_process_status(get_pid_file())
     check_process_status(get_pid_file())
 
 
-  def immediate_stop_cluster(self, env):
+  def immediate_stop_hawq_service(self, env):
     master_helper.stop(hawq_constants.IMMEDIATE, hawq_constants.CLUSTER)
     master_helper.stop(hawq_constants.IMMEDIATE, hawq_constants.CLUSTER)
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":

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

@@ -73,7 +73,7 @@ class HawqSegment(Script):
     from hawqstatus import get_pid_file
     from hawqstatus import get_pid_file
     check_process_status(get_pid_file())
     check_process_status(get_pid_file())
 
 
-  def immediate_stop(self, env):
+  def immediate_stop_hawq_segment(self, env):
     self.stop(env, mode=hawq_constants.IMMEDIATE)
     self.stop(env, mode=hawq_constants.IMMEDIATE)
 
 
 
 

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

@@ -18,6 +18,7 @@ limitations under the License.
 """
 """
 from resource_management import Script
 from resource_management import Script
 from resource_management.libraries.functions.check_process_status import check_process_status
 from resource_management.libraries.functions.check_process_status import check_process_status
+from resource_management.core.logger import Logger
 
 
 import master_helper
 import master_helper
 import common
 import common
@@ -51,10 +52,15 @@ class HawqStandby(Script):
     from hawqstatus import get_pid_file
     from hawqstatus import get_pid_file
     check_process_status(get_pid_file())
     check_process_status(get_pid_file())
 
 
-  def activate_standby(self, env):
+  def activate_hawq_standby(self, env):
     import utils
     import utils
     utils.exec_hawq_operation(hawq_constants.ACTIVATE, "{0} -a -M {1} -v".format(hawq_constants.STANDBY, hawq_constants.FAST))
     utils.exec_hawq_operation(hawq_constants.ACTIVATE, "{0} -a -M {1} -v".format(hawq_constants.STANDBY, hawq_constants.FAST))
-
+  def resync_hawq_standby(self,env):
+    import params
+    import utils
+    Logger.info("Re-synchronizing HAWQ Standby..")
+    utils.exec_hawq_operation(hawq_constants.INIT, "{0} -n -a -v -M {1}".format(hawq_constants.STANDBY, hawq_constants.FAST))
+    Logger.info("HAWQ Standby host {0} Re-Sync successful".format(params.hostname))
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     HawqStandby().execute()
     HawqStandby().execute()

+ 1 - 1
ambari-web/app/controllers/main/admin/highAvailability/hawq/activateStandby/step3_controller.js

@@ -25,7 +25,7 @@ App.ActivateHawqStandbyWizardStep3Controller = App.HighAvailabilityProgressPageC
 
 
   clusterDeployState: 'ACTIVATE_HAWQ_STANDBY',
   clusterDeployState: 'ACTIVATE_HAWQ_STANDBY',
 
 
-  hawqActivateStandbyCustomCommand: "ACTIVATE_STANDBY",
+  hawqActivateStandbyCustomCommand: "ACTIVATE_HAWQ_STANDBY",
 
 
   hawqServiceName: "HAWQ",
   hawqServiceName: "HAWQ",
 
 

+ 23 - 23
ambari-web/app/controllers/main/service/item.js

@@ -523,29 +523,6 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     App.showAlertPopup(Em.I18n.t('services.service.actions.run.yarnRefreshQueues.error'), error);
     App.showAlertPopup(Em.I18n.t('services.service.actions.run.yarnRefreshQueues.error'), error);
   },
   },
 
 
-  /**
-   * On click handler for hawq stop cluster command from items menu
-   */
-
-  immediateStopHawqCluster: function(context) {
-    var controller = this;
-    return App.showConfirmationPopup(function() {
-      App.ajax.send({
-        name: 'service.item.executeCustomCommand',
-        sender: controller,
-        data: {
-          command: context.command,
-          context: Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.context'),
-          hosts: App.Service.find(context.service).get('hostComponents').findProperty('componentName', 'HAWQMASTER').get('hostName'),
-          serviceName: context.service,
-          componentName: context.component
-        },
-        success : 'executeCustomCommandSuccessCallback',
-        error : 'executeCustomCommandErrorCallback'
-      });
-    });
-  },
-
   /**
   /**
    * On click handler for rebalance Hdfs command from items menu
    * On click handler for rebalance Hdfs command from items menu
    */
    */
@@ -924,6 +901,29 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     });
     });
   },
   },
 
 
+  /**
+   * On click handler for custom hawq command from items menu
+   * @param context
+   */
+  executeHawqCustomCommand: function(context) {
+    var controller = this;
+    return App.showConfirmationPopup(function() {
+      App.ajax.send({
+        name : 'service.item.executeCustomCommand',
+        sender: controller,
+        data : {
+          command : context.command,
+          context : context.label,
+          hosts : App.Service.find(context.service).get('hostComponents').findProperty('componentName', context.component).get('hostName'),
+          serviceName : context.service,
+          componentName : context.component
+        },
+        success : 'executeCustomCommandSuccessCallback',
+        error : 'executeCustomCommandErrorCallback'
+      });
+    });
+  },
+
   /**
   /**
    * On click handler for custom command from items menu
    * On click handler for custom command from items menu
    * @param context
    * @param context

+ 4 - 1
ambari-web/app/messages.js

@@ -1684,9 +1684,12 @@ Em.I18n.translations = {
   'services.service.actions.run.stopLdapKnox.title':'Stop Demo LDAP Knox Gateway',
   'services.service.actions.run.stopLdapKnox.title':'Stop Demo LDAP Knox Gateway',
   'services.service.actions.run.stopLdapKnox.context':'Stop Demo LDAP',
   'services.service.actions.run.stopLdapKnox.context':'Stop Demo LDAP',
   'services.service.actions.run.startStopLdapKnox.error': 'Error during remote command: ',
   'services.service.actions.run.startStopLdapKnox.error': 'Error during remote command: ',
-  'services.service.actions.run.immediateStopHawqCluster.context':'Stop HAWQ Cluster (Immediate Mode)',
+  'services.service.actions.run.immediateStopHawqService.context':'Stop HAWQ Service (Immediate Mode)',
+  'services.service.actions.run.immediateStopHawqService.label':'Stop HAWQ Service (Immediate Mode)',
   'services.service.actions.run.immediateStopHawqSegment.label':'Stop (Immediate Mode)',
   'services.service.actions.run.immediateStopHawqSegment.label':'Stop (Immediate Mode)',
   'services.service.actions.run.immediateStopHawqSegment.context':'Stop HAWQ Segment (Immediate Mode)',
   'services.service.actions.run.immediateStopHawqSegment.context':'Stop HAWQ Segment (Immediate Mode)',
+  'services.service.actions.run.resyncHawqStandby.context':'Re-Sync HAWQ Standby',
+  'services.service.actions.run.resyncHawqStandby.label':'Re-Synchronize HAWQ Standby',
   'services.service.actions.manage_configuration_groups.short':'Manage Config Groups',
   'services.service.actions.manage_configuration_groups.short':'Manage Config Groups',
   'services.service.actions.serviceActions':'Service Actions',
   'services.service.actions.serviceActions':'Service Actions',
 
 

+ 19 - 8
ambari-web/app/models/host_component.js

@@ -271,6 +271,7 @@ App.HostComponentActionMap = {
     var RA = ctx.get('controller.content.hostComponents').findProperty('componentName', 'RANGER_ADMIN');
     var RA = ctx.get('controller.content.hostComponents').findProperty('componentName', 'RANGER_ADMIN');
     var HM = ctx.get('controller.content.hostComponents').findProperty('componentName', 'HAWQMASTER');
     var HM = ctx.get('controller.content.hostComponents').findProperty('componentName', 'HAWQMASTER');
     var HS = ctx.get('controller.content.hostComponents').findProperty('componentName', 'HAWQSTANDBY');
     var HS = ctx.get('controller.content.hostComponents').findProperty('componentName', 'HAWQSTANDBY');
+    var HMComponent = App.MasterComponent.find('HAWQMASTER');
     return {
     return {
       RESTART_ALL: {
       RESTART_ALL: {
         action: 'restartAllHostComponents',
         action: 'restartAllHostComponents',
@@ -374,20 +375,29 @@ App.HostComponentActionMap = {
         hasSubmenu: ctx.get('controller.isSeveralClients'),
         hasSubmenu: ctx.get('controller.isSeveralClients'),
         submenuOptions: ctx.get('controller.clientComponents')
         submenuOptions: ctx.get('controller.clientComponents')
       },
       },
-      IMMEDIATE_STOP_CLUSTER: {
-        action: 'immediateStopHawqCluster',
-        customCommand: 'IMMEDIATE_STOP_CLUSTER',
-        context: Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.context'),
-        label: Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.context'),
+      IMMEDIATE_STOP_HAWQ_SERVICE: {
+        action: 'executeHawqCustomCommand',
+        customCommand: 'IMMEDIATE_STOP_HAWQ_SERVICE',
+        context: Em.I18n.t('services.service.actions.run.immediateStopHawqService.context'),
+        label: Em.I18n.t('services.service.actions.run.immediateStopHawqService.label'),
         cssClass: 'icon-stop',
         cssClass: 'icon-stop',
         disabled: !HM || HM.get('workStatus') != App.HostComponentStatus.started
         disabled: !HM || HM.get('workStatus') != App.HostComponentStatus.started
       },
       },
-      IMMEDIATE_STOP: {
-        customCommand: 'IMMEDIATE_STOP',
+      IMMEDIATE_STOP_HAWQ_SEGMENT: {
+        customCommand: 'IMMEDIATE_STOP_HAWQ_SEGMENT',
         context: Em.I18n.t('services.service.actions.run.immediateStopHawqSegment.context'),
         context: Em.I18n.t('services.service.actions.run.immediateStopHawqSegment.context'),
         label: Em.I18n.t('services.service.actions.run.immediateStopHawqSegment.label'),
         label: Em.I18n.t('services.service.actions.run.immediateStopHawqSegment.label'),
         cssClass: 'icon-stop'
         cssClass: 'icon-stop'
       },
       },
+      RESYNC_HAWQ_STANDBY: {
+        action: 'executeHawqCustomCommand',
+        customCommand: 'RESYNC_HAWQ_STANDBY',
+        context: Em.I18n.t('services.service.actions.run.resyncHawqStandby.context'),
+        label: Em.I18n.t('services.service.actions.run.resyncHawqStandby.label'),
+        cssClass: 'icon-refresh',
+        isHidden : App.get('isSingleNode') || !HS ,
+        disabled: !((!!HMComponent && HMComponent.get('startedCount') === 1) && (!!HS && HS.get('workStatus') === App.HostComponentStatus.started))
+      },
       MASTER_CUSTOM_COMMAND: {
       MASTER_CUSTOM_COMMAND: {
         action: 'executeCustomCommand',
         action: 'executeCustomCommand',
         cssClass: 'icon-play-circle',
         cssClass: 'icon-play-circle',
@@ -407,9 +417,10 @@ App.HostComponentActionMap = {
         isHidden: App.get('isSingleNode') || HS,
         isHidden: App.get('isSingleNode') || HS,
         disabled: false
         disabled: false
       },
       },
-      TOGGLE_ACTIVATE_HAWQ_STANDBY: {
+      ACTIVATE_HAWQ_STANDBY: {
         action: 'activateHawqStandby',
         action: 'activateHawqStandby',
         label: Em.I18n.t('admin.activateHawqStandby.button.enable'),
         label: Em.I18n.t('admin.activateHawqStandby.button.enable'),
+        context: Em.I18n.t('admin.activateHawqStandby.button.enable'),
         cssClass: 'icon-arrow-up',
         cssClass: 'icon-arrow-up',
         isHidden: App.get('isSingleNode') || !HS,
         isHidden: App.get('isSingleNode') || !HS,
         disabled: false
         disabled: false

+ 14 - 0
ambari-web/app/utils/helper.js

@@ -659,6 +659,20 @@ App.format = {
     if (result === ' Refreshqueues ResourceManager') {
     if (result === ' Refreshqueues ResourceManager') {
       result = Em.I18n.t('services.service.actions.run.yarnRefreshQueues.title');
       result = Em.I18n.t('services.service.actions.run.yarnRefreshQueues.title');
     }
     }
+ // HAWQ custom commands on back Ops page.
+    if (result === ' Resync Hawq Standby HAWQ Standby Master') {
+        result = Em.I18n.t('services.service.actions.run.resyncHawqStandby.label');
+     }
+    if (result === ' Immediate Stop Hawq Service HAWQ Master') {
+        result = Em.I18n.t('services.service.actions.run.immediateStopHawqService.label');
+     }
+    if (result === ' Immediate Stop Hawq Segment HAWQ Segment') {
+        result = Em.I18n.t('services.service.actions.run.immediateStopHawqSegment.label');
+     }
+    if(result === ' Activate Hawq Standby HAWQ Standby Master') {
+        result = Em.I18n.t('admin.activateHawqStandby.button.enable');
+    }
+    //<---End HAWQ custom commands--->
     return result;
     return result;
   },
   },
 
 

+ 22 - 19
ambari-web/app/views/main/service/item.js

@@ -35,9 +35,9 @@ App.MainServiceItemView = Em.View.extend({
     'RESOURCEMANAGER': ['DECOMMISSION', 'REFRESHQUEUES'],
     'RESOURCEMANAGER': ['DECOMMISSION', 'REFRESHQUEUES'],
     'HBASE_MASTER': ['DECOMMISSION'],
     'HBASE_MASTER': ['DECOMMISSION'],
     'KNOX_GATEWAY': ['STARTDEMOLDAP','STOPDEMOLDAP'],
     'KNOX_GATEWAY': ['STARTDEMOLDAP','STOPDEMOLDAP'],
-    'HAWQMASTER': ['IMMEDIATE_STOP_CLUSTER'],
-    'HAWQSTANDBY': ['ACTIVATE_STANDBY'],
-    'HAWQSEGMENT': ['IMMEDIATE_STOP']
+    'HAWQMASTER': ['IMMEDIATE_STOP_HAWQ_SERVICE'],
+    'HAWQSEGMENT': ['IMMEDIATE_STOP_HAWQ_SEGMENT'],
+    'HAWQSTANDBY' : ['RESYNC_HAWQ_STANDBY','ACTIVATE_HAWQ_STANDBY']
   },
   },
 
 
    addActionMap: function() {
    addActionMap: function() {
@@ -172,7 +172,6 @@ App.MainServiceItemView = Em.View.extend({
             break;
             break;
           case 'HAWQ':
           case 'HAWQ':
             options.push(actionMap.TOGGLE_ADD_HAWQ_STANDBY);
             options.push(actionMap.TOGGLE_ADD_HAWQ_STANDBY);
-            options.push(actionMap.TOGGLE_ACTIVATE_HAWQ_STANDBY);
             break;
             break;
         }
         }
       }
       }
@@ -198,21 +197,25 @@ App.MainServiceItemView = Em.View.extend({
         });
         });
       }
       }
 
 
-      var hawqMasterComponent = App.StackServiceComponent.find().findProperty('componentName','HAWQMASTER');
-      if (serviceName === 'HAWQ' && hawqMasterComponent) {
-        var hawqMasterCustomCommands = hawqMasterComponent.get('customCommands');
-        customCommandToStopCluster = 'IMMEDIATE_STOP_CLUSTER';
-        if (hawqMasterCustomCommands && hawqMasterCustomCommands.contains(customCommandToStopCluster)) {
-          options.push(self.createOption(actionMap.IMMEDIATE_STOP_CLUSTER, {
-            label: Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.context'),
-            context: {
-              label: Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.context'),
-              service: hawqMasterComponent.get('serviceName'),
-              component: hawqMasterComponent.get('componentName'),
-              command: customCommandToStopCluster
-            }
-          }));
-        }
+      /**
+       * Display all custom commands of Master and StandBy on Service page.
+       **/
+      if(serviceName === 'HAWQ') {
+        var hawqMasterComponent = App.StackServiceComponent.find().findProperty('componentName','HAWQMASTER');
+        var hawqStandByComponent = App.StackServiceComponent.find().findProperty('componentName','HAWQSTANDBY');
+        components = [hawqMasterComponent,hawqStandByComponent]
+        components.forEach(function(component){
+          component.get('customCommands').forEach(function(command){
+            options.push(self.createOption(actionMap[command], {
+              context: {
+                label: actionMap[command].context,
+                service: component.get('serviceName'),
+                component: component.get('componentName'),
+                command: command
+              }
+            }));
+          });
+        });
       }
       }
 
 
       self.addActionMap().filterProperty('service', serviceName).forEach(function(item) {
       self.addActionMap().filterProperty('service', serviceName).forEach(function(item) {