ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject git commit: AMBARI-6252 Service Configs page loads too slow on 2k node cluster (Buzhor Denys via ababiichuk)
Date Tue, 24 Jun 2014 11:30:45 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 9643d12e9 -> 38ebe28c9


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


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

Branch: refs/heads/branch-1.6.1
Commit: 38ebe28c94e6d018e5d06d04b1685526be163d61
Parents: 9643d12
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Tue Jun 24 14:30:38 2014 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Tue Jun 24 14:30:38 2014 +0300

----------------------------------------------------------------------
 .../controllers/global/cluster_controller.js    |  19 +++
 .../controllers/main/service/info/configs.js    | 137 +++++++++----------
 .../service/manage_config_groups_controller.js  |   1 +
 ambari-web/app/mappers/hosts_mapper.js          |   2 -
 ambari-web/app/utils/ajax/ajax.js               |  10 ++
 5 files changed, 96 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/38ebe28c/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 699548a..b52cbe4 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -233,6 +233,24 @@ 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
    */
@@ -240,6 +258,7 @@ App.ClusterController = Em.Controller.extend({
     var self = this;
     this.loadAmbariProperties();
     this.loadAmbariViews();
+    this.loadAllHostNames();
     if (!this.get('clusterName')) {
       return;
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/38ebe28c/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 098e1c6..f7d4fbd 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -199,13 +199,27 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       sender: this,
       data: {
         serviceName: this.get('content.serviceName'),
-        serviceConfigsDef: this.get('serviceConfigs').findProperty('serviceName', this.get('content.serviceName'))
+        serviceConfigsDef: this.get('serviceConfigs').findProperty('serviceName', this.get('content.serviceName')),
+        urlParams: "&config_groups/ConfigGroup/tag=" + this.get('content.serviceName')
       },
-      success: 'loadServiceTagsSuccess'
+      success: 'loadServiceConfigsSuccess'
     });
   },
 
