Repository: ambari Updated Branches: refs/heads/branch-2.2 8bb69855f -> ce499c056
AMBARI-14353: Update command context for background message when custom command is executed for HAWQ Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ce499c05 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ce499c05 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ce499c05 Branch: refs/heads/branch-2.2 Commit: ce499c05679a5b849bebc1070e4492d468b39a73 Parents: 8bb6985 Author: Jun Aoki <[email protected]> Authored: Tue Dec 29 15:54:59 2015 -0800 Committer: Jun Aoki <[email protected]> Committed: Tue Dec 29 15:54:59 2015 -0800 ---------------------------------------------------------------------- ambari-web/app/controllers/main/service/item.js | 40 ++++++++++++++++++++ ambari-web/app/messages.js | 2 + ambari-web/app/models/host_component.js | 8 ++++ ambari-web/app/utils/ajax/ajax.js | 20 ++++++++++ ambari-web/app/views/main/service/item.js | 20 +++++++++- 5 files changed, 89 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ce499c05/ambari-web/app/controllers/main/service/item.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js index 21a1136..88bbc4f 100644 --- a/ambari-web/app/controllers/main/service/item.js +++ b/ambari-web/app/controllers/main/service/item.js @@ -501,6 +501,46 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow }, /** + * 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 */ rebalanceHdfsNodes: function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/ce499c05/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index f52b325..b8257e6 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1670,6 +1670,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', http://git-wip-us.apache.org/repos/asf/ambari/blob/ce499c05/ambari-web/app/models/host_component.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/host_component.js b/ambari-web/app/models/host_component.js index 1ef23db..600105b 100644 --- a/ambari-web/app/models/host_component.js +++ b/ambari-web/app/models/host_component.js @@ -357,6 +357,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', http://git-wip-us.apache.org/repos/asf/ambari/blob/ce499c05/ambari-web/app/utils/ajax/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index 258c7c1..b70742d 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/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': { http://git-wip-us.apache.org/repos/asf/ambari/blob/ce499c05/ambari-web/app/views/main/service/item.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/item.js b/ambari-web/app/views/main/service/item.js index d141229..94977cd 100644 --- a/ambari-web/app/views/main/service/item.js +++ b/ambari-web/app/views/main/service/item.js @@ -41,7 +41,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() { @@ -191,6 +192,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;
