You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/01/11 15:38:49 UTC

[13/23] ambari git commit: AMBARI-14594 - Version box showing 'Installing' when some hosts has no HDP components (jonathanhurley)

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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: df29c7750acbd7d6ec2b6c91bc9f6bc546a43240
Parents: 5549bd4
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Fri Jan 8 14:12:35 2016 -0500
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Sat Jan 9 23:58:55 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/df29c775/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 3203dff..b430525 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
@@ -194,9 +194,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/df29c775/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 87305cc..7645d65 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
@@ -283,8 +283,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<>();
 
@@ -1276,30 +1276,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/df29c775/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 3f85840..d2ba396 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
@@ -1591,12 +1591,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());
       }
     }