Updated Branches: refs/heads/trunk b7e9dd9fb -> 46608926e
AMBARI-4489 Set some ui restriction for components/services/hosts in passive mode. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/46608926 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/46608926 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/46608926 Branch: refs/heads/trunk Commit: 46608926ec0cdd184cc2c715821995e891380710 Parents: b7e9dd9 Author: aBabiichuk <[email protected]> Authored: Fri Jan 31 19:09:00 2014 +0200 Committer: aBabiichuk <[email protected]> Committed: Fri Jan 31 19:09:00 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host.js | 16 ++++++----- ambari-web/app/controllers/main/host/details.js | 23 ++++++++------- ambari-web/app/messages.js | 2 +- ambari-web/app/templates/main/host/summary.hbs | 30 +++++++++++--------- ambari-web/app/utils/ajax.js | 2 +- .../app/utils/batch_scheduled_requests.js | 24 ++++++---------- ambari-web/app/views/main/host/summary.js | 7 +++-- ambari-web/test/controllers/main/host_test.js | 14 ++++----- 8 files changed, 61 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/46608926/ambari-web/app/controllers/main/host.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js index 067071a..050cfbc 100644 --- a/ambari-web/app/controllers/main/host.js +++ b/ambari-web/app/controllers/main/host.js @@ -187,9 +187,11 @@ App.MainHostController = Em.ArrayController.extend({ var subQuery = '(HostRoles/component_name.in(%@)&HostRoles/host_name=' + host.get('hostName') + ')'; var components = []; host.get('hostComponents').forEach(function(hostComponent) { - if (hostComponent.get('isMaster') || hostComponent.get('isSlave')) { - if (hostComponent.get('workStatus') === operationData.actionToCheck) { - components.push(hostComponent.get('componentName')); + if (hostComponent.get('passiveState') == 'ACTIVE') { + if (hostComponent.get('isMaster') || hostComponent.get('isSlave')) { + if (hostComponent.get('workStatus') === operationData.actionToCheck) { + components.push(hostComponent.get('componentName')); + } } } }); @@ -227,7 +229,7 @@ App.MainHostController = Em.ArrayController.extend({ bulkOperationForHostsRestart: function(operationData, hosts) { var hostComponents = []; hosts.forEach(function(host) { - hostComponents.pushObjects(host.get('hostComponents').toArray()); + hostComponents.pushObjects(host.get('hostComponents').filterProperty('passiveState','ACTIVE').toArray()); }); batchUtils.restartHostComponents(hostComponents); }, @@ -272,7 +274,7 @@ App.MainHostController = Em.ArrayController.extend({ bulkOperationForHostComponents: function(operationData, hosts) { var service = App.Service.find(operationData.serviceName); var components = service.get('hostComponents').filter(function(hc) { - if (hc.get('componentName') != operationData.componentName) { + if (hc.get('componentName') != operationData.componentName || hc.get('passiveState') != 'ACTIVE' ) { return false; } if(hc.get('workStatus') == operationData.action) { @@ -312,7 +314,7 @@ App.MainHostController = Em.ArrayController.extend({ bulkOperationForHostComponentsDecommission: function(operationData, hosts) { var service = App.Service.find(operationData.serviceName); var components = service.get('hostComponents').filter(function(hc) { - if (hc.get('componentName') != operationData.realComponentName) { + if (hc.get('componentName') != operationData.realComponentName || hc.get('passiveState') != 'ACTIVE' ) { return false; } return hosts.contains(hc.get('host')); @@ -361,7 +363,7 @@ App.MainHostController = Em.ArrayController.extend({ bulkOperationForHostComponentsRestart: function(operationData, hosts) { var service = App.Service.find(operationData.serviceName); var components = service.get('hostComponents').filter(function(hc) { - if (hc.get('componentName') != operationData.componentName) { + if (hc.get('componentName') != operationData.componentName || hc.get('passiveState') != 'ACTIVE') { return false; } return hosts.contains(hc.get('host')); http://git-wip-us.apache.org/repos/asf/ambari/blob/46608926/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 6358e65..7ac6522 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -103,9 +103,9 @@ App.MainHostDetailsController = Em.Controller.extend({ * @param context Context under which this command is beign sent. */ sendStartComponentCommand: function(component, context) { - var url = component !== null ? + var url = component !== null ? '/hosts/' + this.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase() : - '/hosts/' + this.get('content.hostName') + '/host_components'; + '/hosts/' + this.get('content.hostName') + '/host_components?HostRoles/passive_state=ACTIVE'; var dataToSend = { RequestInfo : { "context" : context @@ -120,8 +120,10 @@ App.MainHostDetailsController = Em.Controller.extend({ var allComponents = this.get('content.hostComponents'); var startable = []; allComponents.forEach(function (c) { - if (c.get('isMaster') || c.get('isSlave')) { - startable.push(c.get('componentName')); + if (c.get('passiveState') == 'ACTIVE') { + if (c.get('isMaster') || c.get('isSlave')) { + startable.push(c.get('componentName')); + } } }); dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + startable.join(',') + ")"; @@ -300,9 +302,9 @@ App.MainHostDetailsController = Em.Controller.extend({ * @param context Context under which this command is beign sent. */ sendStopComponentCommand: function(component, context){ - var url = component !== null ? + var url = component !== null ? '/hosts/' + this.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase() : - '/hosts/' + this.get('content.hostName') + '/host_components'; + '/hosts/' + this.get('content.hostName') + '/host_components?HostRoles/passive_state=ACTIVE'; var dataToSend = { RequestInfo : { "context" : context @@ -317,8 +319,10 @@ App.MainHostDetailsController = Em.Controller.extend({ var allComponents = this.get('content.hostComponents'); var startable = []; allComponents.forEach(function (c) { - if (c.get('isMaster') || c.get('isSlave')) { - startable.push(c.get('componentName')); + if (c.get('passiveState') == 'ACTIVE') { + if (c.get('isMaster') || c.get('isSlave')) { + startable.push(c.get('componentName')); + } } }); dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + startable.join(',') + ")"; @@ -994,8 +998,7 @@ App.MainHostDetailsController = Em.Controller.extend({ }, doRestartAllComponents: function() { - var self = this; - var components = this.get('content.hostComponents'); + var components = this.get('content.hostComponents').filterProperty('passiveState','ACTIVE'); var componentsLength = components == null ? 0 : components.get('length'); if (componentsLength > 0) { App.showConfirmationPopup(function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/46608926/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 326c51f..468a3b1 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1816,7 +1816,7 @@ Em.I18n.translations = { 'rolling.command.context': 'Rolling set {0} to state "{1}" - batch {2} of {3}', 'rolling.nothingToDo.header': 'Nothing to do', - 'rolling.nothingToDo.body': '{0} on selected hosts are already in selected state.', + 'rolling.nothingToDo.body': '{0} on selected hosts are already in selected state or in passive mode.', 'restart.service.all': 'Restart All', 'restart.service.rest.context': 'Restart {1}s ({0})', http://git-wip-us.apache.org/repos/asf/ambari/blob/46608926/ambari-web/app/templates/main/host/summary.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs index ffd4c9f..ebdd90b 100644 --- a/ambari-web/app/templates/main/host/summary.hbs +++ b/ambari-web/app/templates/main/host/summary.hbs @@ -193,21 +193,23 @@ </a> </li> {{/if}} - {{#if view.isPassive}} - <li {{bindAttr class="view.noActionAvailable"}}> - <a href="javascript:void(null)" - data-toggle="modal" {{action "turnOnOffPassiveConfirmation" view.content target="controller"}}> - {{t passiveState.turnOff}} - </a> - </li> + {{#unless view.isImplied}} + {{#if view.isActive}} + <li {{bindAttr class="view.noActionAvailable"}}> + <a href="javascript:void(null)" + data-toggle="modal" {{action "turnOnOffPassiveConfirmation" view.content target="controller"}}> + {{t passiveState.turnOn}} + </a> + </li> {{else}} - <li {{bindAttr class="view.noActionAvailable"}}> - <a href="javascript:void(null)" - data-toggle="modal" {{action "turnOnOffPassiveConfirmation" view.content target="controller"}}> - {{t passiveState.turnOn}} - </a> - </li> - {{/if}} + <li {{bindAttr class="view.noActionAvailable"}}> + <a href="javascript:void(null)" + data-toggle="modal" {{action "turnOnOffPassiveConfirmation" view.content target="controller"}}> + {{t passiveState.turnOff}} + </a> + </li> + {{/if}} + {{/unless}} {{/unless}} </ul> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/46608926/ambari-web/app/utils/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js index 8f2a99e..6188371 100644 --- a/ambari-web/app/utils/ajax.js +++ b/ambari-web/app/utils/ajax.js @@ -1467,7 +1467,7 @@ var urls = { data: JSON.stringify({ RequestInfo: { context: data.requestInfo, - query: 'HostRoles/component_name=' + data.componentName + '&HostRoles/host_name.in(' + data.hostNames + ')' + query: 'HostRoles/component_name=' + data.componentName + '&HostRoles/host_name.in(' + data.hostNames + ')&HostRoles/passive_state=ACTIVE' }, Body: { HostRoles: { http://git-wip-us.apache.org/repos/asf/ambari/blob/46608926/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 33dad38..088c83c 100644 --- a/ambari-web/app/utils/batch_scheduled_requests.js +++ b/ambari-web/app/utils/batch_scheduled_requests.js @@ -70,7 +70,7 @@ module.exports = { restartAllServiceHostComponents: function(serviceName, staleConfigsOnly) { var service = App.Service.find(serviceName); if (service) { - var hostComponents = service.get('hostComponents'); + var hostComponents = service.get('hostComponents').filterProperty('passiveState','ACTIVE'); if (staleConfigsOnly) { hostComponents = hostComponents.filterProperty('staleConfigs', true); } @@ -263,13 +263,10 @@ module.exports = { * Retrieves the latest information about a specific request schedule * identified by 'requestScheduleId' * - * @param {Number} - * requestScheduleId ID of the request schedule to get - * @param {Function} - * successCallback Called with request_schedule data from server. An + * @param {Number} requestScheduleId ID of the request schedule to get + * @param {Function} successCallback Called with request_schedule data from server. An * empty object returned for invalid ID. - * @param {Function} - * errorCallback Optional error callback. Default behavior is to + * @param {Function} errorCallback Optional error callback. Default behavior is to * popup default error dialog. */ getRequestSchedule: function(requestScheduleId, successCallback, errorCallback) { @@ -286,7 +283,7 @@ module.exports = { } }, data : { - request_schedule_id : requestScheduleId, + request_schedule_id : requestScheduleId }, success : 'successCallbackFunction', error : 'errorCallbackFunction' @@ -299,12 +296,9 @@ module.exports = { /** * Attempts to abort a specific request schedule identified by 'requestScheduleId' * - * @param {Number} - * requestScheduleId ID of the request schedule to get - * @param {Function} - * successCallback Called when request schedule successfully aborted - * @param {Function} - * errorCallback Optional error callback. Default behavior is to + * @param {Number} requestScheduleId ID of the request schedule to get + * @param {Function} successCallback Called when request schedule successfully aborted + * @param {Function} errorCallback Optional error callback. Default behavior is to * popup default error dialog. */ doAbortRequestSchedule: function(requestScheduleId, successCallback, errorCallback) { @@ -321,7 +315,7 @@ module.exports = { } }, data : { - request_schedule_id : requestScheduleId, + request_schedule_id : requestScheduleId }, success : 'successCallbackFunction', error : 'errorCallbackFunction' http://git-wip-us.apache.org/repos/asf/ambari/blob/46608926/ambari-web/app/views/main/host/summary.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js index e3befcc..9172fb8 100644 --- a/ambari-web/app/views/main/host/summary.js +++ b/ambari-web/app/views/main/host/summary.js @@ -428,10 +428,13 @@ App.MainHostSummaryView = Em.View.extend({ return this.get('content.componentName') === 'HBASE_REGIONSERVER'; }.property('content'), - isPassive: function () { - return (this.get('content.passiveState') == "PASSIVE"); + isActive: function () { + return (this.get('content.passiveState') == "ACTIVE"); }.property('content.passiveState'), + isImplied: function() { + return (this.get('content.passiveState') == "IMPLIED"); + }.property('content.passiveState'), isDecommissioning: function () { return (this.get('isDataNode') && this.get("isDataNodeDecommissioning")) || (this.get('isRegionServer') && this.get("isRegionServerDecommissioning")); http://git-wip-us.apache.org/repos/asf/ambari/blob/46608926/ambari-web/test/controllers/main/host_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host_test.js b/ambari-web/test/controllers/main/host_test.js index a60a605..15004ca 100644 --- a/ambari-web/test/controllers/main/host_test.js +++ b/ambari-web/test/controllers/main/host_test.js @@ -171,8 +171,8 @@ describe('MainHostController', function () { hosts: [ Em.Object.create({ hostComponents: Em.A([ - Em.Object.create({isMaster: true, isSlave: false, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'NAMENODE'}), - Em.Object.create({isMaster: false, isSlave: true, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'DATANODE'}) + Em.Object.create({isMaster: true, isSlave: false, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'NAMENODE', passiveState: 'ACTIVE'}), + Em.Object.create({isMaster: false, isSlave: true, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'DATANODE', passiveState: 'ACTIVE'}) ]) }) ], @@ -186,8 +186,8 @@ describe('MainHostController', function () { hosts: [ Em.Object.create({ hostComponents: Em.A([ - Em.Object.create({isMaster: true, isSlave: false, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'NAMENODE'}), - Em.Object.create({isMaster: false, isSlave: true, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'DATANODE'}) + Em.Object.create({isMaster: true, isSlave: false, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'NAMENODE', passiveState: 'ACTIVE'}), + Em.Object.create({isMaster: false, isSlave: true, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'DATANODE', passiveState: 'ACTIVE'}) ]) }) ], @@ -201,8 +201,8 @@ describe('MainHostController', function () { hosts: [ Em.Object.create({ hostComponents: Em.A([ - Em.Object.create({isMaster: true, isSlave: false, host: {hostName:'host1'}, workStatus: 'INSTALLED', componentName: 'NAMENODE'}), - Em.Object.create({isMaster: false, isSlave: true, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'DATANODE'}) + Em.Object.create({isMaster: true, isSlave: false, host: {hostName:'host1'}, workStatus: 'INSTALLED', componentName: 'NAMENODE', passiveState: 'ACTIVE'}), + Em.Object.create({isMaster: false, isSlave: true, host: {hostName:'host1'}, workStatus: 'STARTED', componentName: 'DATANODE', passiveState: 'ACTIVE'}) ]) }) ], @@ -240,7 +240,7 @@ describe('MainHostController', function () { { hosts: Em.A([ Em.Object.create({ - hostComponents: Em.A([Em.Object.create({}), Em.Object.create({})]) + hostComponents: Em.A([Em.Object.create({passiveState: 'ACTIVE'}), Em.Object.create({passiveState: 'ACTIVE'})]) }) ]), m: 'One host',
