Repository: ambari Updated Branches: refs/heads/trunk 917807d0e -> 63f263f4d
AMBARI-5088 Maintenance Mode fixes. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/63f263f4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/63f263f4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/63f263f4 Branch: refs/heads/trunk Commit: 63f263f4d59c0cc9abf60dc6bb9ac894ed9be9c6 Parents: 917807d Author: aBabiichuk <[email protected]> Authored: Fri Mar 14 18:17:18 2014 +0200 Committer: aBabiichuk <[email protected]> Committed: Fri Mar 14 18:23:23 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 73 ++++++++------------ .../app/utils/batch_scheduled_requests.js | 2 +- .../app/views/common/rolling_restart_view.js | 7 +- 3 files changed, 35 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/63f263f4/ambari-web/app/controllers/main/host/details.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js index 69bc329..1947007 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -44,6 +44,10 @@ App.MainHostDetailsController = Em.Controller.extend({ App.router.transitionTo('main.services.service.summary',service); }, + serviceActiveComponents: function() { + return this.get('content.hostComponents').filterProperty('service.passiveState','OFF') + }.property('content.hostComponents'), + /** * Send specific command to server * @param url @@ -102,10 +106,10 @@ App.MainHostDetailsController = Em.Controller.extend({ * @param component When <code>null</code> all startable components are started. * @param context Context under which this command is beign sent. */ - sendStartComponentCommand: function(component, context) { - var url = component !== null ? - '/hosts/' + this.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase() : - '/hosts/' + this.get('content.hostName') + '/host_components?HostRoles/maintenance_state=OFF'; + sendStartComponentCommand: function(components, context) { + var url = Em.isArray(components) ? + '/hosts/' + this.get('content.hostName') + '/host_components' : + '/hosts/' + this.get('content.hostName') + '/host_components/' + components.get('componentName').toUpperCase(); var dataToSend = { RequestInfo : { "context" : context @@ -116,17 +120,8 @@ App.MainHostDetailsController = Em.Controller.extend({ } } }; - if (component === null) { - var allComponents = this.get('content.hostComponents'); - var startable = []; - allComponents.forEach(function (c) { - if (c.get('passiveState') == 'OFF') { - if (c.get('isMaster') || c.get('isSlave')) { - startable.push(c.get('componentName')); - } - } - }); - dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + startable.join(',') + ")"; + if (Em.isArray(components)) { + dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + components.mapProperty('componentName').join(',') + ")"; } this.sendCommandToServer(url, dataToSend, 'PUT', function(requestId){ @@ -138,7 +133,7 @@ App.MainHostDetailsController = Em.Controller.extend({ console.log('Send request for STARTING successfully'); if (App.testMode) { - if(component === null){ + if(Em.isArray(components)){ var allComponents = this.get('content.hostComponents'); allComponents.forEach(function(component){ component.set('workStatus', App.HostComponentStatus.stopping); @@ -147,9 +142,9 @@ App.MainHostDetailsController = Em.Controller.extend({ },App.testModeDelayForActions); }); } else { - component.set('workStatus', App.HostComponentStatus.starting); + components.set('workStatus', App.HostComponentStatus.starting); setTimeout(function(){ - component.set('workStatus', App.HostComponentStatus.started); + components.set('workStatus', App.HostComponentStatus.started); },App.testModeDelayForActions); } } else { @@ -315,10 +310,10 @@ App.MainHostDetailsController = Em.Controller.extend({ * @param component When <code>null</code> all components are stopped. * @param context Context under which this command is beign sent. */ - sendStopComponentCommand: function(component, context){ - var url = component !== null ? - '/hosts/' + this.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase() : - '/hosts/' + this.get('content.hostName') + '/host_components?HostRoles/maintenance_state=OFF'; + sendStopComponentCommand: function(components, context){ + var url = Em.isArray(components) ? + '/hosts/' + this.get('content.hostName') + '/host_components' : + '/hosts/' + this.get('content.hostName') + '/host_components/' + components.get('componentName').toUpperCase(); var dataToSend = { RequestInfo : { "context" : context @@ -329,17 +324,8 @@ App.MainHostDetailsController = Em.Controller.extend({ } } }; - if (component === null) { - var allComponents = this.get('content.hostComponents'); - var startable = []; - allComponents.forEach(function (c) { - if (c.get('passiveState') == 'OFF') { - if (c.get('isMaster') || c.get('isSlave')) { - startable.push(c.get('componentName')); - } - } - }); - dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + startable.join(',') + ")"; + if (Em.isArray(components)) { + dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + components.mapProperty('componentName').join(',') + ")"; } this.sendCommandToServer( url, dataToSend, 'PUT', function(requestId){ @@ -350,18 +336,17 @@ App.MainHostDetailsController = Em.Controller.extend({ console.log('Send request for STOPPING successfully'); if (App.testMode) { - if(component === null){ - var allComponents = this.get('content.hostComponents'); - allComponents.forEach(function(component){ + if(Em.isArray(components)){ + components.forEach(function(component){ component.set('workStatus', App.HostComponentStatus.stopping); setTimeout(function(){ component.set('workStatus', App.HostComponentStatus.stopped); },App.testModeDelayForActions); }); } else { - component.set('workStatus', App.HostComponentStatus.stopping); + components.set('workStatus', App.HostComponentStatus.stopping); setTimeout(function(){ - component.set('workStatus', App.HostComponentStatus.stopped); + components.set('workStatus', App.HostComponentStatus.stopped); },App.testModeDelayForActions); } @@ -1021,31 +1006,29 @@ App.MainHostDetailsController = Em.Controller.extend({ doStartAllComponents: function() { var self = this; - var components = this.get('content.hostComponents'); + var components = this.get('serviceActiveComponents'); var componentsLength = components == null ? 0 : components.get('length'); if (componentsLength > 0) { App.showConfirmationPopup(function() { - self.sendStartComponentCommand(null, - Em.I18n.t('hosts.host.maintainance.startAllComponents.context')); + self.sendStartComponentCommand(components, Em.I18n.t('hosts.host.maintainance.startAllComponents.context')); }); } }, doStopAllComponents: function() { var self = this; - var components = this.get('content.hostComponents'); + var components = this.get('serviceActiveComponents'); var componentsLength = components == null ? 0 : components.get('length'); if (componentsLength > 0) { App.showConfirmationPopup(function() { - self.sendStopComponentCommand(null, - Em.I18n.t('hosts.host.maintainance.stopAllComponents.context')); + self.sendStopComponentCommand(components, Em.I18n.t('hosts.host.maintainance.stopAllComponents.context')); }); } }, doRestartAllComponents: function() { var self = this; - var components = this.get('content.hostComponents').filterProperty('passiveState','OFF'); + var components = this.get('serviceActiveComponents'); var componentsLength = components == null ? 0 : components.get('length'); if (componentsLength > 0) { App.showConfirmationPopup(function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/63f263f4/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 f32a2dc..62e538c 100644 --- a/ambari-web/app/utils/batch_scheduled_requests.js +++ b/ambari-web/app/utils/batch_scheduled_requests.js @@ -73,7 +73,7 @@ module.exports = { var service = App.Service.find(serviceName); var context = staleConfigsOnly ? Em.I18n.t('rollingrestart.context.allWithStaleConfigsForSelectedService').format(serviceName) : Em.I18n.t('rollingrestart.context.allForSelectedService').format(serviceName); if (service) { - var hostComponents = service.get('hostComponents'); + var hostComponents = service.get('hostComponents').filterProperty('host.passiveState','OFF'); if (staleConfigsOnly) { hostComponents = hostComponents.filterProperty('staleConfigs', true); } http://git-wip-us.apache.org/repos/asf/ambari/blob/63f263f4/ambari-web/app/views/common/rolling_restart_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/rolling_restart_view.js b/ambari-web/app/views/common/rolling_restart_view.js index 658ece3..c9239c4 100644 --- a/ambari-web/app/views/common/rolling_restart_view.js +++ b/ambari-web/app/views/common/rolling_restart_view.js @@ -146,7 +146,12 @@ App.RollingRestartView = Em.View.extend({ * @type {Array} */ restartHostComponents : function() { - var hostComponents = this.get('skipMaintenance') ? this.get('allHostComponents') : this.get('nonMaintainanceHostComponents'); + var hostComponents = null; + if (this.get('skipMaintenance')) { + hostComponents = this.get('allHostComponents').filterProperty('host.passiveState','OFF'); + } else { + hostComponents = this.get('nonMaintainanceHostComponents'); + } if (this.get('staleConfigsOnly')) { hostComponents = hostComponents.filterProperty('staleConfigs', true); }
