ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: AMBARI-14594 - Version box showing 'Installing' when some hosts has no HDP components (jonathanhurley)
Date Sun, 10 Jan 2016 05:04:38 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 461c34ab5 -> 370fa88a5


AMBARI-14594 - Version box showing 'Installing' when some hosts has no HDP components (jonathanhurley)


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

Branch: refs/heads/branch-2.2
Commit: 370fa88a5e840629681641d392ef9aab6770409c
Parents: 461c34a
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Fri Jan 8 14:12:35 2016 -0500
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Sat Jan 9 23:59:21 2016 -0500

----------------------------------------------------------------------
 .../org/apache/ambari/server/state/Cluster.java |  5 ++--
 .../server/state/cluster/ClusterImpl.java       | 27 +++++++++++---------
 .../server/state/cluster/ClusterTest.java       |  4 +--
 3 files changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/370fa88a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
index e10c808..7934e78 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
@@ -188,9 +188,8 @@ public interface Cluster {
    * {@link Cluster#mapHostVersions} is that it affects all hosts (not only
    * missing hosts).
    * <p/>
-   * Hosts that are in maintenance mode will not be included. These hosts have
-   * been explicitely marked as being in maintenance andd are not included in
-   * this operation.
+   * Hosts that are in maintenance mode will be transititioned directly into
+   * {@link RepositoryVersionState#OUT_OF_SYNC} instead.
    *
    * @param sourceClusterVersion
    *          cluster version to be queried for a stack name/version info and

http://git-wip-us.apache.org/repos/asf/ambari/blob/370fa88a/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 9a5407c..7a5db2f 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
@@ -275,8 +275,8 @@ public class ClusterImpl implements Cluster {
                      Injector injector) throws AmbariException {
     injector.injectMembers(this);
 
-    this.clusterId = clusterEntity.getClusterId();
-    this.clusterName = clusterEntity.getClusterName();
+    clusterId = clusterEntity.getClusterId();
+    clusterName = clusterEntity.getClusterName();
 
     serviceComponentHosts = new HashMap<>();
     serviceComponentHostsByHost = new HashMap<>();
@@ -1242,30 +1242,33 @@ public class ClusterImpl implements Cluster {
    * @param newState target host version state for transition
    */
   @Transactional
-  void createOrUpdateHostVersionToState(ClusterVersionEntity sourceClusterVersion, Map<String,
Host> hosts,
-                                        HashMap<String, HostVersionEntity> existingHostStackVersions,
-                                        Sets.SetView<String> hostsMissingRepoVersion,
-                                                RepositoryVersionState newState) {
+  void createOrUpdateHostVersionToState(ClusterVersionEntity sourceClusterVersion,
+      Map<String, Host> hosts, HashMap<String, HostVersionEntity> existingHostStackVersions,
+      Sets.SetView<String> hostsMissingRepoVersion, RepositoryVersionState newState)
{
+
     for (String hostname : hosts.keySet()) {
+      // start off with the requested new state for each host
+      RepositoryVersionState repositoryVersionState = newState;
+
       // if the host is in maintenance mode, that's an explicit marker which
-      // indicates that it should not be transitioned to newState; these
-      // hosts are excluded from being transitioned into newState
+      // indicates that it should not be transitioned to INSTALLING; instead
+      // they will be transitioned to OUT_OF_SYNC
       Host host = hosts.get(hostname);
       if (host.getMaintenanceState(getClusterId()) != MaintenanceState.OFF) {
-        continue;
+        repositoryVersionState = RepositoryVersionState.OUT_OF_SYNC;
       }
 
       if (hostsMissingRepoVersion.contains(hostname)) {
         // Create new host stack version
         HostEntity hostEntity = hostDAO.findByName(hostname);
         HostVersionEntity hostVersionEntity = new HostVersionEntity(hostEntity,
-            sourceClusterVersion.getRepositoryVersion(),
-          newState);
+            sourceClusterVersion.getRepositoryVersion(), repositoryVersionState);
+
         hostVersionDAO.create(hostVersionEntity);
       } else {
         // Update existing host stack version
         HostVersionEntity hostVersionEntity = existingHostStackVersions.get(hostname);
-        hostVersionEntity.setState(newState);
+        hostVersionEntity.setState(repositoryVersionState);
         hostVersionDAO.merge(hostVersionEntity);
       }
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/370fa88a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
index 92d5009..b3f4781 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
@@ -1589,12 +1589,12 @@ public class ClusterTest {
     List<HostVersionEntity> otherHostVersions = hostVersionDAO.findByClusterAndHost("c1",
         hostNotInMaintenanceMode.getHostName());
 
-    // verify the MM host is in INSTALL_FAILED still
+    // verify the MM host has moved to OUT_OF_SYNC
     for (HostVersionEntity hostVersionEntity : hostInMaintModeVersions) {
       StackEntity repoVersionStackEntity = hostVersionEntity.getRepositoryVersion().getStack();
       if (repoVersionStackEntity.getStackName().equals("HDP")
           && repoVersionStackEntity.getStackVersion().equals("0.2")) {
-        assertEquals(RepositoryVersionState.INSTALL_FAILED, hostVersionEntity.getState());
+        assertEquals(RepositoryVersionState.OUT_OF_SYNC, hostVersionEntity.getState());
       }
     }
 


Mime
View raw message