Repository: ambari Updated Branches: refs/heads/trunk c23de40d3 -> 45f0cd3f8
AMBARI-11194. UI calls to /validations fails due to empty host-to-component mappings on large clusters. (srimanth via yusaku) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/45f0cd3f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/45f0cd3f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/45f0cd3f Branch: refs/heads/trunk Commit: 45f0cd3f870a41dea9a185d85c577bb71aa918f6 Parents: c23de40 Author: Yusaku Sako <[email protected]> Authored: Sun May 17 06:04:57 2015 -0700 Committer: Yusaku Sako <[email protected]> Committed: Sun May 17 06:04:57 2015 -0700 ---------------------------------------------------------------------- ambari-web/app/mixins/common/serverValidator.js | 39 +++++++++++++++++++- ambari-web/app/utils/ajax/ajax.js | 5 +++ 2 files changed, 43 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/45f0cd3f/ambari-web/app/mixins/common/serverValidator.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/serverValidator.js b/ambari-web/app/mixins/common/serverValidator.js index 8854985..8ee28ef 100644 --- a/ambari-web/app/mixins/common/serverValidator.js +++ b/ambari-web/app/mixins/common/serverValidator.js @@ -152,16 +152,53 @@ App.ServerValidatorMixin = Em.Mixin.create({ serverSideValidation: function () { var deferred = $.Deferred(); + var self = this; this.set('configValidationFailed', false); this.set('configValidationGlobalMessage', []); if (this.get('configValidationFailed')) { this.warnUser(deferred); } else { - this.runServerSideValidation(deferred); + if (this.get('isInstaller')) { + this.runServerSideValidation(deferred); + } else { + // on Service Configs page we need to load all hosts with componnets + this.getAllHostsWithComponents().then(function(data) { + self.set('content.recommendationsHostGroups', blueprintUtils.generateHostGroups(App.get('allHostNames'), self.mapHostsToComponents(data.items))); + self.runServerSideValidation(deferred); + }); + } } return deferred; }, + getAllHostsWithComponents: function() { + return App.ajax.send({ + sender: this, + name: 'common.hosts.all', + data: { + urlParams: 'fields=HostRoles/component_name,HostRoles/host_name' + } + }); + }, + + /** + * Generate array similar to App.HostComponent which will be used to + * create blueprint hostGroups object as well. + * + * @param {Object[]} jsonData + * @returns {Em.Object[]} + */ + mapHostsToComponents: function(jsonData) { + var result = []; + jsonData.forEach(function(item) { + result.push(Em.Object.create({ + componentName: Em.get(item, 'HostRoles.component_name'), + hostName: Em.get(item, 'HostRoles.host_name') + })); + }); + return result; + }, + /** * @method serverSideValidation * send request to validate configs http://git-wip-us.apache.org/repos/asf/ambari/blob/45f0cd3f/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 dab402d..77d6ea5 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -159,6 +159,11 @@ var urls = { } }, + 'common.hosts.all': { + 'real': '/clusters/{clusterName}/host_components?{urlParams}&minimal_response=true', + 'mock': '' + }, + 'common.service.configurations': { 'real':'/clusters/{clusterName}', 'mock':'',
