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/12 13:39:06 UTC

[2/2] ambari git commit: AMBARI-12715. FE: Adding 1000 hosts to config group takes 50-60 seconds to process (onechiporenko)

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/a93aa629
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a93aa629
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a93aa629

Branch: refs/heads/branch-2.1
Commit: a93aa629353bf7ac8538d6f4bc06b688d736b15b
Parents: e8ae332
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue Aug 11 12:28:42 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Wed Aug 12 14:35:59 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/a93aa629/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 4ce4145..1f61f36 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
@@ -493,32 +493,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/a93aa629/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;
+    });
+
+  });
+
 });