You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2014/07/16 17:20:03 UTC
git commit: AMBARI-6500. Upgrade creates new configs version even if
there is nothing to update (aonishuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 6cf8fb17d -> 8f2f5bcde
AMBARI-6500. Upgrade creates new configs version even if there is nothing to update (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8f2f5bcd
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8f2f5bcd
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8f2f5bcd
Branch: refs/heads/trunk
Commit: 8f2f5bcde7ee2411cb0e121ee28cb215e7112933
Parents: 6cf8fb1
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Wed Jul 16 18:19:51 2014 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Wed Jul 16 18:19:51 2014 +0300
----------------------------------------------------------------------
.../server/upgrade/AbstractUpgradeCatalog.java | 51 +++++++++++---------
.../server/upgrade/UpgradeCatalogTest.java | 2 +-
2 files changed, 30 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/8f2f5bcd/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
index 2f01d38..4d21d79 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
@@ -17,6 +17,7 @@
*/
package org.apache.ambari.server.upgrade;
+import com.google.common.collect.Maps;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
@@ -202,30 +203,36 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog {
Map<String, Config> all = cluster.getConfigsByType(configType);
if (all == null || !all.containsKey(newTag) || properties.size() > 0) {
+ Map<String, String> oldConfigProperties = oldConfig.getProperties();
+
Map<String, String> mergedProperties =
- mergeProperties(oldConfig.getProperties(), properties, updateIfExists);
-
- LOG.info("Applying configuration with tag '%s' to " +
- "cluster '%s'", newTag, cluster.getClusterName());
-
- ConfigurationRequest cr = new ConfigurationRequest();
- cr.setClusterName(cluster.getClusterName());
- cr.setVersionTag(newTag);
- cr.setType(configType);
- cr.setProperties(mergedProperties);
- controller.createConfiguration(cr);
-
- Config baseConfig = cluster.getConfig(cr.getType(), cr.getVersionTag());
- if (baseConfig != null) {
- String authName = "ambari-upgrade";
-
- if (cluster.addDesiredConfig(authName, baseConfig)) {
- LOG.info("cluster '" + cluster.getClusterName() + "' "
- + "changed by: '" + authName + "'; "
- + "type='" + baseConfig.getType() + "' "
- + "tag='" + baseConfig.getVersionTag() + "'"
- + " from='"+ oldConfig.getVersionTag() + "'");
+ mergeProperties(oldConfigProperties, properties, updateIfExists);
+
+ if (!Maps.difference(oldConfigProperties, mergedProperties).areEqual()) {
+ LOG.info("Applying configuration with tag '%s' to " +
+ "cluster '%s'", newTag, cluster.getClusterName());
+
+ ConfigurationRequest cr = new ConfigurationRequest();
+ cr.setClusterName(cluster.getClusterName());
+ cr.setVersionTag(newTag);
+ cr.setType(configType);
+ cr.setProperties(mergedProperties);
+ controller.createConfiguration(cr);
+
+ Config baseConfig = cluster.getConfig(cr.getType(), cr.getVersionTag());
+ if (baseConfig != null) {
+ String authName = "ambari-upgrade";
+
+ if (cluster.addDesiredConfig(authName, baseConfig)) {
+ LOG.info("cluster '" + cluster.getClusterName() + "' "
+ + "changed by: '" + authName + "'; "
+ + "type='" + baseConfig.getType() + "' "
+ + "tag='" + baseConfig.getVersionTag() + "'"
+ + " from='" + oldConfig.getVersionTag() + "'");
+ }
}
+ } else {
+ LOG.info("No changes detected to config " + configType + ". Skipping configuration properties update");
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/8f2f5bcd/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java
index 322b3f1..79007d5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalogTest.java
@@ -182,7 +182,7 @@ public class UpgradeCatalogTest {
Collections.singletonMap("x", "y"), false);
config = cluster.getDesiredConfigByType("global");
Assert.assertNotNull(config);
- Assert.assertNotSame(version, config.getVersionTag());
+ Assert.assertSame(version, config.getVersionTag());
Assert.assertTrue(config.getProperties().containsKey("x"));
Assert.assertEquals("z", config.getProperties().get("x"));
}