Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6F347200B89 for ; Wed, 21 Sep 2016 12:33:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6DA07160ADB; Wed, 21 Sep 2016 10:33:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 64DAC160ACF for ; Wed, 21 Sep 2016 12:33:43 +0200 (CEST) Received: (qmail 72671 invoked by uid 500); 21 Sep 2016 10:33:42 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 72662 invoked by uid 99); 21 Sep 2016 10:33:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Sep 2016 10:33:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5BB39E09AC; Wed, 21 Sep 2016 10:33:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: akovalenko@apache.org To: commits@ambari.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-18424. Core-site should be provided for every stack advisor call (e.g. when deleting services) (akovalenko) Date: Wed, 21 Sep 2016 10:33:42 +0000 (UTC) archived-at: Wed, 21 Sep 2016 10:33:44 -0000 Repository: ambari Updated Branches: refs/heads/trunk 20997630d -> 04b4dc2a5 AMBARI-18424. Core-site should be provided for every stack advisor call (e.g. when deleting services) (akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/04b4dc2a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/04b4dc2a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/04b4dc2a Branch: refs/heads/trunk Commit: 04b4dc2a5d57f9b092ae336c2ba089c259b8a56e Parents: 2099763 Author: Aleksandr Kovalenko Authored: Tue Sep 20 18:04:10 2016 +0300 Committer: Aleksandr Kovalenko Committed: Wed Sep 21 13:33:23 2016 +0300 ---------------------------------------------------------------------- .../resourceManager/step3_controller.js | 1 - .../mixins/common/configs/enhanced_configs.js | 24 +++--- ambari-web/app/mixins/common/serverValidator.js | 7 +- ambari-web/app/utils/ajax/ajax.js | 4 +- ambari-web/app/utils/blueprint.js | 10 +-- ambari-web/app/utils/config.js | 45 ++++++----- .../common/configs/enhanced_configs_test.js | 79 +++----------------- 7 files changed, 60 insertions(+), 110 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/04b4dc2a/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js index 36dcfb8..08e0b73 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step3_controller.js @@ -182,7 +182,6 @@ App.RMHighAvailabilityWizardStep3Controller = Em.Controller.extend(App.Blueprint }, loadRecommendations: function(blueprintConfigurations) { - var dfd = $.Deferred(); var blueprint = this.getCurrentMasterSlaveBlueprint(); // host group where new ResourceManager will be added var hostGroupName = blueprintUtils.getHostGroupByFqdn(blueprint, this.get('content.rmHosts.additionalRM')); http://git-wip-us.apache.org/repos/asf/ambari/blob/04b4dc2a/ambari-web/app/mixins/common/configs/enhanced_configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/configs/enhanced_configs.js b/ambari-web/app/mixins/common/configs/enhanced_configs.js index a99d835..f53b45d 100644 --- a/ambari-web/app/mixins/common/configs/enhanced_configs.js +++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js @@ -179,17 +179,26 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP loadConfigRecommendations: function (changedConfigs, onComplete) { var updateDependencies = Em.isArray(changedConfigs) && changedConfigs.length > 0; var stepConfigs = this.get('stepConfigs'); + var requiredTags = []; if (updateDependencies || Em.isNone(this.get('recommendationsConfigs'))) { var recommendations = this.get('hostGroups'); var dataToSend = this.getConfigRecommendationsParams(updateDependencies, changedConfigs); this.modifyRecommendationConfigGroups(recommendations); - if (stepConfigs.someProperty('serviceName', 'MISC')) { + if (!stepConfigs.someProperty('serviceName', 'MISC')) { + requiredTags.push({site: 'cluster-env', serviceName: 'MISC'}); + } + + if (App.Service.find().someProperty('serviceName', 'HDFS') && !stepConfigs.someProperty('serviceName', 'HDFS')) { + requiredTags.push({site: 'core-site', serviceName: 'HDFS'}); + } + + if (requiredTags.length) { + this.loadAdditionalSites(requiredTags, stepConfigs, recommendations, dataToSend, onComplete); + } else { this.addRecommendationRequestParams(recommendations, dataToSend, stepConfigs); return this.getRecommendationsRequest(dataToSend, onComplete); - } else { - this.requestRecommendationsWithEnv(stepConfigs, recommendations, dataToSend, onComplete); } } else { if (onComplete) { @@ -217,13 +226,10 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP * @param {object} dataToSend * @param {Function} onComplete */ - requestRecommendationsWithEnv: function(stepConfigs, recommendations, dataToSend, onComplete) { + loadAdditionalSites: function(sites, stepConfigs, recommendations, dataToSend, onComplete) { var self = this; - App.config.getClusterEnvConfigs().done(function (clusterEnvConfigs) { - stepConfigs = stepConfigs.concat(Em.Object.create({ - serviceName: 'MISC', - configs: clusterEnvConfigs - })); + App.config.getConfigsByTypes(sites).done(function (configs) { + stepConfigs = stepConfigs.concat(configs); self.addRecommendationRequestParams(recommendations, dataToSend, stepConfigs); self.getRecommendationsRequest(dataToSend, onComplete); http://git-wip-us.apache.org/repos/asf/ambari/blob/04b4dc2a/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 9fb5ae3..d8747d3 100644 --- a/ambari-web/app/mixins/common/serverValidator.js +++ b/ambari-web/app/mixins/common/serverValidator.js @@ -153,11 +153,8 @@ App.ServerValidatorMixin = Em.Mixin.create({ // check if we have configs from 'cluster-env', if not, then load them, as they are mandatory for validation request if (!stepConfigs.findProperty('serviceName', 'MISC')) { - App.config.getClusterEnvConfigs().done(function(clusterEnvConfigs){ - stepConfigs = stepConfigs.concat(Em.Object.create({ - serviceName: 'MISC', - configs: clusterEnvConfigs - })); + App.config.getConfigsByTypes([{site: 'cluster-env', serviceName: 'MISC'}]).done(function (configs) { + stepConfigs = stepConfigs.concat(configs); dfd.resolve(blueprintUtils.buildConfigsJSON(stepConfigs)); }); } else { http://git-wip-us.apache.org/repos/asf/ambari/blob/04b4dc2a/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 70c73be..7eb9c9e 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -850,8 +850,8 @@ var urls = { 'mock': '/data/configurations/host_level_overrides_configs.json?{params}' }, - 'config.cluster_env_site': { - 'real': '/clusters/{clusterName}/configurations?type=cluster-env', + 'config.tags.selected': { + 'real': '/clusters/{clusterName}/configurations?type.in({tags})', 'mock': '/data/configuration/cluster_env_site.json' }, http://git-wip-us.apache.org/repos/asf/ambari/blob/04b4dc2a/ambari-web/app/utils/blueprint.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/blueprint.js b/ambari-web/app/utils/blueprint.js index 696f7a4..1148d3d 100644 --- a/ambari-web/app/utils/blueprint.js +++ b/ambari-web/app/utils/blueprint.js @@ -320,13 +320,11 @@ module.exports = { var configurations = {}; stepConfigs.forEach(function (stepConfig) { stepConfig.get('configs').forEach(function (config) { - if (config.get('filename') === 'cluster-env.xml' || config.get('isRequiredByAgent')) { - var type = App.config.getConfigTagFromFileName(config.get('filename')); - if (!configurations[type]) { - configurations[type] = {properties: {}} - } - configurations[type]['properties'][config.get('name')] = config.get('value'); + var type = App.config.getConfigTagFromFileName(config.get('filename')); + if (!configurations[type]) { + configurations[type] = {properties: {}} } + configurations[type]['properties'][config.get('name')] = config.get('value'); }); }); return configurations; http://git-wip-us.apache.org/repos/asf/ambari/blob/04b4dc2a/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index ae09b82..abb2fbf 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -1287,28 +1287,37 @@ App.config = Em.Object.create({ * Load cluster-env configs mapped to array * @return {*|{then}} */ - getClusterEnvConfigs: function () { + getConfigsByTypes: function (sites) { var dfd = $.Deferred(); App.ajax.send({ - name: 'config.cluster_env_site', - sender: this + name: 'config.tags.selected', + sender: this, + data: { + tags: sites.mapProperty('site').join(',') + } }).done(function (data) { - App.router.get('configurationController').getConfigsByTags([{ - siteName: data.items[data.items.length - 1].type, - tagName: data.items[data.items.length - 1].tag - }]).done(function (clusterEnvConfigs) { - var configsObject = clusterEnvConfigs[0].properties; - var configsArray = []; - for (var property in configsObject) { - if (configsObject.hasOwnProperty(property)) { - configsArray.push(Em.Object.create({ - name: property, - value: configsObject[property], - filename: 'cluster-env.xml' - })); + App.router.get('configurationController').getConfigsByTags(data.items.map(function (item) { + return {siteName: item.type, tagName: item.tag}; + })).done(function (configs) { + var result = []; + configs.forEach(function(config){ + var configsArray = []; + var configsObject = config.properties; + for (var property in configsObject) { + if (configsObject.hasOwnProperty(property)) { + configsArray.push(Em.Object.create({ + name: property, + value: configsObject[property], + filename: App.config.getOriginalFileName(config.type) + })); + } } - } - dfd.resolve(configsArray); + result.push(Em.Object.create({ + serviceName: sites.findProperty('site', config.type).serviceName, + configs: configsArray + })); + }); + dfd.resolve(result); }); }); return dfd.promise(); http://git-wip-us.apache.org/repos/asf/ambari/blob/04b4dc2a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js index 79a7ef7..a9c9770 100644 --- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js +++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js @@ -164,60 +164,6 @@ describe('App.EnhancedConfigsMixin', function () { }); }); - describe("#loadConfigRecommendations", function () { - var mixinInstance; - - beforeEach(function () { - mixinInstance = mixinClass.create({ - recommendationsConfigs: {}, - stepConfigs: [], - hostGroups: { - blueprint: { - configurations: {} - } - } - }); - this.mockedCallback = sinon.stub(); - sinon.stub(App.config, 'getClusterEnvConfigs').returns({ - done: function (callback) { - callback([]); - } - }); - }); - - afterEach(function () { - App.config.getClusterEnvConfigs.restore(); - }); - - it("should call callback if changedConfigs is empty array", function () { - mixinInstance.loadConfigRecommendations([], this.mockedCallback); - expect(testHelpers.findAjaxRequest('name', 'config.recommendations')).to.not.exist; - expect(this.mockedCallback.calledOnce).to.be.true; - }); - - it("should call callback from ajax callback if changedConfigs is not empty", function () { - mixinInstance.loadConfigRecommendations([{}], this.mockedCallback); - var args = testHelpers.findAjaxRequest('name', 'config.recommendations'); - expect(args[0]).exists; - args[0].callback(); - expect(this.mockedCallback.calledOnce).to.be.true; - }); - - it("should call getClusterEnvConfigs if there is no cluster-env configs in stepConfigs", function () { - mixinInstance.loadConfigRecommendations([{}]); - expect(App.config.getClusterEnvConfigs.calledOnce).to.be.true; - }); - - it("should not call getClusterEnvConfigs if there is cluster-env configs in stepConfigs", function () { - mixinInstance.set('stepConfigs', [Em.Object.create({ - serviceName: 'MISC', - configs: [] - })]); - mixinInstance.loadConfigRecommendations([{}]); - expect(App.config.getClusterEnvConfigs.calledOnce).to.be.false; - }); - }); - describe("#changedDependentGroup", function () { var mixinInstance; @@ -559,7 +505,7 @@ describe('App.EnhancedConfigsMixin', function () { sinon.stub(mixin, 'modifyRecommendationConfigGroups'); sinon.stub(mixin, 'addRecommendationRequestParams'); sinon.stub(mixin, 'getRecommendationsRequest'); - sinon.stub(mixin, 'requestRecommendationsWithEnv'); + sinon.stub(mixin, 'loadAdditionalSites'); }); afterEach(function() { @@ -568,7 +514,7 @@ describe('App.EnhancedConfigsMixin', function () { mixin.modifyRecommendationConfigGroups.restore(); mixin.addRecommendationRequestParams.restore(); mixin.getRecommendationsRequest.restore(); - mixin.requestRecommendationsWithEnv.restore(); + mixin.loadAdditionalSites.restore(); }); it("changedConfigs is null", function() { @@ -589,7 +535,7 @@ describe('App.EnhancedConfigsMixin', function () { mixin.loadConfigRecommendations([], mock.onComplete); expect(mixin.getConfigRecommendationsParams.calledWith(false)).to.be.true; expect(mixin.modifyRecommendationConfigGroups.calledOnce).to.be.true; - expect(mixin.requestRecommendationsWithEnv.calledOnce).to.be.true; + expect(mixin.loadAdditionalSites.calledOnce).to.be.true; }); it("changedConfigs is correct, MISC service present", function() { @@ -628,34 +574,29 @@ describe('App.EnhancedConfigsMixin', function () { }); }); - describe("#requestRecommendationsWithEnv()", function () { + describe("#loadAdditionalSites()", function () { beforeEach(function() { - sinon.stub(App.config, 'getClusterEnvConfigs').returns({ + sinon.stub(App.config, 'getConfigsByTypes').returns({ done: function(callback) {callback([]);} }); sinon.stub(mixin, 'addRecommendationRequestParams'); sinon.stub(mixin, 'getRecommendationsRequest'); - mixin.requestRecommendationsWithEnv([], {}, {}, Em.K); + mixin.loadAdditionalSites([], [], {}, {}, Em.K); }); afterEach(function() { - App.config.getClusterEnvConfigs.restore(); + App.config.getConfigsByTypes.restore(); mixin.addRecommendationRequestParams.restore(); mixin.getRecommendationsRequest.restore(); }); - it("App.config.getClusterEnvConfigs should be called", function() { - expect(App.config.getClusterEnvConfigs.calledOnce).to.be.true; + it("App.config.getConfigsByTypes should be called", function() { + expect(App.config.getConfigsByTypes.calledOnce).to.be.true; }); it("addRecommendationRequestParams should be called", function() { - expect(mixin.addRecommendationRequestParams.calledWith({}, {}, [ - Em.Object.create({ - serviceName: 'MISC', - configs: [] - }) - ])).to.be.true; + expect(mixin.addRecommendationRequestParams.calledWith({}, {}, [])).to.be.true; }); it("getRecommendationsRequest should be called", function() {