Repository: ambari Updated Branches: refs/heads/trunk 3a9b0bbaf -> 52d1a911e
AMBARI-14353. Update command context for background message when custom command is executed for HAWQ(Bhuvnesh Chaudhary via odiachenko). Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/52d1a911 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/52d1a911 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/52d1a911 Branch: refs/heads/trunk Commit: 52d1a911e084fb17fae265a284cc23f5efe1eb79 Parents: 3a9b0bb Author: Oleksandr Diachenko <[email protected]> Authored: Thu Dec 17 11:07:24 2015 -0800 Committer: Oleksandr Diachenko <[email protected]> Committed: Thu Dec 17 11:07:24 2015 -0800 ---------------------------------------------------------------------- ambari-web/app/controllers/main/service/item.js | 40 ++++++++++++++++++++ ambari-web/app/messages.js | 2 + ambari-web/app/models/host_component.js | 10 ++++- ambari-web/app/utils/ajax/ajax.js | 20 ++++++++++ ambari-web/app/views/main/service/item.js | 20 +++++++++- 5 files changed, 90 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/52d1a911/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 475342e..aa4ca5d 100644 --- a/ambari-web/app/controllers/main/service/item.js +++ b/ambari-web/app/controllers/main/service/item.js @@ -489,6 +489,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/52d1a911/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 3858bd2..bd71c2f 100644 --- a/ambari-web/app/messages.js +++ b/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', http://git-wip-us.apache.org/repos/asf/ambari/blob/52d1a911/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 db750e0..4fe08f5 100644 --- a/ambari-web/app/models/host_component.js +++ b/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 = { } }; } -}; \ No newline at end of file +}; http://git-wip-us.apache.org/repos/asf/ambari/blob/52d1a911/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 1187d0a..980cad8 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/52d1a911/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 9c72164..f85f266 100644 --- a/ambari-web/app/views/main/service/item.js +++ b/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;
