Repository: ambari Updated Branches: refs/heads/trunk fb9455562 -> b86507829
AMBARI-16419: PXF should be collocated with NAMENODE even if NAMENODE is moved to another host (mithmatt) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b8650782 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b8650782 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b8650782 Branch: refs/heads/trunk Commit: b86507829d11eb8a16b9046a9458879881e3ab4e Parents: fb94555 Author: Matt <[email protected]> Authored: Wed May 11 19:30:13 2016 -0700 Committer: Matt <[email protected]> Committed: Wed May 11 19:30:13 2016 -0700 ---------------------------------------------------------------------- .../main/service/reassign/step6_controller.js | 18 ++++ ambari-web/app/messages.js | 1 + .../service/reassign/step6_controller_test.js | 95 ++++++++++++++++++++ 3 files changed, 114 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b8650782/ambari-web/app/controllers/main/service/reassign/step6_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/reassign/step6_controller.js b/ambari-web/app/controllers/main/service/reassign/step6_controller.js index f718d46..113686b 100644 --- a/ambari-web/app/controllers/main/service/reassign/step6_controller.js +++ b/ambari-web/app/controllers/main/service/reassign/step6_controller.js @@ -42,6 +42,20 @@ App.ReassignMasterWizardStep6Controller = App.HighAvailabilityProgressPageContro } else { this.set('hostComponents', [this.get('content.reassign.component_name')]); } + + if (App.Service.find().someProperty('serviceName', 'PXF') && this.get('content.reassign.component_name') === 'NAMENODE') { + var pxfHosts = App.HostComponent.find().filterProperty('componentName', 'PXF').mapProperty('hostName'); + var dataNodeHosts = App.HostComponent.find().filterProperty('componentName', 'DATANODE').mapProperty('hostName'); + + // If NAMENODE is being moved and source host does not have DATANODE, PXF should be removed from source host + if (pxfHosts.contains(this.get('content.reassignHosts.source')) && !dataNodeHosts.contains(this.get('content.reassignHosts.source'))) + this.get('hostComponents').push('PXF'); + + // If NAMENODE is being moved and target host does not have PXF, PXF should be added to target host + if (!pxfHosts.contains(this.get('content.reassignHosts.target'))) + this.get('commands').splice(this.get('commands').indexOf('startAllServices'), 0, 'installPxf'); + } + this._super(); }, @@ -118,6 +132,10 @@ App.ReassignMasterWizardStep6Controller = App.HighAvailabilityProgressPageContro } }, + installPxf: function () { + this.createInstallComponentTask('PXF', this.get('content.reassignHosts.target'), "PXF"); + }, + startAllServices: function () { this.startServices(true); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/b8650782/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index e388526..910bed7 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -2231,6 +2231,7 @@ Em.I18n.translations = { 'services.reassign.step6.tasks.putHostComponentsInMaintenanceMode.title':'Disable {0}', 'services.reassign.step6.tasks.deleteHostComponents.title': 'Delete disabled {0}', 'services.reassign.step6.tasks.startAllServices.title': 'Start All Services', + 'services.reassign.step6.tasks.installPxf.title': 'Install PXF on NameNode', 'services.reassign.step6.tasks.stopMysqlService.title': 'Stop Mysql Server', 'services.reassign.step6.tasks.stopHostComponentsInMaintenanceMode.title': 'Stop {0}', 'services.reassign.step6.status.success': 'Successfully moved <b>{0}</b> from <b>{1}</b> host to <b>{2}</b> host.', http://git-wip-us.apache.org/repos/asf/ambari/blob/b8650782/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js index 89e2325..f5029a8 100644 --- a/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js +++ b/ambari-web/test/controllers/main/service/reassign/step6_controller_test.js @@ -138,6 +138,101 @@ describe('App.ReassignMasterWizardStep6Controller', function () { }); }); + describe('#loadStep() for reassign NameNode with PXF service installed', function () { + + var serviceStub, hostComponentStub, pxfHosts, dataNodeHosts; + + var commands = [ + 'stopMysqlService', + 'putHostComponentsInMaintenanceMode', + 'stopHostComponentsInMaintenanceMode', + 'deleteHostComponents', + 'startAllServices' + ]; + + var reassignHosts = { + "source": "c6401.ambari.apache.org", + "target": "c6403.ambari.apache.org" + }; + + beforeEach(function () { + controller.set('content.reassign.service_id', 'HDFS'); + controller.set('content.reassign.component_name', 'NAMENODE'); + controller.set('commands', commands.copy()); + controller.set('content.reassignHosts', reassignHosts); + sinon.stub(controller, 'onTaskStatusChange', Em.K); + sinon.stub(controller, 'initializeTasks', Em.K); + serviceStub = sinon.stub(App.Service.find(), 'someProperty'); + hostComponentStub = sinon.stub(App.HostComponent.find(), 'filterProperty'); + serviceStub.withArgs('serviceName', 'PXF').returns(true); + }); + + afterEach(function () { + controller.onTaskStatusChange.restore(); + controller.initializeTasks.restore(); + serviceStub.restore(); + hostComponentStub.restore(); + }); + + var setUpHosts = function (pxfHosts, dataNodeHosts) { + hostComponentStub.withArgs('componentName', 'PXF').returns(pxfHosts); + hostComponentStub.withArgs('componentName', 'DATANODE').returns(dataNodeHosts); + }; + + it('does not delete PXF from source host if PXF and DATANODE are not installed on the source host', function () { + pxfHosts = [{"hostName": "c6402.ambari.apache.org"}]; + dataNodeHosts = [{"hostName": "c6402.ambari.apache.org"}]; + setUpHosts(pxfHosts, dataNodeHosts); + + controller.loadStep(); + expect(controller.get('hostComponents')).to.eql(['NAMENODE']); + }); + + it('does not delete PXF from source host if PXF is not installed on the source host and DATANODE is installed on the source host', function () { + pxfHosts = [{"hostName": "c6402.ambari.apache.org"}]; + dataNodeHosts = [{"hostName": "c6401.ambari.apache.org"}, {"hostName": "c6402.ambari.apache.org"}]; + setUpHosts(pxfHosts, dataNodeHosts); + + controller.loadStep(); + expect(controller.get('hostComponents')).to.eql(['NAMENODE']); + }); + + it('deletes PXF from source host if PXF is installed on the source host and DATANODE is not installed on the source host', function () { + pxfHosts = [{"hostName": "c6401.ambari.apache.org"}, {"hostName": "c6402.ambari.apache.org"}]; + dataNodeHosts = [{"hostName": "c6402.ambari.apache.org"}]; + setUpHosts(pxfHosts, dataNodeHosts); + + controller.loadStep(); + expect(controller.get('hostComponents')).to.eql(['NAMENODE', 'PXF']); + }); + + it('does not delete PXF from source host if PXF and DATANODE are installed on the source host', function () { + pxfHosts = [{"hostName": "c6401.ambari.apache.org"}, {"hostName": "c6402.ambari.apache.org"}]; + dataNodeHosts = [{"hostName": "c6401.ambari.apache.org"}, {"hostName": "c6402.ambari.apache.org"}]; + setUpHosts(pxfHosts, dataNodeHosts); + + controller.loadStep(); + expect(controller.get('hostComponents')).to.eql(['NAMENODE']); + }); + + it('does not install PXF on the target host if PXF is already installed on the target host', function () { + pxfHosts = [{"hostName": "c6403.ambari.apache.org"}]; + setUpHosts(pxfHosts, []); + + controller.loadStep(); + expect(controller.get('commands').indexOf('installPxf')).to.eql(-1); + }); + + it('installs PXF on the target host if PXF is not installed on the target host', function () { + pxfHosts = [{"hostName": "c6401.ambari.apache.org"}, {"hostName": "c6402.ambari.apache.org"}]; + setUpHosts(pxfHosts, []); + + controller.loadStep(); + expect(controller.get('commands').indexOf('installPxf')).to.eql(4); + }); + + }); + describe('#deleteHostComponents()', function () { it('No host components', function () {
