Updated Branches: refs/heads/trunk 9395e1f87 -> ab0c39c07
AMBARI-4281. Implement Restart All capability for service. (srimanth) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ab0c39c0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ab0c39c0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ab0c39c0 Branch: refs/heads/trunk Commit: ab0c39c07a6153f214dfd486ec6df314877db6ba Parents: 9395e1f Author: Srimanth Gunturi <[email protected]> Authored: Mon Jan 13 15:49:20 2014 -0800 Committer: Srimanth Gunturi <[email protected]> Committed: Tue Jan 14 10:20:21 2014 -0800 ---------------------------------------------------------------------- ambari-web/app/controllers/main/service/item.js | 3 +- ambari-web/app/messages.js | 3 ++ ambari-web/app/utils/ajax.js | 22 ++++++++- .../app/utils/batch_scheduled_requests.js | 48 ++++++++++++++++++++ ambari-web/app/views/main/service/item.js | 2 + 5 files changed, 76 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ab0c39c0/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 72cec23..92d160d 100644 --- a/ambari-web/app/controllers/main/service/item.js +++ b/ambari-web/app/controllers/main/service/item.js @@ -187,7 +187,8 @@ App.MainServiceItemController = Em.Controller.extend({ }); }, - restartAllHostComponents: function(event) { + restartAllHostComponents : function(serviceName) { + batchUtils.doPostRestartAllServiceComponents(serviceName); }, rollingRestart: function(hostComponentName) { http://git-wip-us.apache.org/repos/asf/ambari/blob/ab0c39c0/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index c09b3bf..90130db 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1783,6 +1783,9 @@ Em.I18n.translations = { 'rollingrestart.dialog.msg.staleConfigsOnly': 'Only restart {0}s with stale configs', 'rollingrestart.rest.context': 'Rolling Restart of {0}s - batch {1} of {2}', + 'restart.service.all': 'Restart All', + 'restart.service.rest.context': 'Restart {1}s ({0})', + 'menu.item.dashboard':'Dashboard', 'menu.item.heatmaps':'Heatmaps', 'menu.item.services':'Services', http://git-wip-us.apache.org/repos/asf/ambari/blob/ab0c39c0/ambari-web/app/utils/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js index e690b67..9b98a3b 100644 --- a/ambari-web/app/utils/ajax.js +++ b/ambari-web/app/utils/ajax.js @@ -1293,7 +1293,7 @@ var urls = { batches.push({ "order_id" : count + 1, "type" : "POST", - "uri" : "/api/v1/clusters/" + data.clusterName + "/requests", + "uri" : App.apiPrefix + "/clusters/" + data.clusterName + "/requests", "RequestBodyInfo" : { "RequestInfo" : { "context" : Em.I18n.t('rollingrestart.rest.context').format(componentDisplayName, (count + 1), batchCount), @@ -1322,6 +1322,26 @@ var urls = { } ]) } } + }, + 'restart.service.hostComponents' : { + 'real' : '/clusters/{clusterName}/requests', + 'mock' : '', + 'format' : function(data) { + var componentDisplayName = App.format.role(data.componentName); + var serviceDisplayName = App.Service.DisplayNames[data.serviceName]; + return { + type : 'POST', + data : JSON.stringify({ + "RequestInfo" : { + "context" : Em.I18n.t('restart.service.rest.context').format(serviceDisplayName, componentDisplayName), + "command" : "RESTART", + "service_name" : data.serviceName, + "component_name" : data.componentName, + "hosts" : data.hosts + } + }) + } + } } }; /** http://git-wip-us.apache.org/repos/asf/ambari/blob/ab0c39c0/ambari-web/app/utils/batch_scheduled_requests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/batch_scheduled_requests.js b/ambari-web/app/utils/batch_scheduled_requests.js index 2f8ae78..e3bdb53 100644 --- a/ambari-web/app/utils/batch_scheduled_requests.js +++ b/ambari-web/app/utils/batch_scheduled_requests.js @@ -49,6 +49,49 @@ module.exports = { return rollingRestartComponent; }, + doPostRestartAllServiceComponents : function(serviceName) { + var allHostComponents = App.HostComponent.find(); + var componentToHostsMap = {}; + var componentCount = 0; + allHostComponents.forEach(function(hc) { + if (serviceName == hc.get('service.serviceName')) { + var componentName = hc.get('componentName'); + if (!componentToHostsMap[componentName]) { + componentToHostsMap[componentName] = []; + componentCount++; + } + componentToHostsMap[componentName].push(hc.get('host.hostName')); + } + }); + for ( var componentName in componentToHostsMap) { + var hosts = componentToHostsMap[componentName].join(","); + var data = { + serviceName : serviceName, + componentName : componentName, + hosts : hosts + } + var sender = { + successFunction : function() { + App.router.get('applicationController').dataLoading().done(function (initValue) { + if (initValue) { + App.router.get('backgroundOperationsController').showPopup(); + } + }); + }, + errorFunction : function(xhr, textStatus, error, opt) { + App.ajax.defaultErrorHandler(xhr, opt.url, 'POST', xhr.status); + } + } + App.ajax.send({ + name : 'restart.service.hostComponents', + sender : sender, + data : data, + success : 'successFunction', + error : 'errorFunction' + }); + } + }, + /** * Makes a REST call to the server requesting the rolling restart of the * provided host components. @@ -134,6 +177,11 @@ module.exports = { var tolerateSize = this.get('innerView.tolerateSize'); self.doPostBatchRollingRestartRequest(restartComponents, batchSize, waitTime, tolerateSize, function() { dialog.hide(); + App.router.get('applicationController').dataLoading().done(function (initValue) { + if (initValue) { + App.router.get('backgroundOperationsController').showPopup(); + } + }); }, function(xhr, textStatus, error, opt) { App.ajax.defaultErrorHandler(xhr, opt.url, 'POST', xhr.status); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/ab0c39c0/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 e67b303..d1792da 100644 --- a/ambari-web/app/views/main/service/item.js +++ b/ambari-web/app/views/main/service/item.js @@ -47,6 +47,8 @@ App.MainServiceItemView = Em.View.extend({ options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke').format(service.get('serviceName')), disabled:disabled}); } + options.push({action:'restartAllHostComponents', context: serviceName, 'label': Em.I18n.t('restart.service.all'), disabled: false}); + var rrComponentName = batchUtils.getRollingRestartComponentName(serviceName); if (rrComponentName) { var label = Em.I18n.t('rollingrestart.dialog.title').format(App.format.role(rrComponentName));
