Browse Source

AMBARI-14353. Update command context for background message when custom command is executed for HAWQ(Bhuvnesh Chaudhary via odiachenko).

Oleksandr Diachenko 9 năm trước cách đây
mục cha
commit
52d1a911e0

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

@@ -488,6 +488,46 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     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.immediateStopHawqCluster',
+        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 : 'executeImmediateStopHawqClusterCmdSuccessCallback',
+        error : 'executeImmediateStopHawqClusterCmdErrorCallback'
+      });
+    });
+  },
+
+  executeImmediateStopHawqClusterCmdSuccessCallback  : function(data, ajaxOptions, params) {
+    if (data.Requests.id) {
+      App.router.get('backgroundOperationsController').showPopup();
+    }
+  },
+
+  executeImmediateStopHawqClusterCmdErrorCallback : function(data) {
+    var error = Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.error');
+    if(data && data.responseText){
+      try {
+        var json = $.parseJSON(data.responseText);
+        error += json.message;
+      } catch (err) {}
+    }
+    App.showAlertPopup(Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.error'), error);
+  },
+
   /**
    * On click handler for rebalance Hdfs command from items menu
    */

+ 2 - 0
ambari-web/app/messages.js

@@ -1658,6 +1658,8 @@ Em.I18n.translations = {
   'services.service.actions.run.stopLdapKnox.title':'Stop Demo LDAP Knox Gateway',
   'services.service.actions.run.stopLdapKnox.context':'Stop Demo LDAP',
   '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.immediateStopHawqCluster.error': 'Error during remote command: ',
   'services.service.actions.manage_configuration_groups.short':'Manage Config Groups',
   'services.service.actions.serviceActions':'Service Actions',
   'services.service.summary.unknown':'unknown',

+ 9 - 1
ambari-web/app/models/host_component.js

@@ -358,6 +358,14 @@ App.HostComponentActionMap = {
         hasSubmenu: ctx.get('controller.isSeveralClients'),
         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'),
+        cssClass: 'icon-stop',
+        disabled: false,
+      },
       MASTER_CUSTOM_COMMAND: {
         action: 'executeCustomCommand',
         cssClass: 'icon-play-circle',
@@ -366,4 +374,4 @@ App.HostComponentActionMap = {
       }
     };
   }
-};
+};

+ 20 - 0
ambari-web/app/utils/ajax/ajax.js

@@ -624,6 +624,26 @@ var urls = {
       }
     }
   },
+  'service.item.immediateStopHawqCluster': {
+    'real': '/clusters/{clusterName}/requests',
+    'mock': '',
+    'format': function (data) {
+      return {
+        type: 'POST',
+        data: JSON.stringify({
+          RequestInfo: {
+            'context': data.context,
+            'command': data.command
+          },
+          "Requests/resource_filters": [{
+            "service_name": data.serviceName,
+            "component_name": data.componentName,
+            'hosts': data.hosts
+          }]
+        })
+      }
+    }
+  },
   /*************************CONFIG THEME****************************************/
 
   'configs.theme': {

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

@@ -34,7 +34,8 @@ App.MainServiceItemView = Em.View.extend({
     'NAMENODE': ['DECOMMISSION', 'REBALANCEHDFS'],
     'RESOURCEMANAGER': ['DECOMMISSION', 'REFRESHQUEUES'],
     'HBASE_MASTER': ['DECOMMISSION'],
-    'KNOX_GATEWAY': ['STARTDEMOLDAP','STOPDEMOLDAP']
+    'KNOX_GATEWAY': ['STARTDEMOLDAP','STOPDEMOLDAP'],
+    'HAWQMASTER': ['IMMEDIATE_STOP_CLUSTER']
   },
 
    addActionMap: function() {
@@ -184,6 +185,23 @@ 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
+          }
+        })) };
+      }
+
       self.addActionMap().filterProperty('service', serviceName).forEach(function(item) {
         if (App.get('components.addableToHost').contains(item.component)) {
           item.action = 'add' + item.component;