Repository: ambari
Updated Branches:
  refs/heads/trunk f3aab68ec -> fb16c640c


AMBARI-6585. Deleted hosts come back to life after ambari-server restart. 
(Alejandro Fernandez via swagle)


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

Branch: refs/heads/trunk
Commit: fb16c640cf84ea62fc84a60a83e4791b1cefcebe
Parents: f3aab68
Author: Siddharth Wagle <swa...@hortonworks.com>
Authored: Thu Jul 24 23:47:26 2014 -0700
Committer: Siddharth Wagle <swa...@hortonworks.com>
Committed: Thu Jul 24 23:47:26 2014 -0700

----------------------------------------------------------------------
 .../server/orm/entities/ClusterEntity.java      | 16 +++--------
 .../ambari/server/orm/entities/HostEntity.java  | 29 ++------------------
 .../server/state/cluster/ClustersImpl.java      | 13 +++++----
 3 files changed, 14 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fb16c640/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
index 7e01140..6fb9b5a 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
@@ -162,24 +162,16 @@ public class ClusterEntity {
 
     ClusterEntity that = (ClusterEntity) o;
 
-    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId 
!= null) return false;
-    if (clusterInfo != null ? !clusterInfo.equals(that.clusterInfo) : 
that.clusterInfo != null) return false;
-    if (clusterName != null ? !clusterName.equals(that.clusterName) : 
that.clusterName != null) return false;
-    if (desiredClusterState != null ? 
!desiredClusterState.equals(that.desiredClusterState) : 
that.desiredClusterState != null)
-      return false;
-    if (desiredStackVersion != null ? 
!desiredStackVersion.equals(that.desiredStackVersion) : 
that.desiredStackVersion != null)
-      return false;
+    if (!clusterId.equals(that.clusterId)) return false;
+    if (!clusterName.equals(that.clusterName)) return false;
 
     return true;
   }
 
   @Override
   public int hashCode() {
-    int result = clusterId != null ? clusterId.intValue() : 0;
-    result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0);
-    result = 31 * result + (desiredClusterState != null ? 
desiredClusterState.hashCode() : 0);
-    result = 31 * result + (clusterInfo != null ? clusterInfo.hashCode() : 0);
-    result = 31 * result + (desiredStackVersion != null ? 
desiredStackVersion.hashCode() : 0);
+    int result = clusterId.hashCode();
+    result = 31 * result + clusterName.hashCode();
     return result;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/fb16c640/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java
index 0739ddf..a71fddb 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostEntity.java
@@ -237,39 +237,14 @@ public class HostEntity {
 
     HostEntity that = (HostEntity) o;
 
-    if (cpuCount != null ? !cpuCount.equals(that.cpuCount) : that.cpuCount != 
null) return false;
-    if (lastRegistrationTime != null ? 
!lastRegistrationTime.equals(that.lastRegistrationTime) : 
that.lastRegistrationTime != null) return false;
-    if (totalMem != null ? !totalMem.equals(that.totalMem) : that.totalMem != 
null) return false;
-    if (cpuInfo != null ? !cpuInfo.equals(that.cpuInfo) : that.cpuInfo != 
null) return false;
-    if (discoveryStatus != null ? 
!discoveryStatus.equals(that.discoveryStatus) : that.discoveryStatus != null)
-      return false;
-    if (hostAttributes != null ? !hostAttributes.equals(that.hostAttributes) : 
that.hostAttributes != null)
-      return false;
-    if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != 
null) return false;
-    if (ipv4 != null ? !ipv4.equals(that.ipv4) : that.ipv4 != null) return 
false;
-    if (osArch != null ? !osArch.equals(that.osArch) : that.osArch != null) 
return false;
-    if (osInfo != null ? !osInfo.equals(that.osInfo) : that.osInfo != null) 
return false;
-    if (osType != null ? !osType.equals(that.osType) : that.osType != null) 
return false;
-    if (rackInfo != null ? !rackInfo.equals(that.rackInfo) : that.rackInfo != 
null) return false;
+    if (!hostName.equals(that.hostName)) return false;
 
     return true;
   }
 
   @Override
   public int hashCode() {
-    int result = hostName != null ? hostName.hashCode() : 0;
-    result = 31 * result + (ipv4 != null ? ipv4.hashCode() : 0);
-    result = 31 * result + (totalMem != null ? totalMem.intValue() : 0);
-    result = 31 * result + cpuCount;
-    result = 31 * result + (cpuInfo != null ? cpuInfo.hashCode() : 0);
-    result = 31 * result + (osArch != null ? osArch.hashCode() : 0);
-    result = 31 * result + (osInfo != null ? osInfo.hashCode() : 0);
-    result = 31 * result + (osType != null ? osType.hashCode() : 0);
-    result = 31 * result + (discoveryStatus != null ? 
discoveryStatus.hashCode() : 0);
-    result = 31 * result + (lastRegistrationTime != null ? 
lastRegistrationTime.intValue() : 0);
-    result = 31 * result + (rackInfo != null ? rackInfo.hashCode() : 0);
-    result = 31 * result + (hostAttributes != null ? hostAttributes.hashCode() 
: 0);
-    return result;
+    return hostName.hashCode();
   }
 
   public Collection<HostComponentDesiredStateEntity> 
getHostComponentDesiredStateEntities() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/fb16c640/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
index 7dd4cda..f858264 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
@@ -324,7 +324,6 @@ public class ClustersImpl implements Clusters {
   }
 
   @Override
-  @Transactional
   public void updateHostWithClusterAndAttributes(Map<String, Set<String>> 
hostClusters, Map<String,
       Map<String, String>> hostAttributes)
       throws AmbariException {
@@ -370,7 +369,8 @@ public class ClustersImpl implements Clusters {
               }
 
               mapHostClusterEntities(hostname, cluster.getClusterId());
-
+              host.refresh();
+              cluster.refresh();
               hostClusterMap.get(hostname).add(cluster);
               clusterHostMap.get(clusterName).add(host);
 
@@ -458,7 +458,8 @@ public class ClustersImpl implements Clusters {
       }
 
       mapHostClusterEntities(hostname, cluster.getClusterId());
-
+      host.refresh();
+      cluster.refresh();
       hostClusterMap.get(hostname).add(cluster);
       clusterHostMap.get(clusterName).add(host);
 
@@ -472,7 +473,7 @@ public class ClustersImpl implements Clusters {
       w.unlock();
     }
   }
-  
+
   @Transactional
   void mapHostClusterEntities(String hostName, Long clusterId) {
     HostEntity hostEntity = hostDAO.findByName(hostName);
@@ -607,8 +608,10 @@ public class ClustersImpl implements Clusters {
             + ", clusterId=" + cluster.getClusterId()
             + ", hostname=" + hostname);
       }
-      
+
       unmapHostClusterEntities(hostname, cluster.getClusterId());
+      host.refresh();
+      cluster.refresh();
 
       hostClusterMap.get(hostname).remove(cluster);
       clusterHostMap.get(clusterName).remove(host);

Reply via email to