You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/07/14 14:21:31 UTC
ambari git commit: AMBARI-12405. Host value not saved when going back
in RM HA wizard (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 461ce541a -> 798357d81
AMBARI-12405. Host value not saved when going back in RM HA wizard (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/798357d8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/798357d8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/798357d8
Branch: refs/heads/trunk
Commit: 798357d81e33882a5e918b0220effdc07c20d72c
Parents: 461ce54
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue Jul 14 15:03:51 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Tue Jul 14 15:03:51 2015 +0300
----------------------------------------------------------------------
.../nameNode/wizard_controller.js | 25 -------
.../main/service/reassign_controller.js | 1 +
ambari-web/app/controllers/wizard.js | 26 +++++++
.../mixins/wizard/assign_master_components.js | 20 ++++--
.../app/routes/high_availability_routes.js | 5 +-
.../app/routes/ra_high_availability_routes.js | 5 +-
ambari-web/app/routes/reassign_master_routes.js | 2 +
.../app/routes/rm_high_availability_routes.js | 5 +-
.../main/service/reassign_controller_test.js | 63 +++++++++++++++-
ambari-web/test/controllers/wizard_test.js | 75 ++++++++++++++++++++
10 files changed, 187 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/app/controllers/main/admin/highAvailability/nameNode/wizard_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/wizard_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/wizard_controller.js
index ae2fa60..134cb64 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability/nameNode/wizard_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability/nameNode/wizard_controller.js
@@ -81,31 +81,6 @@ App.HighAvailabilityWizardController = App.WizardController.extend({
this.save('cluster');
},
- /**
- * Save Master Component Hosts data to Main Controller
- * @param stepController App.WizardStep5Controller
- */
- saveMasterComponentHosts: function (stepController) {
- var obj = stepController.get('selectedServicesMasters');
- var masterComponentHosts = [];
- obj.forEach(function (_component) {
- masterComponentHosts.push({
- display_name: _component.get('display_name'),
- component: _component.get('component_name'),
- hostName: _component.get('selectedHost'),
- serviceId: _component.get('serviceId'),
- isInstalled: _component.get('isInstalled')
- });
- });
- this.setDBProperty('masterComponentHosts', masterComponentHosts);
- this.set('content.masterComponentHosts', masterComponentHosts);
- },
-
- clearMasterComponentHosts: function() {
- this.set('content.masterComponentHosts', null);
- this.setDBProperty('masterComponentHosts', null);
- },
-
saveHdfsUser: function () {
App.db.setHighAvailabilityWizardHdfsUser(this.get('content.hdfsUser'));
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/app/controllers/main/service/reassign_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/reassign_controller.js b/ambari-web/app/controllers/main/service/reassign_controller.js
index 1827bf5..7db5092 100644
--- a/ambari-web/app/controllers/main/service/reassign_controller.js
+++ b/ambari-web/app/controllers/main/service/reassign_controller.js
@@ -184,6 +184,7 @@ App.ReassignMasterController = App.WizardController.extend({
});
App.db.setMasterComponentHosts(masterComponentHosts);
this.set('content.masterComponentHosts', masterComponentHosts);
+ this.setDBProperty('masterComponentHosts', masterComponentHosts);
},
loadComponentToReassign: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index eaf60a2..b1e7073 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -1078,6 +1078,32 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
}
this.set("content.masterComponentHosts", masterComponentHosts);
},
+
+ /**
+ * Save Master Component Hosts data to Main Controller
+ * @param stepController App.WizardStep5Controller
+ */
+ saveMasterComponentHosts: function (stepController) {
+ var obj = stepController.get('selectedServicesMasters');
+ var masterComponentHosts = [];
+ obj.forEach(function (_component) {
+ masterComponentHosts.push({
+ display_name: _component.get('display_name'),
+ component: _component.get('component_name'),
+ hostName: _component.get('selectedHost'),
+ serviceId: _component.get('serviceId'),
+ isInstalled: _component.get('isInstalled')
+ });
+ });
+ this.setDBProperty('masterComponentHosts', masterComponentHosts);
+ this.set('content.masterComponentHosts', masterComponentHosts);
+ },
+
+ clearMasterComponentHosts: function() {
+ this.set('content.masterComponentHosts', null);
+ this.setDBProperty('masterComponentHosts', null);
+ },
+
/**
* Load information about hosts with clients components
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/app/mixins/wizard/assign_master_components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/assign_master_components.js b/ambari-web/app/mixins/wizard/assign_master_components.js
index d3d674a..9f6b477 100644
--- a/ambari-web/app/mixins/wizard/assign_master_components.js
+++ b/ambari-web/app/mixins/wizard/assign_master_components.js
@@ -537,8 +537,8 @@ App.AssignMasterComponents = Em.Mixin.create({
var mastersLength = this.get("selectedServicesMasters").filterProperty("component_name", componentName).length;
if (mastersLength < this.getMaxNumberOfMasters(componentName)) {
component.set('showAddControl', true);
- } else if (mastersLength == 1) {
- component.set('showRemoveControl', false);
+ } else {
+ component.set('showRemoveControl', mastersLength != 1);
}
}
},
@@ -797,16 +797,22 @@ App.AssignMasterComponents = Em.Mixin.create({
* @returns {masterComponents[]}
*/
addNewMasters: function (masterComponents) {
- this.get('mastersToAdd').forEach(function(masterName){
- var hostName = this.getHostForMaster(masterName, masterComponents);
- var serviceName = this.getServiceByMaster(masterName);
- masterComponents.push(this.createComponentInstallationObject(
+ this.get('mastersToAdd').forEach(function (masterName, index, mastersToAdd) {
+ var toBeAddedNumber = mastersToAdd.filter(function (name) {
+ return name === masterName;
+ }).length,
+ alreadyAddedNumber = masterComponents.filterProperty('component_name', masterName).rejectProperty('isInstalled').length;
+ if (toBeAddedNumber > alreadyAddedNumber) {
+ var hostName = this.getHostForMaster(masterName, masterComponents),
+ serviceName = this.getServiceByMaster(masterName);
+ masterComponents.push(this.createComponentInstallationObject(
Em.Object.create({
componentName: masterName,
serviceName: serviceName
}),
hostName
- ));
+ ));
+ }
}, this);
return masterComponents;
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/app/routes/high_availability_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/high_availability_routes.js b/ambari-web/app/routes/high_availability_routes.js
index 1e25ab3..381d285 100644
--- a/ambari-web/app/routes/high_availability_routes.js
+++ b/ambari-web/app/routes/high_availability_routes.js
@@ -124,16 +124,13 @@ module.exports = App.WizardRoute.extend({
next: function (router) {
var controller = router.get('highAvailabilityWizardController');
controller.saveNameServiceId(router.get('highAvailabilityWizardStep1Controller.content.nameServiceId'));
+ controller.clearMasterComponentHosts();
router.transitionTo('step2');
}
}),
step2: Em.Route.extend({
route: '/step2',
- enter: function(router) {
- var controller = router.get('highAvailabilityWizardController');
- controller.clearMasterComponentHosts();
- },
connectOutlets: function (router) {
var controller = router.get('highAvailabilityWizardController');
controller.dataLoading().done(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/app/routes/ra_high_availability_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/ra_high_availability_routes.js b/ambari-web/app/routes/ra_high_availability_routes.js
index fe93992..ebdbf97 100644
--- a/ambari-web/app/routes/ra_high_availability_routes.js
+++ b/ambari-web/app/routes/ra_high_availability_routes.js
@@ -109,7 +109,9 @@ module.exports = App.WizardRoute.extend({
});
},
next: function (router) {
- router.get('rAHighAvailabilityWizardController').save('loadBalancerURL');
+ var controller = router.get('rAHighAvailabilityWizardController');
+ controller.save('loadBalancerURL');
+ controller.clearMasterComponentHosts();
router.transitionTo('step2');
}
}),
@@ -136,6 +138,7 @@ module.exports = App.WizardRoute.extend({
};
wizardController.set('content.raHosts', raHosts);
wizardController.save('raHosts');
+ wizardController.saveMasterComponentHosts(stepController);
router.transitionTo('step3');
},
back: function (router) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/app/routes/reassign_master_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/reassign_master_routes.js b/ambari-web/app/routes/reassign_master_routes.js
index b93f9a6..9802fc2 100644
--- a/ambari-web/app/routes/reassign_master_routes.js
+++ b/ambari-web/app/routes/reassign_master_routes.js
@@ -127,7 +127,9 @@ module.exports = App.WizardRoute.extend({
})
},
next: function (router) {
+ var controller = router.get('reassignMasterController');
App.db.setMasterComponentHosts(undefined);
+ controller.clearMasterComponentHosts();
router.transitionTo('step2');
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/app/routes/rm_high_availability_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/rm_high_availability_routes.js b/ambari-web/app/routes/rm_high_availability_routes.js
index 3c11376..6d58c62 100644
--- a/ambari-web/app/routes/rm_high_availability_routes.js
+++ b/ambari-web/app/routes/rm_high_availability_routes.js
@@ -110,7 +110,9 @@ module.exports = App.WizardRoute.extend({
return false;
},
next: function (router) {
- router.get('rMHighAvailabilityWizardController').setDBProperty('rmHosts', undefined);
+ var controller = router.get('rMHighAvailabilityWizardController');
+ controller.setDBProperty('rmHosts', undefined);
+ controller.clearMasterComponentHosts();
router.transitionTo('step2');
}
}),
@@ -138,6 +140,7 @@ module.exports = App.WizardRoute.extend({
additionalRM: additionalRM.get('selectedHost')
};
wizardController.saveRmHosts(rmHost);
+ wizardController.saveMasterComponentHosts(stepController);
router.transitionTo('step3');
},
back: function (router) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/test/controllers/main/service/reassign_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign_controller_test.js b/ambari-web/test/controllers/main/service/reassign_controller_test.js
index 12e5f9c..498cbab 100644
--- a/ambari-web/test/controllers/main/service/reassign_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign_controller_test.js
@@ -23,14 +23,73 @@ require('controllers/main/service/reassign_controller');
describe('App.ReassignMasterController', function () {
- var reassignMasterController = App.ReassignMasterController.create({});
+ var reassignMasterController;
+
+ beforeEach(function () {
+ reassignMasterController = App.ReassignMasterController.create({});
+ });
describe('#totalSteps', function () {
it('check', function () {
expect(reassignMasterController.get('totalSteps')).to.equal(7);
+ reassignMasterController.set('content.reassign', {service_id:null});
});
});
- reassignMasterController.set('content.reassign', {service_id:null});
+ describe('#saveMasterComponentHosts', function () {
+
+ var stepController = Em.Object.create({
+ selectedServicesMasters: [
+ Em.Object.create({
+ display_name: 'd0',
+ component_name: 'c0',
+ selectedHost: 'h0',
+ serviceId: 's0'
+ }),
+ Em.Object.create({
+ display_name: 'd1',
+ component_name: 'c1',
+ selectedHost: 'h1',
+ serviceId: 's1'
+ })
+ ]
+ }),
+ masterComponentHosts = [
+ {
+ display_name: 'd0',
+ component: 'c0',
+ hostName: 'h0',
+ serviceId: 's0',
+ isInstalled: true
+ },
+ {
+ display_name: 'd1',
+ component: 'c1',
+ hostName: 'h1',
+ serviceId: 's1',
+ isInstalled: true
+ }
+ ];
+
+ beforeEach(function () {
+ sinon.stub(App.db, 'setMasterComponentHosts', Em.K);
+ sinon.stub(reassignMasterController, 'setDBProperty', Em.K);
+ });
+
+ afterEach(function () {
+ App.db.setMasterComponentHosts.restore();
+ reassignMasterController.setDBProperty.restore();
+ });
+
+ it('should save master component hosts', function () {
+ reassignMasterController.saveMasterComponentHosts(stepController);
+ expect(App.db.setMasterComponentHosts.calledOnce).to.be.true;
+ expect(reassignMasterController.setDBProperty.calledOnce).to.be.true;
+ expect(App.db.setMasterComponentHosts.calledWith(masterComponentHosts)).to.be.true;
+ expect(reassignMasterController.setDBProperty.calledWith('masterComponentHosts', masterComponentHosts)).to.be.true;
+ expect(reassignMasterController.get('content.masterComponentHosts')).to.eql(masterComponentHosts);
+ });
+
+ });
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/798357d8/ambari-web/test/controllers/wizard_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index 95f7f5c..b00e5ba 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -1387,4 +1387,79 @@ describe('App.WizardController', function () {
});
});
+ describe('#saveMasterComponentHosts', function () {
+
+ var stepController = Em.Object.create({
+ selectedServicesMasters: [
+ Em.Object.create({
+ display_name: 'd0',
+ component_name: 'c0',
+ selectedHost: 'h0',
+ serviceId: 's0',
+ isInstalled: true
+ }),
+ Em.Object.create({
+ display_name: 'd1',
+ component_name: 'c1',
+ selectedHost: 'h1',
+ serviceId: 's1',
+ isInstalled: false
+ })
+ ]
+ }),
+ masterComponentHosts = [
+ {
+ display_name: 'd0',
+ component: 'c0',
+ hostName: 'h0',
+ serviceId: 's0',
+ isInstalled: true
+ },
+ {
+ display_name: 'd1',
+ component: 'c1',
+ hostName: 'h1',
+ serviceId: 's1',
+ isInstalled: false
+ }
+ ];
+
+ beforeEach(function () {
+ sinon.stub(wizardController, 'setDBProperty', Em.K);
+ });
+
+ afterEach(function () {
+ wizardController.setDBProperty.restore();
+ });
+
+ it('should save master component hosts', function () {
+ wizardController.saveMasterComponentHosts(stepController);
+ expect(wizardController.setDBProperty.calledOnce).to.be.true;
+ expect(wizardController.setDBProperty.calledWith('masterComponentHosts', masterComponentHosts)).to.be.true;
+ expect(wizardController.get('content.masterComponentHosts')).to.eql(masterComponentHosts);
+ });
+
+ });
+
+ describe('#clearMasterComponentHosts', function () {
+
+ beforeEach(function () {
+ sinon.stub(wizardController, 'setDBProperty', Em.K);
+ });
+
+ afterEach(function () {
+ wizardController.setDBProperty.restore();
+ });
+
+ it('should clear master component hosts', function () {
+ wizardController.set('content.masterComponentHosts', {});
+ wizardController.clearMasterComponentHosts();
+ expect(wizardController.setDBProperty.calledOnce).to.be.true;
+ expect(wizardController.setDBProperty.calledWith('masterComponentHosts', null)).to.be.true;
+ expect(wizardController.get('content.masterComponentHosts')).to.be.null;
+ });
+
+ });
+
+
});