Преглед изворни кода

AMBARI-6252 Service Configs page loads too slow on 2k node cluster [patch 2]. (Buzhor Denys via ababiichuk)

aBabiichuk пре 11 година
родитељ
комит
8d4c6b86ab

+ 0 - 20
ambari-web/app/controllers/global/cluster_controller.js

@@ -233,32 +233,12 @@ App.ClusterController = Em.Controller.extend({
   }.property('App.router.updateController.isUpdated', 'dataLoadList.serviceMetrics'),
 
   /**
-   * Get all host names. We have many places where we need it.
-   **/
-  loadAllHostNames: function () {
-    App.ajax.send({
-      sender: this,
-      name: 'cluster.fields',
-      data: {
-        fields: ['hosts'],
-        clusterName: App.get('clusterName')
-      },
-      success: 'loadAllHostNamesSuccess'
-    });
-  },
-
-  loadAllHostNamesSuccess: function(response) {
-    App.cache['HostsList'] = response.hosts.mapProperty('Hosts.host_name');
-  },
-  /**
-   *
    *  load all data and update load status
    */
   loadClusterData: function () {
     var self = this;
     this.loadAmbariProperties();
     this.loadAmbariViews();
-    this.loadAllHostNames();
     if (!this.get('clusterName')) {
       return;
     }

+ 5 - 5
ambari-web/app/controllers/main/service/info/configs.js

@@ -224,9 +224,9 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     var serviceName = this.get('content.serviceName');
     console.debug("loadServiceConfigs(): data=", data);
     // Create default configuration group
-    var defaultConfigGroupHosts = App.cache['HostsList'];
     var selectedConfigGroup;
     var siteToTagMap = {};
+    var hostsLength = App.router.get('mainHostController.hostsCountMap.TOTAL');
     serviceConfigsDef.sites.forEach(function(siteName){
       if(data.Clusters.desired_configs[siteName]){
         siteToTagMap[siteName] = data.Clusters.desired_configs[siteName].tag;
@@ -253,9 +253,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
               hosts: groupHosts,
               configSiteTags: []
             });
-            groupHosts.forEach(function (host) {
-              defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
-            }, this);
+            hostsLength -= groupHosts.length;
             item.desired_configs.forEach(function (config) {
               newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
                 site: config.type,
@@ -276,7 +274,9 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       name: App.Service.DisplayNames[serviceName] + " Default",
       description: "Default cluster level " + serviceName + " configuration",
       isDefault: true,
-      hosts: defaultConfigGroupHosts,
+      hosts: {
+        length: hostsLength
+      },
       parentConfigGroup: null,
       service: this.get('content'),
       serviceName: serviceName,

+ 11 - 2
ambari-web/app/utils/config.js

@@ -1292,12 +1292,21 @@ App.config = Em.Object.create({
       }.property('selectedConfigGroup'),
       onPrimary: function () {
         var newGroup = this.get('selectedConfigGroup');
-        selectedGroup.get('hosts').removeObject(hostName);
+        if (selectedGroup.get('isDefault')) {
+          selectedGroup.set('hosts.length', selectedGroup.get('hosts.length') - 1)
+        } else {
+          selectedGroup.get('hosts').removeObject(hostName);
+        }
         if (!selectedGroup.get('isDefault')) {
           self.updateConfigurationGroup(selectedGroup, function () {
           }, Em.K);
         }
-        newGroup.get('hosts').pushObject(hostName);
+
+        if (newGroup.get('isDefault')) {
+          newGroup.set('hosts.length', newGroup.get('hosts.length') + 1)
+        } else {
+          newGroup.get('hosts').pushObject(hostName);
+        }
         callback(newGroup);
         if (!newGroup.get('isDefault')) {
           self.updateConfigurationGroup(newGroup, function () {