Repository: ambari Updated Branches: refs/heads/branch-2.4 fd9210343 -> 23486664f
AMBARI-17293 Ambari does not refresh yarn queues when HiveServerIntearctive component is restarted. Third patch. (akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/23486664 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/23486664 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/23486664 Branch: refs/heads/branch-2.4 Commit: 23486664fcbd6b6a107a04050f671550f95c4c89 Parents: fd92103 Author: Aleksandr Kovalenko <[email protected]> Authored: Mon Jul 11 21:57:05 2016 +0300 Committer: Aleksandr Kovalenko <[email protected]> Committed: Tue Jul 12 13:53:23 2016 +0300 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host/details.js | 69 +-------------- ambari-web/app/controllers/main/service.js | 65 +++++++++++++-- ambari-web/app/utils/ajax/ajax.js | 15 +--- .../app/utils/batch_scheduled_requests.js | 88 ++++++++++++++++---- .../test/controllers/main/host/details_test.js | 13 --- .../test/controllers/main/service_test.js | 23 +++++ .../test/utils/batch_scheduled_requests_test.js | 23 +++++ 7 files changed, 182 insertions(+), 114 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/23486664/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 74255b9..1364adf 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -68,12 +68,6 @@ 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 */ @@ -516,18 +510,13 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow * @method restartComponent */ restartComponent: function (event) { - var self = this; var component = event.context; - if (component.get('componentName') == 'NAMENODE') { + if (event.context.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.refreshYARNQueueAndRestartComponent(component); - }); } else { return App.showConfirmationPopup(function () { batchUtils.restartHostComponents([component], Em.I18n.t('rollingrestart.context.selectedComponentOnSelectedHost').format(component.get('displayName')), "HOST_COMPONENT"); @@ -535,62 +524,6 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow } }, - refreshYARNQueueAndRestartComponent: 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": "Refresh YARN Capacity Scheduler", - "command": "REFRESHQUEUES", - "parameters/forceRefreshConfigTags": "capacity-scheduler" - }, - "Requests/resource_filters": [{ - "service_name": "YARN", - "component_name": "RESOURCEMANAGER", - "hosts": resourceManagerHost - }] - } - }, - { - "order_id": 2, - "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 - }] - } - } - ]; - 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/23486664/ambari-web/app/controllers/main/service.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service.js b/ambari-web/app/controllers/main/service.js index 44b8b21..7d9b737 100644 --- a/ambari-web/app/controllers/main/service.js +++ b/ambari-web/app/controllers/main/service.js @@ -319,11 +319,66 @@ App.MainServiceController = Em.ArrayController.extend({ * @returns {$.ajax} */ restartHostComponents: function () { - App.ajax.send({ - name: 'restart.staleConfigs', - sender: this, - success: 'restartAllRequiredSuccessCallback' - }); + var batches, hiveInteractive = App.HostComponent.find().findProperty('componentName', 'HIVE_SERVER_INTERACTIVE'); + var isYARNQueueRefreshRequired = hiveInteractive && hiveInteractive.get('staleConfigs'); + var ajaxData = { + "RequestInfo": { + "command": "RESTART", + "context": "Restart all required services", + "operation_level": "host_component" + }, + "Requests/resource_filters": [ + { + "hosts_predicate": "HostRoles/stale_configs=true" + } + ] + }; + + if (isYARNQueueRefreshRequired) { + batches = [ + { + "order_id": 1, + "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": App.HostComponent.find().findProperty('componentName', 'RESOURCEMANAGER').get('hostName') + }] + } + }, + { + "order_id": 2, + "type": "POST", + "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + "/requests", + "RequestBodyInfo": ajaxData + } + ]; + + App.ajax.send({ + name: 'common.batch.request_schedules', + sender: this, + data: { + intervalTimeSeconds: 1, + tolerateSize: 0, + batches: batches + }, + success: 'restartAllRequiredSuccessCallback' + }); + } else { + App.ajax.send({ + name: 'request.post', + sender: this, + data: ajaxData, + success: 'restartAllRequiredSuccessCallback' + }); + } }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/23486664/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 edd89ad..677c609 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -2299,24 +2299,13 @@ var urls = { } }, - 'restart.staleConfigs': { + 'request.post': { 'real': "/clusters/{clusterName}/requests", 'mock': "", 'format': function () { return { type: 'POST', - data: JSON.stringify({ - "RequestInfo": { - "command": "RESTART", - "context": "Restart all required services", - "operation_level": "host_component" - }, - "Requests/resource_filters": [ - { - "hosts_predicate": "HostRoles/stale_configs=true" - } - ] - }) + data: JSON.stringify(data.data) } } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/23486664/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 b8ae955..c9828a4 100644 --- a/ambari-web/app/utils/batch_scheduled_requests.js +++ b/ambari-web/app/utils/batch_scheduled_requests.js @@ -203,9 +203,16 @@ module.exports = { */ var componentToHostsMap = {}; var hosts = []; + var batches, refreshYARNQueues = false; + hostComponentsList.forEach(function(hc) { var hostName = hc.get('hostName'); var componentName = hc.get('componentName'); + + if (componentName === 'HIVE_SERVER_INTERACTIVE') { + refreshYARNQueues = true; + } + if (!componentToHostsMap[componentName]) { componentToHostsMap[componentName] = []; } @@ -231,21 +238,72 @@ module.exports = { if (resource_filters.length) { - App.ajax.send({ - name: 'restart.hostComponents', - sender: { - successCallback: defaultSuccessCallback, - errorCallback: defaultErrorCallback - }, - data: { - context: context, - resource_filters: resource_filters, - query: query, - operation_level: operation_level - }, - success: 'successCallback', - error: 'errorCallback' - }); + if (refreshYARNQueues) { + batches = [ + { + "order_id": 1, + "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": App.HostComponent.find().findProperty('componentName', 'RESOURCEMANAGER').get('hostName') + }] + } + }, + { + "order_id": 2, + "type": "POST", + "uri": App.apiPrefix + "/clusters/" + App.get('clusterName') + "/requests", + "RequestBodyInfo": { + "RequestInfo": { + "context": context, + "command": "RESTART", + "operation_level": operation_level + }, + "Requests/resource_filters": resource_filters + } + } + ]; + + App.ajax.send({ + name: 'common.batch.request_schedules', + sender: { + successCallback: defaultSuccessCallback, + errorCallback: defaultErrorCallback + }, + data: { + intervalTimeSeconds: 1, + tolerateSize: 0, + batches: batches, + query: query + }, + success: 'successCallback', + error: 'errorCallback' + }); + } else { + App.ajax.send({ + name: 'restart.hostComponents', + sender: { + successCallback: defaultSuccessCallback, + errorCallback: defaultErrorCallback + }, + data: { + context: context, + resource_filters: resource_filters, + query: query, + operation_level: operation_level + }, + success: 'successCallback', + error: 'errorCallback' + }); + } } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/23486664/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 bbf7fce..66bd454 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -472,13 +472,11 @@ describe('App.MainHostDetailsController', function () { sinon.spy(App, "showConfirmationPopup"); sinon.stub(batchUtils, "restartHostComponents", Em.K); sinon.stub(controller, 'checkNnLastCheckpointTime', Em.clb); - sinon.stub(controller, "refreshYARNQueueAndRestartComponent", Em.K); }); afterEach(function () { App.showConfirmationPopup.restore(); batchUtils.restartHostComponents.restore(); controller.checkNnLastCheckpointTime.restore(); - controller.refreshYARNQueueAndRestartComponent.restore(); }); it('popup should be displayed', function () { @@ -499,17 +497,6 @@ 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.refreshYARNQueueAndRestartComponent.calledOnce).to.be.true; - }); }); describe('#addComponent()', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/23486664/ambari-web/test/controllers/main/service_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service_test.js b/ambari-web/test/controllers/main/service_test.js index 9db4849..06961a1 100644 --- a/ambari-web/test/controllers/main/service_test.js +++ b/ambari-web/test/controllers/main/service_test.js @@ -687,4 +687,27 @@ describe('App.MainServiceController', function () { expect(mock.showPopup.calledOnce).to.be.true; }); }); + + describe('#restartHostComponents', function () { + + beforeEach(function () { + this.mock = sinon.stub(App.HostComponent, 'find'); + }); + afterEach(function () { + App.HostComponent.find.restore(); + }); + + it('should make batch request to refresh YARN queues', function () { + this.mock.returns([Em.Object.create({componentName: 'HIVE_SERVER_INTERACTIVE', staleConfigs: true}), Em.Object.create({componentName: 'RESOURCEMANAGER', staleConfigs: false})]); + mainServiceController.restartHostComponents(); + expect(testHelpers.findAjaxRequest('name', 'common.batch.request_schedules')).not.to.be.undefined; + }); + + it('should make single request without refresh YARN queues', function () { + this.mock.returns([Em.Object.create({componentName: 'HIVE_SERVER_INTERACTIVE', staleConfigs: false}), Em.Object.create({componentName: 'RESOURCEMANAGER', staleConfigs: false})]); + mainServiceController.restartHostComponents(); + expect(testHelpers.findAjaxRequest('name', 'request.post')).not.to.be.undefined; + }); + + }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/23486664/ambari-web/test/utils/batch_scheduled_requests_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/batch_scheduled_requests_test.js b/ambari-web/test/utils/batch_scheduled_requests_test.js index c282350..20b190b 100644 --- a/ambari-web/test/utils/batch_scheduled_requests_test.js +++ b/ambari-web/test/utils/batch_scheduled_requests_test.js @@ -20,6 +20,8 @@ require('utils/helper'); require('views/common/rolling_restart_view'); var batchUtils = require('utils/batch_scheduled_requests'); var modelSetup = require('test/init_model_test'); +var testHelpers = require('test/helpers'); + describe('batch_scheduled_requests', function() { beforeEach(function(){ @@ -131,4 +133,25 @@ describe('batch_scheduled_requests', function() { }); + describe('#restartHostComponents', function () { + + beforeEach(function () { + sinon.stub(App.HostComponent, 'find').returns([Em.Object.create({componentName: 'RESOURCEMANAGER', hostName: '1'})]); + }); + afterEach(function () { + App.HostComponent.find.restore(); + }); + + it('should make batch request to refresh YARN queues', function () { + batchUtils.restartHostComponents([Em.Object.create({componentName: 'HIVE_SERVER_INTERACTIVE'})]); + expect(testHelpers.findAjaxRequest('name', 'common.batch.request_schedules')).to.exists; + }); + + it('should make single request without refresh YARN queues', function () { + batchUtils.restartHostComponents([Em.Object.create({componentName: 'NAMENODE'})]); + expect(testHelpers.findAjaxRequest('name', 'restart.hostComponents')).to.exists; + }); + + }); + });
