ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-21497 Conflicts in the ambari config groups. (atkach)
Date Thu, 03 Aug 2017 09:17:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 d322f9d7b -> 83e6f06af


AMBARI-21497 Conflicts in the ambari config groups. (atkach)


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

Branch: refs/heads/branch-2.5
Commit: 83e6f06afba676e2e3adb1aac397dc69cd9456b0
Parents: d322f9d
Author: Andrii Tkach <atkach@apache.org>
Authored: Thu Aug 3 12:16:15 2017 +0300
Committer: Andrii Tkach <atkach@apache.org>
Committed: Thu Aug 3 12:16:15 2017 +0300

----------------------------------------------------------------------
 .../app/mixins/common/configs/configs_saver.js   | 12 +++++++++++-
 .../mixins/common/configs/enhanced_configs.js    | 12 +++++++++++-
 .../mixins/common/configs/configs_saver_test.js  | 19 +++++++++++++++++++
 .../common/configs/enhanced_configs_test.js      | 10 ++++++++++
 4 files changed, 51 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/83e6f06a/ambari-web/app/mixins/common/configs/configs_saver.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js
index 5ceb611..12b6e15 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -149,7 +149,7 @@ App.ConfigsSaverMixin = Em.Mixin.create({
 
           var overriddenConfigs = this.getConfigsForGroup(configs, configGroup.get('name'));
 
-          if (Em.isArray(overriddenConfigs)) {
+          if (Em.isArray(overriddenConfigs) && this.isOverriddenConfigsModified(overriddenConfigs))
{
             var successCallback = this.get('content.serviceName') === serviceName ? 'putConfigGroupChangesSuccess'
: null;
             this.saveGroup(overriddenConfigs, configGroup, this.get('serviceConfigVersionNote'),
successCallback);
           }
@@ -158,6 +158,16 @@ App.ConfigsSaverMixin = Em.Mixin.create({
     }
   },
 
+  /**
+   * @param {Array} overriddenConfigs
+   * @returns {boolean}
+   */
+  isOverriddenConfigsModified: function(overriddenConfigs) {
+    return overriddenConfigs.some(function(config) {
+      return config.get('savedValue') !== config.get('value');
+    });
+  },
+
   /*********************************** 0. HELPERS ********************************************/
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/83e6f06a/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 5668b8c..8b9c673 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -368,7 +368,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
       var configFroGroup = recommendations['config-groups'][0];
       this.get('stepConfigs').forEach(function(stepConfig) {
         var configGroup = this.getGroupForService(stepConfig.get('serviceName'));
-        if (configGroup) {
+        if (configGroup && this.isConfigGroupAffected(configFroGroup.hosts, configGroup.get('hosts')))
{
           this.updateOverridesByRecommendations(configFroGroup.configurations, stepConfig.get('configs'),
changedConfigs, configGroup);
           this.updateOverridesByRecommendations(configFroGroup.dependent_configurations,
stepConfig.get('configs'), changedConfigs, configGroup);
           this.toggleProperty('forceUpdateBoundaries');
@@ -385,6 +385,16 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP
   },
 
   /**
+   * determine whether hosts of group affected by config modifications
+   * @param {Array} affectedHosts
+   * @param {Array} groupHosts
+   * @returns {boolean}
+   */
+  isConfigGroupAffected: function(affectedHosts, groupHosts) {
+    return _.intersection(affectedHosts, groupHosts).length > 0;
+  },
+
+  /**
    * method to show popup with dependent configs
    * @method showChangedDependentConfigs
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/83e6f06a/ambari-web/test/mixins/common/configs/configs_saver_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/configs_saver_test.js b/ambari-web/test/mixins/common/configs/configs_saver_test.js
index 89f08e9..b0258a3 100644
--- a/ambari-web/test/mixins/common/configs/configs_saver_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_saver_test.js
@@ -284,5 +284,24 @@ describe('App.ConfigsSaverMixin', function() {
       expect(instanceObject.getModifiedConfigs(configs).mapProperty('filename').uniq()).to.eql(['f1','f2','f3']);
     });
   });
+
+  describe('#isOverriddenConfigsModified', function() {
+    it('no configs modified', function() {
+      expect(instanceObject.isOverriddenConfigsModified([
+        Em.Object.create({
+          savedValue: '1',
+          value: '1'
+        })
+      ])).to.be.false;
+    });
+    it('one config modified', function() {
+      expect(instanceObject.isOverriddenConfigsModified([
+        Em.Object.create({
+          savedValue: '1',
+          value: '2'
+        })
+      ])).to.be.true;
+    });
+  });
 });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/83e6f06a/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 3a41dc9..acce70d 100644
--- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
+++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
@@ -307,5 +307,15 @@ describe('App.EnhancedConfigsMixin', function() {
       expect(instanceObject.filterRequiredChanges(recommendations)).to.be.eql(recommendations);
     });
   });
+
+  describe('#isConfigGroupAffected', function() {
+    it('groups have no shared hosts', function() {
+      expect(instanceObject.isConfigGroupAffected(['host1'], ['host2'])).to.be.false;
+    });
+    it('groups have shared hosts', function() {
+      expect(instanceObject.isConfigGroupAffected(['host1'], ['host2', 'host1'])).to.be.true;
+    });
+  });
+
 });
 


Mime
View raw message