Repository: ambari Updated Branches: refs/heads/branch-2.0.maint b66a5bcd9 -> f5d0397f2
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/f5d0397f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f5d0397f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f5d0397f Branch: refs/heads/branch-2.0.maint Commit: f5d0397f2fbbbf6f0fb0d1eaed7b0c7e67cdd073 Parents: b66a5bc Author: Yusaku Sako <[email protected]> Authored: Sun May 17 06:04:57 2015 -0700 Committer: Yusaku Sako <[email protected]> Committed: Sun May 17 06:06:29 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/f5d0397f/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 ffd0d4b..918071a 100644 --- a/ambari-web/app/mixins/common/serverValidator.js +++ b/ambari-web/app/mixins/common/serverValidator.js @@ -141,16 +141,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/f5d0397f/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 24e9749..bfda3a3 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':'',
