ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject ambari git commit: AMBARI-11506. Heartbeats lost during large cluster deploy. (mpapirkovskyy)
Date Tue, 09 Jun 2015 18:43:08 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.maint d9cffc309 -> 358a91ac1


AMBARI-11506. Heartbeats lost during large cluster deploy. (mpapirkovskyy)


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

Branch: refs/heads/branch-2.0.maint
Commit: 358a91ac1f361156b0834a3932eacc4f2794267c
Parents: d9cffc3
Author: Myroslav Papirkovskyy <mpapyrkovskyy@hortonworks.com>
Authored: Tue Jun 9 21:42:07 2015 +0300
Committer: Myroslav Papirkovskyy <mpapyrkovskyy@hortonworks.com>
Committed: Tue Jun 9 21:42:54 2015 +0300

----------------------------------------------------------------------
 .../server/state/cluster/ClusterImpl.java       | 37 ++++++++++----------
 1 file changed, 18 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/358a91ac/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 8e89cad..a55024f 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
@@ -1243,36 +1243,35 @@ public class ClusterImpl implements Cluster {
       }
 
       // Part 2, check for transitions.
-      Set<Host> hostsWithoutHostVersion = new HashSet<Host>();
+      Set<String> hostsWithoutHostVersion = new HashSet<String>();
       Map<RepositoryVersionState, Set<String>> stateToHosts = new HashMap<RepositoryVersionState,
Set<String>>();
-      for (Host host : hosts.values()) {
-        String hostName = host.getHostName();
-        HostVersionEntity hostVersion = hostVersionDAO.findByClusterStackVersionAndHost(
-            getClusterName(), stackId.getStackId(), repositoryVersion, hostName);
-
-        if (hostVersion == null) {
-          // This host either has not had a chance to heartbeat yet with its
-          // installed component, or it has components
-          // that do not advertise a version.
-          hostsWithoutHostVersion.add(host);
-          continue;
-        }
+      List<HostVersionEntity> hostVersionEntities =
+          hostVersionDAO.findByClusterStackAndVersion(getClusterName(), stackId.getStackId(),
repositoryVersion);
+
+
+      Set<String> hostsWithState = new HashSet<String>();
+      for (HostVersionEntity hostVersionEntity : hostVersionEntities) {
+        String hostname = hostVersionEntity.getHostEntity().getHostName();
+        hostsWithState.add(hostname);
+        RepositoryVersionState hostState = hostVersionEntity.getState();
 
-        RepositoryVersionState hostState = hostVersion.getState();
         if (stateToHosts.containsKey(hostState)) {
-          stateToHosts.get(hostState).add(hostName);
+          stateToHosts.get(hostState).add(hostname);
         } else {
           Set<String> hostsInState = new HashSet<String>();
-          hostsInState.add(hostName);
+          hostsInState.add(hostname);
           stateToHosts.put(hostState, hostsInState);
         }
       }
 
+      hostsWithoutHostVersion.addAll(hosts.keySet());
+      hostsWithoutHostVersion.removeAll(hostsWithState);
+
       // Ensure that all of the hosts without a Host Version only have
       // Components that do not advertise a version.
       // Otherwise, operations are still in progress.
-      for (Host host : hostsWithoutHostVersion) {
-        HostEntity hostEntity = hostDAO.findByName(host.getHostName());
+      for (String hostname : hostsWithoutHostVersion) {
+        HostEntity hostEntity = hostDAO.findByName(hostname);
         final Collection<HostComponentStateEntity> allHostComponents = hostEntity.getHostComponentStateEntities();
 
         for (HostComponentStateEntity hostComponentStateEntity : allHostComponents) {
@@ -1287,7 +1286,7 @@ public class ClusterImpl implements Cluster {
 
             if (compInfo.isVersionAdvertised()) {
               LOG.debug("Skipping transitioning the cluster version because host "
-                  + host.getHostName() + " does not have a version yet.");
+                  + hostname + " does not have a version yet.");
               return;
             }
           }


Mime
View raw message