Repository: ambari
Updated Branches:
  refs/heads/branch-rbac-sso cf73fa58b -> 2cfc7bc85


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/2cfc7bc8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2cfc7bc8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2cfc7bc8

Branch: refs/heads/branch-rbac-sso
Commit: 2cfc7bc859a0811fd0a7fac9f98f990638641b5c
Parents: cf73fa5
Author: Nate Cole <[email protected]>
Authored: Wed Dec 16 16:11:10 2015 -0500
Committer: Sumit Mohanty <[email protected]>
Committed: Fri Dec 18 14:40:14 2015 -0800

----------------------------------------------------------------------
 .../ambari/server/orm/entities/ClusterConfigEntity.java      | 4 ++--
 .../org/apache/ambari/server/state/cluster/ClusterImpl.java  | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2cfc7bc8/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 ceefa60..bf0faee 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
@@ -228,8 +228,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/2cfc7bc8/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 629c1b0..6aa3563 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;
@@ -40,7 +39,6 @@ import javax.annotation.Nullable;
 import javax.persistence.EntityManager;
 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;
@@ -132,6 +130,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;
@@ -3057,6 +3056,7 @@ public class ClusterImpl implements Cluster {
       clusterEntity = clusterDAO.merge(clusterEntity);
       clusterDAO.mergeConfigMappings(configMappingEntities);
 
+      refresh();
       cacheConfigurations();
     } finally {
       clusterGlobalLock.writeLock().unlock();
@@ -3141,6 +3141,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();
@@ -3169,6 +3170,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();

Reply via email to