Repository: ambari Updated Branches: refs/heads/branch-2.2 685319d38 -> 7927d3239
AMBARI-14405. RU: Finalize Downgrade failed (ncole) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7927d323 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7927d323 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7927d323 Branch: refs/heads/branch-2.2 Commit: 7927d3239a40bbda352ce33154e2fbe2b3e702d9 Parents: 685319d Author: Nate Cole <[email protected]> Authored: Wed Dec 16 16:11:10 2015 -0500 Committer: Nate Cole <[email protected]> Committed: Wed Dec 16 16:11:10 2015 -0500 ---------------------------------------------------------------------- .../ambari/server/orm/entities/ClusterConfigEntity.java | 4 ++-- .../org/apache/ambari/server/state/cluster/ClusterImpl.java | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7927d323/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java index 607d5fa..7da77e3 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java @@ -222,8 +222,8 @@ public class ClusterConfigEntity { @Override public int hashCode() { - int result = configId != null ? configId.intValue() : 0; - result = 31 * result + (clusterId != null ? clusterId.intValue() : 0); + int result = configId != null ? configId.hashCode() : 0; + result = 31 * result + (clusterId != null ? clusterId.hashCode() : 0); result = 31 * result + (type != null ? type.hashCode() : 0); result = 31 * result + (tag != null ? tag.hashCode() : 0); result = 31 * result + (stack != null ? stack.hashCode() : 0); http://git-wip-us.apache.org/repos/asf/ambari/blob/7927d323/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java index 16f4120..3358e8c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java @@ -22,7 +22,6 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -39,7 +38,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import javax.annotation.Nullable; import javax.persistence.RollbackException; -import com.google.common.collect.Maps; import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.ConfigGroupNotFoundException; import org.apache.ambari.server.DuplicateResourceException; @@ -131,6 +129,7 @@ import com.google.common.base.Predicate; import com.google.common.collect.HashMultimap; import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; +import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import com.google.inject.Inject; @@ -3001,6 +3000,7 @@ public class ClusterImpl implements Cluster { public void applyLatestConfigurations(StackId stackId) { clusterGlobalLock.writeLock().lock(); try { + Collection<ClusterConfigMappingEntity> configMappingEntities = clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId()); // disable previous config @@ -3025,6 +3025,7 @@ public class ClusterImpl implements Cluster { clusterDAO.mergeConfigMappings(configMappingEntities); + refresh(); cacheConfigurations(); } finally { clusterGlobalLock.writeLock().unlock(); @@ -3090,6 +3091,7 @@ public class ClusterImpl implements Cluster { // remove config mappings Collection<ClusterConfigMappingEntity> configMappingEntities = clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId()); + for (ClusterConfigEntity removedClusterConfig : removedClusterConfigs) { String removedClusterConfigType = removedClusterConfig.getType(); String removedClusterConfigTag = removedClusterConfig.getTag(); @@ -3118,6 +3120,9 @@ public class ClusterImpl implements Cluster { public void removeConfigurations(StackId stackId) { clusterGlobalLock.writeLock().lock(); try { + // make sure the entity isn't stale in the current unit of work. + refresh(); + removeAllConfigsForStack(stackId); cacheConfigurations();
