AMBARI-17293 Ambari does not refresh yarn queues when HiveServerIntearctive component is restarted (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0545cb59 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0545cb59 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0545cb59 Branch: refs/heads/branch-2.4 Commit: 0545cb59772995e4b1c5fe8e1471c3f23b8ee157 Parents: 4ae7b12 Author: Aleksandr Kovalenko <akovale...@hortonworks.com> Authored: Fri Jun 17 16:11:25 2016 +0300 Committer: Aleksandr Kovalenko <akovale...@hortonworks.com> Committed: Fri Jun 17 20:15:47 2016 +0300 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 69 +++++++++++++++++++- .../test/controllers/main/host/details_test.js | 13 ++++ 2 files changed, 81 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0545cb59/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 1364adf..517adb2 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -68,6 +68,12 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow isOozieServerAddable: true, /** + * List of components to run refresh YARN queue with + * @type {Array} + */ + refreshYARNQueueComponents: ['HIVE_SERVER_INTERACTIVE'], + + /** * Open dashboard page * @method routeHome */ @@ -510,13 +516,18 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * @method restartComponent */ restartComponent: function (event) { + var self = this; var component = event.context; - if (event.context.get('componentName') == 'NAMENODE') { + if (component.get('componentName') == 'NAMENODE') { this.checkNnLastCheckpointTime(function () { return App.showConfirmationPopup(function () { batchUtils.restartHostComponents([component], Em.I18n.t('rollingrestart.context.selectedComponentOnSelectedHost').format(component.get('displayName')), "HOST_COMPONENT"); }); }); + } else if (this.get('refreshYARNQueueComponents').contains(component.get('componentName'))) { + return App.showConfirmationPopup(function () { + self.restartComponentAndRefreshYARNQueue(component); + }); } else { return App.showConfirmationPopup(function () { batchUtils.restartHostComponents([component], Em.I18n.t('rollingrestart.context.selectedComponentOnSelectedHost').format(component.get('displayName')), "HOST_COMPONENT"); @@ -524,6 +535,62 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow } }, + restartComponentAndRefreshYARNQueue: function (component) { + var componentToRestartHost = App.HostComponent.find().findProperty('componentName', component.get('componentName')).get('hostName'); + var resourceManagerHost = App.HostComponent.find().findProperty('componentName', 'RESOURCEMANAGER').get('hostName'); + var batches = [ + { + "order_id": 1, + "type": "POST", + "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + "/requests", + "RequestBodyInfo": { + "RequestInfo": { + "context": "Restart " + component.get('displayName'), + "command": "RESTART", + "operation_level": { + "level": "HOST_COMPONENT", + "cluster_name": App.get('clusterName'), + "service_name": component.get('service.serviceName'), + "hostcomponent_name": component.get('componentName') + } + }, + "Requests/resource_filters": [{ + "service_name": component.get('service.serviceName'), + "component_name": component.get('componentName'), + "hosts": componentToRestartHost + }] + } + }, + { + "order_id": 2, + "type": "POST", + "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + "/requests", + "RequestBodyInfo": { + "RequestInfo": { + "context": "Refresh YARN Capacity Scheduler", + "command": "REFRESHQUEUES", + "parameters/forceRefreshConfigTags": "capacity-scheduler" + }, + "Requests/resource_filters": [{ + "service_name": "YARN", + "component_name": "RESOURCEMANAGER", + "hosts": resourceManagerHost + }] + } + } + ]; + App.ajax.send({ + name: 'common.batch.request_schedules', + sender: this, + data: { + intervalTimeSeconds: 1, + tolerateSize: 0, + batches: batches + }, + success: 'showBackgroundOperationsPopup' + }); + }, + /** * add component as <code>addComponent<code> method but perform * kdc sessionstate if cluster is secure; http://git-wip-us.apache.org/repos/asf/ambari/blob/0545cb59/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 66bd454..971d0cd 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -472,11 +472,13 @@ describe('App.MainHostDetailsController', function () { sinon.spy(App, "showConfirmationPopup"); sinon.stub(batchUtils, "restartHostComponents", Em.K); sinon.stub(controller, 'checkNnLastCheckpointTime', Em.clb); + sinon.stub(controller, "restartComponentAndRefreshYARNQueue", Em.K); }); afterEach(function () { App.showConfirmationPopup.restore(); batchUtils.restartHostComponents.restore(); controller.checkNnLastCheckpointTime.restore(); + controller.restartComponentAndRefreshYARNQueue.restore(); }); it('popup should be displayed', function () { @@ -497,6 +499,17 @@ describe('App.MainHostDetailsController', function () { expect(controller.checkNnLastCheckpointTime.calledOnce).to.equal(true); expect(App.showConfirmationPopup.calledOnce).to.be.true; }); + + it('restart HIVE_SERVER_INTERACTIVE, should call restartComponentAndRefreshYARNQueuet', function () { + var event = { + context: Em.Object.create({ + componentName: 'HIVE_SERVER_INTERACTIVE' + }) + }; + var confirmPopup = controller.restartComponent(event); + confirmPopup.onPrimary(); + expect(controller.restartComponentAndRefreshYARNQueue.calledOnce).to.be.true; + }); }); describe('#addComponent()', function () {