Repository: ambari Updated Branches: refs/heads/trunk 73be90ac0 -> 41bcd351e
AMBARI-5392 Recommend putting Region Server in Maintenance Mode when Decommissioning Region Server. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/41bcd351 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/41bcd351 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/41bcd351 Branch: refs/heads/trunk Commit: 41bcd351ed83766f4b404a10bc8d6bb985d18b8b Parents: 73be90a Author: aBabiichuk <ababiic...@cybervisiontech.com> Authored: Mon Jul 28 20:16:44 2014 +0300 Committer: aBabiichuk <ababiic...@cybervisiontech.com> Committed: Mon Jul 28 20:16:44 2014 +0300 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host.js | 35 +++++++++++++++- ambari-web/app/controllers/main/host/details.js | 44 +++++++++++++++++--- ambari-web/app/utils/ajax/ajax.js | 4 ++ .../test/controllers/main/host/details_test.js | 3 -- 4 files changed, 76 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/41bcd351/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 cc9b26c..6b9210a 100644 --- a/ambari-web/app/controllers/main/host.js +++ b/ambari-web/app/controllers/main/host.js @@ -844,7 +844,7 @@ App.MainHostController = Em.ArrayController.extend({ //For decommession if (svcName == "HBASE") { // HBASE service, decommission RegionServer in batch requests - App.router.get('mainHostDetailsController').doDecommissionRegionServer(hostNames, svcName, masterName, slaveName); + this.warnBeforeDecommission(hostNames); } else { var parameters = { "slave_type": slaveName @@ -880,6 +880,39 @@ App.MainHostController = Em.ArrayController.extend({ } }, + + /** + * get info about regionserver passive_state + * @method warnBeforeDecommission + * @param {String} hostNames + * @return {$.ajax} + */ + warnBeforeDecommission: function (hostNames) { + return App.ajax.send({ + 'name': 'host_components.hbase_regionserver.active', + 'sender': this, + 'data': { + hostNames: hostNames + }, + success: 'warnBeforeDecommissionSuccess' + }); + }, + + /** + * check is hbase regionserver in mm. If so - run decommission + * otherwise shows warning + * @method warnBeforeDecommission + * @param {Object} data + * @param {Object} opt + * @param {Object} params + */ + warnBeforeDecommissionSuccess: function(data, opt, params) { + if (Em.get(data, 'items.length')) { + App.router.get('mainHostDetailsController').showHbaseActiveWarning(); + } else { + App.router.get('mainHostDetailsController').doDecommissionRegionServer(params.hostNames, "HBASE", "HBASE_MASTER", "HBASE_REGIONSERVER"); + } + }, /** * Bulk restart for selected hostComponents * @param {Object} operationData http://git-wip-us.apache.org/repos/asf/ambari/blob/41bcd351/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 cc13471..cab9cb1 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -858,9 +858,8 @@ App.MainHostDetailsController = Em.Controller.extend({ this.doDecommission(hostName, svcName, "JOBTRACKER", "TASKTRACKER"); break; case 'HBASE': - this.doDecommissionRegionServer(hostName, svcName, "HBASE_MASTER", "HBASE_REGIONSERVER"); + this.warnBeforeDecommission(hostName); } - this.showBackgroundOperationsPopup(); }, /** @@ -925,9 +924,42 @@ App.MainHostDetailsController = Em.Controller.extend({ }, /** + * check is hbase regionserver in mm. If so - run decommission + * otherwise shows warning + * @method warnBeforeDecommission + * @param {string} hostNames - list of host when run from bulk operations or current host + */ + + warnBeforeDecommission: function(hostNames) { + if (this.get('content.hostComponents').findProperty('componentName', 'HBASE_REGIONSERVER').get('passiveState') == "OFF") { + this.showHbaseActiveWarning(); + } else { + this.doDecommissionRegionServer(hostNames, "HBASE", "HBASE_MASTER", "HBASE_REGIONSERVER"); + } + }, + + /** + * shows warning: put hbase regionserver in passive state + * @method showHbaseActiveWarning + * @return {App.ModalPopup} + */ + showHbaseActiveWarning: function() { + return App.ModalPopup.show({ + header: Em.I18n.t('common.warning'), + message: function(){ + return Em.I18n.t('hostPopup.reccomendation.beforeDecommission').format(App.format.components["HBASE_REGIONSERVER"]); + }.property(), + bodyClass: Ember.View.extend({ + template: Em.Handlebars.compile('<div class="alert alert-warning">{{message}}</div>') + }), + secondary: false + }); + }, + + /** * Performs Decommission (for RegionServer) * @method doDecommissionRegionServer - * @param {string[]} hostNames - list of host when run from bulk operations or current host + * @param {string} hostNames - list of host when run from bulk operations or current host * @param {string} serviceName - serviceName * @param {string} componentName - master compoent name * @param {string} slaveType - slave component name @@ -943,7 +975,7 @@ App.MainHostDetailsController = Em.Controller.extend({ { "order_id": 1, "type": "POST", - "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + "/requests", + "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/requests", "RequestBodyInfo": { "RequestInfo": { "context": Em.I18n.t('hosts.host.regionserver.decommission.batch1'), @@ -967,7 +999,7 @@ App.MainHostDetailsController = Em.Controller.extend({ { "order_id": 2, "type": "PUT", - "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + "/host_components", + "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/host_components", "RequestBodyInfo": { "RequestInfo": { context: Em.I18n.t('hosts.host.regionserver.decommission.batch2'), @@ -983,7 +1015,7 @@ App.MainHostDetailsController = Em.Controller.extend({ { "order_id": 3, "type": "POST", - "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + "/requests", + "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/requests", "RequestBodyInfo": { "RequestInfo": { "context": Em.I18n.t('hosts.host.regionserver.decommission.batch3'), http://git-wip-us.apache.org/repos/asf/ambari/blob/41bcd351/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 fe1ebdd..bc969bd 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -405,6 +405,10 @@ var urls = { 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}/?fields=ServiceComponentInfo,host_components/HostRoles/state', 'mock': '' }, + 'host_components.hbase_regionserver.active': { + 'real': '/clusters/{clusterName}/host_components?HostRoles/component_name=HBASE_REGIONSERVER&HostRoles/maintenance_state=OFF&HostRoles/desired_admin_state=INSERVICE&HostRoles/host_name.in({hostNames})', + 'mock': '' + }, 'host.host_component.decommission_status_datanode': { 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?fields=metrics/dfs/namenode', 'mock': '' http://git-wip-us.apache.org/repos/asf/ambari/blob/41bcd351/ambari-web/test/controllers/main/host/details_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js index 4fd01c8..189e483 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -721,17 +721,14 @@ describe('App.MainHostDetailsController', function () { it('HDFS service', function () { controller.runDecommission('host1', 'HDFS'); expect(controller.doDecommission.calledWith('host1', 'HDFS', "NAMENODE", "DATANODE")).to.be.true; - expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true; }); it('YARN service', function () { controller.runDecommission('host1', 'YARN'); expect(controller.doDecommission.calledWith('host1', 'YARN', "RESOURCEMANAGER", "NODEMANAGER")).to.be.true; - expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true; }); it('MAPREDUCE service', function () { controller.runDecommission('host1', 'MAPREDUCE'); expect(controller.doDecommission.calledWith('host1', 'MAPREDUCE', "JOBTRACKER", "TASKTRACKER")).to.be.true; - expect(controller.showBackgroundOperationsPopup.calledOnce).to.be.true; }); });