소스 검색

AMBARI-14405. RU: Finalize Downgrade failed (ncole)

Nate Cole 9 년 전
부모
커밋
b3edc70991

+ 2 - 2
ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigEntity.java

@@ -228,8 +228,8 @@ public class ClusterConfigEntity {
 
 
   @Override
   @Override
   public int hashCode() {
   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 + (type != null ? type.hashCode() : 0);
     result = 31 * result + (tag != null ? tag.hashCode() : 0);
     result = 31 * result + (tag != null ? tag.hashCode() : 0);
     result = 31 * result + (stack != null ? stack.hashCode() : 0);
     result = 31 * result + (stack != null ? stack.hashCode() : 0);

+ 7 - 2
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.ArrayList;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Iterator;
@@ -39,7 +38,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.annotation.Nullable;
 import javax.annotation.Nullable;
 import javax.persistence.RollbackException;
 import javax.persistence.RollbackException;
 
 
-import com.google.common.collect.Maps;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ConfigGroupNotFoundException;
 import org.apache.ambari.server.ConfigGroupNotFoundException;
 import org.apache.ambari.server.DuplicateResourceException;
 import org.apache.ambari.server.DuplicateResourceException;
@@ -134,6 +132,7 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.ListMultimap;
 import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Maps;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Sets;
 import com.google.common.collect.Sets;
 import com.google.inject.Inject;
 import com.google.inject.Inject;
@@ -3018,6 +3017,7 @@ public class ClusterImpl implements Cluster {
   public void applyLatestConfigurations(StackId stackId) {
   public void applyLatestConfigurations(StackId stackId) {
     clusterGlobalLock.writeLock().lock();
     clusterGlobalLock.writeLock().lock();
     try {
     try {
+
       Collection<ClusterConfigMappingEntity> configMappingEntities = clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId());
       Collection<ClusterConfigMappingEntity> configMappingEntities = clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId());
 
 
       // disable previous config
       // disable previous config
@@ -3044,6 +3044,7 @@ public class ClusterImpl implements Cluster {
 
 
       clusterDAO.mergeConfigMappings(clusterConfigMappingEntities);
       clusterDAO.mergeConfigMappings(clusterConfigMappingEntities);
 
 
+      refresh();
       cacheConfigurations();
       cacheConfigurations();
     } finally {
     } finally {
       clusterGlobalLock.writeLock().unlock();
       clusterGlobalLock.writeLock().unlock();
@@ -3128,6 +3129,7 @@ public class ClusterImpl implements Cluster {
     // remove config mappings
     // remove config mappings
     Collection<ClusterConfigMappingEntity> configMappingEntities =
     Collection<ClusterConfigMappingEntity> configMappingEntities =
         clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId());
         clusterDAO.getClusterConfigMappingEntitiesByCluster(getClusterId());
+
     for (ClusterConfigEntity removedClusterConfig : removedClusterConfigs) {
     for (ClusterConfigEntity removedClusterConfig : removedClusterConfigs) {
       String removedClusterConfigType = removedClusterConfig.getType();
       String removedClusterConfigType = removedClusterConfig.getType();
       String removedClusterConfigTag = removedClusterConfig.getTag();
       String removedClusterConfigTag = removedClusterConfig.getTag();
@@ -3156,6 +3158,9 @@ public class ClusterImpl implements Cluster {
   public void removeConfigurations(StackId stackId) {
   public void removeConfigurations(StackId stackId) {
     clusterGlobalLock.writeLock().lock();
     clusterGlobalLock.writeLock().lock();
     try {
     try {
+      // make sure the entity isn't stale in the current unit of work.
+      refresh();
+
       removeAllConfigsForStack(stackId);
       removeAllConfigsForStack(stackId);
 
 
       cacheConfigurations();
       cacheConfigurations();