-  loadServiceTagsSuccess: function (data, opt, params) {
+  loadServiceConfigsSuccess: function(data, opt, params) {
+    if (data) {
+      this.setConfigGroups.apply(this, Array.prototype.slice.call(arguments, 0));
+    } else {
+      App.ajax.send({
+        name: 'config.tags',
+        sender: this,
+        data: App.permit(params, ['clusterName', 'serviceConfigsDef', 'serviceName']),
+        success: 'setConfigGroups'
+      });
+    }
+  },
+
+  setConfigGroups: function (data, opt, params) {
     var serviceConfigsDef = params.serviceConfigsDef;
     var serviceName = this.get('content.serviceName');
     console.debug("loadServiceConfigs(): data=", data);
@@ -224,7 +238,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     //parse loaded config groups
     if (App.supports.hostOverrides) {
       var configGroups = [];
-      if (data.config_groups.length) {
+      if (data.config_groups && data.config_groups.length) {
         data.config_groups.forEach(function (item) {
           item = item.ConfigGroup;
           if (item.tag === this.get('content.serviceName')) {
@@ -414,25 +428,37 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
   getInfoForDefaults: function() {
 
     App.ajax.send({
-      name: 'host_components.all',
+      name: 'hosts.config_groups',
       sender: this,
       data: {
         clusterName: App.get('clusterName')
       },
-      success: 'slavesSuccessCallback'
+      success: 'configGroupsHostsSuccessCallback'
     });
+  },
 
+  configGroupsHostsSuccessCallback: function(response) {
+    this.set('defaultsInfo', {
+      masterComponentHosts: this.getMasterComponents(response),
+      slaveComponentHosts: this.getSlaveComponents(response),
+      hosts: this.getHostsInfo(response)
+    });
   },
 
-  slavesSuccessCallback: function (response) {
-    var slaveComponentHosts = [];
-    var slaves = response.items.mapProperty('HostRoles').filter(function (c) {
-      return App.StackServiceComponent.find().findProperty('componentName', c.component_name).get('isSlave');
-    }).map(function(item) {
-      return Em.Object.create({
-        host: item.host_name,
-        componentName: item.component_name
+  getSlaveComponents: function (response) {
+    var slaveComponentHosts = [],
+        slaves = [];
+    response.items.forEach(function(item) {
+      var hostName = item.Hosts.host_name;
+      var _slaves = item.host_components.mapProperty('HostRoles.component_name').filter(function(componentName)
{
+        return App.StackServiceComponent.find().findProperty('componentName', componentName).get('isSlave');
+      }).map(function(componentName) {
+        return Em.Object.create({
+          host: hostName,
+          componentName: componentName
+        });
       });
+      slaves = slaves.concat(_slaves);
     });
     slaves.forEach(function(slave) {
       var s = slaveComponentHosts.findProperty('componentName', slave.componentName);
@@ -446,45 +472,30 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
         });
       }
     });
-
-    App.ajax.send({
-      name: 'host_components.with_services_names',
-      sender: this,
-      data: {
-        clusterName: App.get('clusterName'),
-        slaveComponentHosts: slaveComponentHosts
-      },
-      success: 'mastersSuccessCallback'
-    });
-
-  },
-
-  mastersSuccessCallback: function (response, request, data) {
-
-    var masterComponentHosts = response.items.filter(function (c) {
-      return App.StackServiceComponent.find().findProperty('componentName', c.HostRoles.component_name).get('isMaster');
-    }).map(function(item) {
-      return {
-        component: item.HostRoles.component_name,
-        serviceId: item.component[0].ServiceComponentInfo.service_name,
-        host: item.HostRoles.host_name
-      }
-    });
-
-    App.ajax.send({
-      name: 'hosts.confirmed',
-      sender: this,
-      data: {
-        clusterName: App.get('clusterName'),
-        masterComponentHosts: masterComponentHosts,
-        slaveComponentHosts: data.slaveComponentHosts
-      },
-      success: 'hostsSuccessCallback'
+    return slaveComponentHosts;
+  },
+
+  getMasterComponents: function (response) {
+    var serviceMasterComponents = this.get('content.hostComponents').filterProperty('isMaster',
true).mapProperty('componentName').uniq(),
+        masterComponentHosts = [],
+        _this = this;
+    response.items.forEach(function(item) {
+      var hostName = item.Hosts.host_name;
+      item.host_components.mapProperty('HostRoles.component_name').forEach(function(componentName)
{
+        if (serviceMasterComponents.contains(componentName)) {
+          masterComponentHosts.push({
+            component: componentName,
+            serviceId: _this.get('content.serviceName'),
+            host: hostName
+          });
+        }
+      });
     });
 
+    return masterComponentHosts;
   },
 
-  hostsSuccessCallback: function (response, request, data) {
+  getHostsInfo: function (response) {
     var hosts = {};
     response.items.mapProperty('Hosts').map(function(host) {
       hosts[host.host_name] = {
@@ -494,28 +505,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
         disk_info: host.disk_info
       };
     });
-    var obj =  {
-      masterComponentHosts: [],
-      slaveComponentHosts: [],
-      hosts: hosts
-    };
-    lazyLoading.run({
-      initSize: 20,
-      chunkSize: 50,
-      delay: 50,
-      destination: obj.masterComponentHosts,
-      source: data.masterComponentHosts,
-      context: Em.Object.create()
-    });
-    lazyLoading.run({
-      initSize: 20,
-      chunkSize: 50,
-      delay: 50,
-      destination: obj.slaveComponentHosts,
-      source: obj.slaveComponentHosts,
-      context: Em.Object.create()
-    });
-    this.set('defaultsInfo', obj);
+
+    return hosts;
   },
 
   /**
@@ -584,6 +575,10 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
   setRecommendedDefaults: function (advancedConfigs) {
     var s = this.get('serviceConfigsData').findProperty('serviceName', this.get('content.serviceName'));
     var dfd = $.Deferred();
+    if (!s.defaultsProviders) {
+      dfd.resolve();
+      return dfd.promise();
+    }
     this.getInfoForDefaults();
     this.addObserver('defaultsInfo.hosts.length', this, function() {
       var localDB = this.get('defaultsInfo');

http://git-wip-us.apache.org/repos/asf/ambari/blob/38ebe28c/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 da34a6f..d99c8ab 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
@@ -103,6 +103,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({
           memory: host.Hosts.total_mem,
           diskTotal: host.metrics.disk.disk_total,
           diskFree: host.metrics.disk.disk_free,
+          disksMounted: host.Hosts.disk_info.length,
           hostComponents: hostComponents
         }
       ));

http://git-wip-us.apache.org/repos/asf/ambari/blob/38ebe28c/ambari-web/app/mappers/hosts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/hosts_mapper.js b/ambari-web/app/mappers/hosts_mapper.js
index a32d6c1..cadf519 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -69,9 +69,7 @@ App.hostsMapper = App.QuickDataMapper.create({
       var hostsWithFullInfo = [];
       var hostIds = {};
       var components = [];
-      App.cache['HostsList'] = [];
       json.items.forEach(function (item, index) {
-        App.cache['HostsList'].push(item.Hosts.host_name);
         item.host_components = item.host_components || [];
         item.host_components.forEach(function (host_component) {
           host_component.id = host_component.HostRoles.component_name + "_" + item.Hosts.host_name;

http://git-wip-us.apache.org/repos/asf/ambari/blob/38ebe28c/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 45e9ae4..e95e804 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2171,6 +2171,16 @@ var urls = {
   'hosts.config_groups': {
     'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem,Hosts/ip,Hosts/os_type,Hosts/os_arch,Hosts/public_host_name,metrics/disk,host_components&minimal_response=true',
     'mock': ''
+  },
+  'cluster.fields': {
+    real: '/clusters/{clusterName}?fields={fields}',
+    mock: '',
+    format: function(data) {
+      return {
+        async: true,
+        fields: data.fields.join(',')
+      }
+    }
   }
 };
 /**


Mime
View raw message