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/08/11 11:31:20 UTC
ambari git commit: AMBARI-12715. FE: Adding 1000 hosts to config
group takes 50-60 seconds to process (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/branch-2.1.1 6067dfacc -> 591709e7e
AMBARI-12715. FE: Adding 1000 hosts to config group takes 50-60 seconds to process (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/591709e7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/591709e7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/591709e7
Branch: refs/heads/branch-2.1.1
Commit: 591709e7ea89da9170902927e4b64851dd163a1b
Parents: 6067dfa
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue Aug 11 12:28:42 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Tue Aug 11 12:28:42 2015 +0300
----------------------------------------------------------------------
.../service/manage_config_groups_controller.js | 18 +++++------
.../manage_config_groups_controller_test.js | 32 ++++++++++++++++++++
2 files changed, 41 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/591709e7/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
index e1d44ca..d29b470 100644
--- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
+++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
@@ -479,32 +479,32 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
},
/**
- * add hosts callback
+ * Remove selected hosts from default group (<code>selectedConfigGroup.parentConfigGroup</code>) and add them to the <code>selectedConfigGroup</code>
* @param {string[]} selectedHosts
* @method addHostsCallback
*/
addHostsCallback: function (selectedHosts) {
if (selectedHosts) {
var group = this.get('selectedConfigGroup');
- selectedHosts.forEach(function (hostName) {
- group.get('hosts').pushObject(hostName);
- group.get('parentConfigGroup.hosts').removeObject(hostName);
+ var parentGroupHosts = group.get('parentConfigGroup.hosts');
+ var newHostsForParentGroup = parentGroupHosts.filter(function(hostName) {
+ return !selectedHosts.contains(hostName);
});
+ group.get('hosts').pushObjects(selectedHosts);
+ group.set('parentConfigGroup.hosts', newHostsForParentGroup);
}
},
/**
- * delete hosts from group
+ * Delete hosts from <code>selectedConfigGroup</code> and move them to the Default group (<code>selectedConfigGroup.parentConfigGroup</code>)
* @method deleteHosts
*/
deleteHosts: function () {
if (this.get('isDeleteHostsDisabled')) {
return;
}
- this.get('selectedHosts').slice().forEach(function (hostName) {
- this.get('selectedConfigGroup.parentConfigGroup.hosts').pushObject(hostName);
- this.get('selectedConfigGroup.hosts').removeObject(hostName);
- }, this);
+ var hosts = this.get('selectedHosts').slice();
+ this.get('selectedConfigGroup.parentConfigGroup.hosts').pushObjects(hosts);
this.set('selectedHosts', []);
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/591709e7/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
index a1812c8..b45f7ab 100644
--- a/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
+++ b/ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
@@ -18,12 +18,14 @@
var App = require('app');
var c;
+
describe('App.ManageConfigGroupsController', function() {
var controller = App.ManageConfigGroupsController.create({});
beforeEach(function() {
c = App.ManageConfigGroupsController.create({});
});
+
var manageConfigGroupsController = App.ManageConfigGroupsController.create({});
describe('#addConfigGroup', function() {
@@ -157,4 +159,34 @@ describe('App.ManageConfigGroupsController', function() {
});
+ describe('#deleteConfigGroup', function () {
+
+ beforeEach(function() {
+
+ var defaultGroup = Em.Object.create({
+ hosts: ['h2', 'h3'],
+ isDefault: true
+ });
+
+ var selectedGroup = Em.Object.create({
+ hosts: ['h1'],
+ parentConfigGroup: defaultGroup
+ });
+
+ c.reopen({
+ configGroups: [defaultGroup, selectedGroup],
+ selectedConfigGroup: selectedGroup
+ });
+ });
+
+ it('after deleting some config group, Default should be selected', function () {
+
+ c.deleteConfigGroup();
+
+ expect(c.get('selectedConfigGroup.hosts')).to.include.members(['h1','h2','h3']);
+ expect(c.get('selectedConfigGroup.isDefault')).to.be.true;
+ });
+
+ });
+
});