Repository: ambari Updated Branches: refs/heads/trunk 9c39acb06 -> 09aef90eb
AMBARI-6418 Config pages load slowly on 2k-node cluster for some services. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/09aef90e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/09aef90e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/09aef90e Branch: refs/heads/trunk Commit: 09aef90ebd300e78ff65c0002387bb48cca3a058 Parents: 9c39acb Author: atkach <atk...@hortonworks.com> Authored: Tue Jul 8 17:55:42 2014 +0300 Committer: atkach <atk...@hortonworks.com> Committed: Tue Jul 8 17:55:42 2014 +0300 ---------------------------------------------------------------------- .../controllers/main/service/info/configs.js | 185 ++++++++----------- ambari-web/app/data/global_properties.js | 4 +- ambari-web/app/utils/ajax/ajax.js | 12 +- .../defaults_providers/defaultsProvider.js | 9 + .../yarn_defaults_provider.js | 4 +- 5 files changed, 91 insertions(+), 123 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/09aef90e/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 c137e5c..ee1336f 100644 --- a/ambari-web/app/controllers/main/service/info/configs.js +++ b/ambari-web/app/controllers/main/service/info/configs.js @@ -430,133 +430,95 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ * Get info about hosts and host components to configDefaultsProviders * @returns {{masterComponentHosts: Array, slaveComponentHosts: Array, hosts: {}}} */ - getInfoForDefaults: function() { - App.ajax.send({ - name: 'hosts.basic_info', - sender: this, - data: { - clusterName: App.get('clusterName') - }, - success: 'configGroupsHostsSuccessCallback' + getInfoForDefaults: function(providers) { + var requiredComponents = []; + + providers.forEach(function (provider) { + requiredComponents = provider.get('slaveHostDependency').concat(provider.get('masterHostDependency')); }); - }, - configGroupsHostsSuccessCallback: function(response) { - // We load only basic host information. We do not load all host-components. - // Since some default providers need certain host-components, we load them - // very specifically on a need basis, and merge into 'response' parameter. - var mergeComponentResponse = function(componentResponse){ - if(response && response.items && componentResponse && - componentResponse.items && componentResponse.items.length > 0) { - componentResponse.items.forEach(function(nmHost){ - var nmHostName = nmHost.Hosts.host_name; - response.items.forEach(function(host) { - if (nmHostName == host.Hosts.host_name) { - host.host_components = nmHost.host_components; - } - }); - }); - } + if (requiredComponents.length > 0) { + App.ajax.send({ + name: 'hosts.by_component.' + ((requiredComponents.length === 1) ? 'one' : 'all'), + sender: this, + data: { + componentNames: requiredComponents.join(',') + }, + success: 'getInfoForDefaultsSuccessCallback' + }); + } else { + //if no components required then slaveComponentHosts and hosts stay empty + this.set('defaultsInfo', { + masterComponentHosts: this.getMasterComponents(), + slaveComponentHosts: [], + hosts: {} + }); } - var self = this; - var oneComponentCallback = { - success: function(oneComponentResponse) { - mergeComponentResponse(oneComponentResponse); - var allComponentCallback = { - success: function(allComponentResponse) { - mergeComponentResponse(allComponentResponse); - self.set('defaultsInfo', { - masterComponentHosts: self.getMasterComponents(response), - slaveComponentHosts: self.getSlaveComponents(response), - hosts: self.getHostsInfo(response) - }); + }, + + getInfoForDefaultsSuccessCallback: function (response) { + var defaultsInfo = { + masterComponentHosts: this.getMasterComponents(), + slaveComponentHosts: this.getSlaveComponents(response), + hosts: this.getHostsInfo(response) + }; + this.set('defaultsInfo', defaultsInfo); + }, + + /** + * parse json response and build slave components array + * @param response + * @return {Array} + */ + getSlaveComponents: function (response) { + var hostComponentMap = {}; + var slaves = App.StackServiceComponent.find().filterProperty('isSlave').mapProperty('componentName'); + var slaveComponentHosts = []; + + response.items.forEach(function (host) { + host.host_components.forEach(function (hostComponent) { + if (slaves.contains(hostComponent.HostRoles.component_name)) { + if (!hostComponentMap[hostComponent.HostRoles.component_name]) { + hostComponentMap[hostComponent.HostRoles.component_name] = []; } + hostComponentMap[hostComponent.HostRoles.component_name].push({hostName: host.Hosts.host_name}); } - App.ajax.send({ - name: 'hosts.all_components_of_type', - sender: allComponentCallback, - data: { - clusterName: App.get('clusterName'), - componentNames: ['HBASE_MASTER', 'FALCON_SERVER'].join(',') - }, - success: 'success' - }); - } - } - App.ajax.send({ - name: 'hosts.one_component_of_type', - sender: oneComponentCallback, - data: { - clusterName: App.get('clusterName'), - componentNames: ['NODEMANAGER'].join(',') - }, - success: 'success' + }) }); - }, - getSlaveComponents: function (response) { - var slaveComponentHosts = [], - slaves = []; - response.items.forEach(function(item) { - var hostName = item.Hosts.host_name; - if (!item.host_components) { - return; - } - 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 - }); + for (var componentName in hostComponentMap) { + slaveComponentHosts.push({ + componentName: componentName, + hosts: hostComponentMap[componentName] }); - slaves = slaves.concat(_slaves); - }); - slaves.forEach(function(slave) { - var s = slaveComponentHosts.findProperty('componentName', slave.componentName); - if (s) { - s.hosts.push({hostName: slave.host}); - } - else { - slaveComponentHosts.push({ - componentName: slave.get('componentName'), - hosts: [{hostName: slave.host}] - }); - } - }); + } return slaveComponentHosts; }, - getMasterComponents: function (response) { - var masterComponentNames = App.StackServiceComponent.find().filterProperty('isMaster', true).mapProperty('componentName'); - // For default config value calculation and validation, a service - // might need the master from another service. For example, YARN - // default configurations depend on HBASE_MASTER component being - // installed. So we need to provide all masters that are required - // for config default/validation calculations. - var masterComponentHosts = [], - _this = this; - response.items.forEach(function(item) { - var hostName = item.Hosts.host_name; - if (!item.host_components) { - return; - } - item.host_components.mapProperty('HostRoles.component_name').forEach(function(componentName) { - if (masterComponentNames.contains(componentName)) { - masterComponentHosts.push({ - component: componentName, - serviceId: _this.get('content.serviceName'), - host: hostName - }); - } + /** + * build master components array of data from HostComponent model + * @return {Array} + */ + getMasterComponents: function () { + var masterComponentHosts = []; + + App.HostComponent.find().filterProperty('isMaster').forEach(function (masterComponent) { + masterComponentHosts.push({ + component: masterComponent.get('componentName'), + serviceId: masterComponent.get('service.serviceName'), + host: masterComponent.get('hostName') }); }); - return masterComponentHosts; }, - + /** + * parse json response and build hosts map + * @param response + * @return {Object} + */ getHostsInfo: function (response) { var hosts = {}; + response.items.mapProperty('Hosts').map(function(host) { hosts[host.host_name] = { name: host.host_name, @@ -565,7 +527,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ disk_info: host.disk_info }; }); - return hosts; }, @@ -639,7 +600,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({ dfd.resolve(); return dfd.promise(); } - this.getInfoForDefaults(); + this.getInfoForDefaults(s.defaultsProviders); this.addObserver('defaultsInfo.hosts.length', this, function() { var localDB = this.get('defaultsInfo'); var recommendedDefaults = {}; http://git-wip-us.apache.org/repos/asf/ambari/blob/09aef90e/ambari-web/app/data/global_properties.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/data/global_properties.js b/ambari-web/app/data/global_properties.js index 501fbfc..9a97b22 100644 --- a/ambari-web/app/data/global_properties.js +++ b/ambari-web/app/data/global_properties.js @@ -696,8 +696,8 @@ module.exports = }, { displayName: 'Existing PostgreSQL Database', - foreignKeys: ['hive_existing_postgresql_database', 'hive_existing_postgresql_host'], - }, + foreignKeys: ['hive_existing_postgresql_database', 'hive_existing_postgresql_host'] + }, { displayName: 'Existing Oracle Database', foreignKeys: ['hive_existing_oracle_database', 'hive_existing_oracle_host'], http://git-wip-us.apache.org/repos/asf/ambari/blob/09aef90e/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 b84702a..3396ac0 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -1698,16 +1698,12 @@ var urls = { } } }, - 'hosts.basic_info': { - '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&minimal_response=true', + 'hosts.by_component.one': { + 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name.in({componentNames})&fields=host_components,Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem,Hosts/ip,Hosts/os_type,Hosts/os_arch,Hosts/public_host_name&page_size=1&minimal_response=true', 'mock': '' }, - 'hosts.one_component_of_type': { - 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name.in({componentNames})&fields=host_components&page_size=1&minimal_response=true', - 'mock': '' - }, - 'hosts.all_components_of_type': { - 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name.in({componentNames})&fields=host_components&minimal_response=true', + 'hosts.by_component.all': { + 'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name.in({componentNames})&fields=host_components,Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem,Hosts/ip,Hosts/os_type,Hosts/os_arch,Hosts/public_host_name&minimal_response=true', 'mock': '' }, 'hosts.config_groups': { http://git-wip-us.apache.org/repos/asf/ambari/blob/09aef90e/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js b/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js index 1eaad12..fffbea6 100644 --- a/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js +++ b/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js @@ -20,6 +20,15 @@ var App = require('app'); App.DefaultsProvider = Em.Object.extend({ /** + * contains slave components assigned to hosts which has info required by config provider + */ + slaveHostDependency: [], + /** + * contains master components assigned to hosts which has info required by config provider + */ + masterHostDependency: [], + + /** * Look at cluster setup, the provided properties, and provide an object where keys are property-names, and values are the recommended defaults * @param {App.ServiceConfigProperty} serviceConfigProperty */ http://git-wip-us.apache.org/repos/asf/ambari/blob/09aef90e/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js b/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js index 37799df..16f5168 100644 --- a/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js +++ b/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js @@ -20,6 +20,8 @@ require('utils/configs/defaults_providers/defaultsProvider'); App.YARNDefaultsProvider = App.DefaultsProvider.extend({ + slaveHostDependency: ['NODEMANAGER'], + /** * List of the configs that should be calculated * @type {Object} @@ -256,7 +258,7 @@ App.YARNDefaultsProvider = App.DefaultsProvider.extend({ */ getClusterData: function (localDB) { this._super(); - var components = ['NODEMANAGER']; + var components = this.get('slaveHostDependency').concat(this.get('masterHostDependency')); var hosts = []; if (!localDB.hosts || !(localDB.masterComponentHosts || localDB.slaveComponentHosts)) return; var hBaseInstalled = !!localDB.masterComponentHosts.filterProperty('component', 'HBASE_MASTER').length;