ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject ambari git commit: AMBARI-12313. Service config pages load extremely slowly (especially on big clusters). (atkach via yusaku)
Date Tue, 07 Jul 2015 18:05:38 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 2735157fa -> 4d71f7540


AMBARI-12313. Service config pages load extremely slowly (especially on big clusters). (atkach
via yusaku)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4d71f754
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4d71f754
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4d71f754

Branch: refs/heads/trunk
Commit: 4d71f7540a72b166711de97ed15201c7c5860632
Parents: 2735157
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Tue Jul 7 11:04:20 2015 -0700
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Tue Jul 7 11:05:01 2015 -0700

----------------------------------------------------------------------
 .../app/mappers/component_config_mapper.js      | 35 ++++++------
 .../app/mixins/common/table_server_mixin.js     |  5 ++
 ambari-web/app/utils/blueprint.js               | 59 +++++++++++++-------
 ambari-web/test/utils/blueprint_test.js         | 58 +++++++++++++++++--
 4 files changed, 116 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4d71f754/ambari-web/app/mappers/component_config_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/component_config_mapper.js b/ambari-web/app/mappers/component_config_mapper.js
index 0d2466a..dddb79a 100644
--- a/ambari-web/app/mappers/component_config_mapper.js
+++ b/ambari-web/app/mappers/component_config_mapper.js
@@ -42,7 +42,7 @@ App.componentConfigMapper = App.QuickDataMapper.create({
     // We do not want to parse JSON if there is no need to
     var hostComponentJsonMap = {};
     var hostComponentJsonIds = [];
-    var hostComponentJsonsToRemove = {};
+    var hostComponentLoaded = {};
 
     if (json.items.length > 0 || this.get('model').find().someProperty('staleConfigs',
true)) {
       json.items.forEach(function (item) {
@@ -54,31 +54,32 @@ App.componentConfigMapper = App.QuickDataMapper.create({
       });
       this.get('model').find().forEach(function (hostComponent) {
         var hostComponentJson = hostComponentJsonMap[hostComponent.get('id')];
-        if (!hostComponentJson && !hostComponent.get('isMaster')) {
-          hostComponent.set('staleConfigs', false);
-        }
-        if (hostComponentJson != null && hostComponent.get('staleConfigs') &&
-          hostComponentJson.HostRoles.state == hostComponent.get('workStatus') &&
-          hostComponentJson.HostRoles.maintenance_state == hostComponent.get('passiveState'))
{
-          // A component already exists with correct stale_configs flag and other values
- no need to load again
-          hostComponentJsonsToRemove[hostComponentJson.id] = hostComponentJson;
+        var currentStaleConfigsState = Boolean(hostComponentJson);
+        var stateChanged = hostComponent.get('staleConfigs') !== currentStaleConfigsState;
+
+        if (stateChanged && !hostComponent.get('isMaster')) {
+          hostComponent.set('staleConfigs', currentStaleConfigsState);
         }
+        //delete load host-components, so only new ones left
+        delete hostComponentJsonMap[hostComponent.get('id')];
       });
       hostComponentJsonIds.forEach(function (hcId) {
-        if (!hostComponentJsonsToRemove[hcId]) {
-          var host_component = hostComponentJsonMap[hcId];
-          var serviceName = host_component.HostRoles.service_name;
-          hostComponents.push(this.parseIt(host_component, mapConfig));
+        var newHostComponent = hostComponentJsonMap[hcId];
+        if (newHostComponent) {
+          var serviceName = newHostComponent.HostRoles.service_name;
+          hostComponents.push(this.parseIt(newHostComponent, mapConfig));
           if (!newHostComponentsMap[serviceName]) {
             newHostComponentsMap[serviceName] = [];
           }
-          if (!currentServiceComponentsMap[serviceName][host_component.id]) {
-            newHostComponentsMap[serviceName].push(host_component.id);
+          if (!currentServiceComponentsMap[serviceName][newHostComponent.id]) {
+            newHostComponentsMap[serviceName].push(newHostComponent.id);
           }
         }
       }, this);
-      App.store.loadMany(this.get('model'), hostComponents);
-      this.addNewHostComponents(newHostComponentsMap, cacheServices);
+      if (hostComponents.length > 0) {
+        App.store.loadMany(this.get('model'), hostComponents);
+        this.addNewHostComponents(newHostComponentsMap, cacheServices);
+      }
     }
     console.timeEnd('App.componentConfigMapper execution time');
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/4d71f754/ambari-web/app/mixins/common/table_server_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/table_server_mixin.js b/ambari-web/app/mixins/common/table_server_mixin.js
index 84e9ce3..5162a02 100644
--- a/ambari-web/app/mixins/common/table_server_mixin.js
+++ b/ambari-web/app/mixins/common/table_server_mixin.js
@@ -59,6 +59,11 @@ App.TableServerMixin = Em.Mixin.create({
    * @return {array}
    */
   getPaginationProps: function () {
+    var displayLength = App.db.getDisplayLength(this.get('name'));
+    if (displayLength) {
+      this.get('paginationProps').findProperty('name', 'displayLength').value = displayLength;
+    }
+
     var startIndex = App.db.getStartIndex(this.get('name'));
     if (!Em.isNone(startIndex)) {
       startIndex = (startIndex > 0) ? startIndex - 1 : startIndex;

http://git-wip-us.apache.org/repos/asf/ambari/blob/4d71f754/ambari-web/app/utils/blueprint.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/blueprint.js b/ambari-web/app/utils/blueprint.js
index 4eb63c0..6ccd86c 100644
--- a/ambari-web/app/utils/blueprint.js
+++ b/ambari-web/app/utils/blueprint.js
@@ -248,13 +248,15 @@ module.exports = {
         host_groups: []
       }
     };
+    var hostsMap = this.getComponentForHosts();
 
-    for (var i = 1; i <= hostNames.length; i++) {
+    for (var i = 0; i <= hostNames.length; i++) {
       var host_group = {
-        name: "host-group-" + i,
+        name: "host-group-" + (i + 1),
         components: []
       };
-      var hcFiltered = this.getComponentForHost(hostNames[i-1]);
+      var hcFiltered = hostsMap[hostNames[i]];
+      if (Em.isNone(hcFiltered)) continue;
       for (var j = 0; j < hcFiltered.length; j++) {
         host_group.components.push({
           name: hcFiltered[j]
@@ -262,9 +264,9 @@ module.exports = {
       }
       recommendations.blueprint.host_groups.push(host_group);
       recommendations.blueprint_cluster_binding.host_groups.push({
-        name: "host-group-" + i,
+        name: "host-group-" + (i + 1),
         hosts: [{
-          fqdn: hostNames[i-1]
+          fqdn: hostNames[i]
         }]
       });
     }
@@ -272,20 +274,39 @@ module.exports = {
   },
 
   /**
-   * gets all component names that are present on current host
-   * @param {String} hostName
-   * @returns {Array}
+   * collect all component names that are present on hosts
+   * @returns {object}
    */
-  getComponentForHost: function(hostName) {
-    var clients = App.ClientComponent.find().filter(function(c) {
-      return c.get('hostNames').contains(hostName);
-    }).mapProperty('componentName');
-    var slaves = App.SlaveComponent.find().filter(function(s) {
-      return s.get('hostNames').contains(hostName);
-    }).mapProperty('componentName');
-    var masters = App.HostComponent.find().filter(function(m) {
-      return m.get('isMaster') && m.get('hostName') === hostName;
-    }).mapProperty('componentName');
-    return masters.concat(slaves).concat(clients);
+  getComponentForHosts: function() {
+    var hostsMap = {};
+    App.ClientComponent.find().forEach(function(c) {
+      var componentName = c.get('componentName');
+      c.get('hostNames').forEach(function(hostName){
+        if (hostsMap[hostName]) {
+          hostsMap[hostName].push(componentName);
+        } else {
+          hostsMap[hostName] = [componentName];
+        }
+      });
+    });
+    App.SlaveComponent.find().forEach(function (c) {
+      var componentName = c.get('componentName');
+      c.get('hostNames').forEach(function (hostName) {
+        if (hostsMap[hostName]) {
+          hostsMap[hostName].push(componentName);
+        } else {
+          hostsMap[hostName] = [componentName];
+        }
+      });
+    });
+    App.HostComponent.find().forEach(function (c) {
+      var hostName = c.get('hostName');
+      if (hostsMap[hostName]) {
+        hostsMap[hostName].push(c.get('componentName'));
+      } else {
+        hostsMap[hostName] = [c.get('componentName')];
+      }
+    });
+    return hostsMap;
   }
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/4d71f754/ambari-web/test/utils/blueprint_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/blueprint_test.js b/ambari-web/test/utils/blueprint_test.js
index a0253a8..cc6b932 100644
--- a/ambari-web/test/utils/blueprint_test.js
+++ b/ambari-web/test/utils/blueprint_test.js
@@ -334,15 +334,17 @@ describe('utils/blueprint', function() {
     });
   });
 
-  describe('#generateHostGroups', function () {
+  describe('#generateHostGroups()', function () {
     beforeEach(function() {
-      sinon.stub(blueprintUtils, 'getComponentForHost' ,function(host) {
-        return host == "host1" ? ["C1","C2"] : ["C1","C3"];
+      sinon.stub(blueprintUtils, 'getComponentForHosts').returns({
+        "host1": ["C1", "C2"],
+        "host2": ["C1", "C3"]
       });
     });
     afterEach(function() {
-      blueprintUtils.getComponentForHost.restore();
-    })
+      blueprintUtils.getComponentForHosts.restore();
+    });
+
     var tests = [
       {
         "hostNames": ["host1", "host2"],
@@ -420,4 +422,50 @@ describe('utils/blueprint', function() {
       });
     });
   });
+
+  describe("#getComponentForHosts()", function() {
+
+    beforeEach(function() {
+      sinon.stub(App.ClientComponent, 'find').returns([
+        Em.Object.create({
+          componentName: "C1",
+          hostNames: ["host1", "host2"]
+        })
+      ]);
+      sinon.stub(App.SlaveComponent, 'find').returns([
+        Em.Object.create({
+          componentName: "C2",
+          hostNames: ["host2", "host3"]
+        })
+      ]);
+      sinon.stub(App.HostComponent, 'find').returns([
+        Em.Object.create({
+          componentName: "C3",
+          hostName: "host3",
+          isMaster: true
+        })
+      ]);
+    });
+    afterEach(function() {
+      App.ClientComponent.find.restore();
+      App.SlaveComponent.find.restore();
+      App.HostComponent.find.restore();
+    });
+
+    it("", function() {
+      expect(blueprintUtils.getComponentForHosts()).to.eql({
+        "host1": [
+          "C1"
+        ],
+        "host2": [
+          "C1",
+          "C2"
+        ],
+        "host3": [
+          "C2",
+          "C3"
+        ]
+      });
+    });
+  });
 });
\ No newline at end of file


Mime
View raw message