ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rle...@apache.org
Subject [17/50] [abbrv] ambari git commit: AMBARI-22178. Install and upgrade options are shown for current and already upgraded stack versions (ncole)
Date Fri, 13 Oct 2017 15:10:36 GMT
AMBARI-22178. Install and upgrade options are shown for current and already upgraded stack
versions (ncole)


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

Branch: refs/heads/branch-feature-AMBARI-20859
Commit: 8908d3e05a546cd3dea4bf84d54f087d64ce8b88
Parents: b129536
Author: Nate Cole <ncole@hortonworks.com>
Authored: Tue Oct 10 09:44:20 2017 -0400
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Tue Oct 10 10:18:06 2017 -0400

----------------------------------------------------------------------
 .../upgrade/HostVersionOutOfSyncListener.java         | 11 +++++++++++
 .../upgrade/HostVersionOutOfSyncListenerTest.java     | 14 +++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8908d3e0/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
index 0be036e..4ce855d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
@@ -48,6 +48,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.RepositoryVersionState;
+import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.StackId;
 import org.slf4j.Logger;
@@ -115,6 +116,10 @@ public class HostVersionOutOfSyncListener {
       List<HostVersionEntity> hostVersionEntities =
           hostVersionDAO.get().findByClusterAndHost(cluster.getClusterName(), event.getHostName());
 
+      Service service = cluster.getService(event.getServiceName());
+      ServiceComponent serviceComponent = service.getServiceComponent(event.getComponentName());
+      RepositoryVersionEntity componentRepo = serviceComponent.getDesiredRepositoryVersion();
+
       for (HostVersionEntity hostVersionEntity : hostVersionEntities) {
         StackEntity hostStackEntity = hostVersionEntity.getRepositoryVersion().getStack();
         StackId hostStackId = new StackId(hostStackEntity);
@@ -136,6 +141,12 @@ public class HostVersionOutOfSyncListener {
           continue;
         }
 
+        // !!! we shouldn't be changing other versions to OUT_OF_SYNC if the event
+        // component repository doesn't match
+        if (!hostVersionEntity.getRepositoryVersion().equals(componentRepo)) {
+          continue;
+        }
+
         switch (hostVersionEntity.getState()) {
           case INSTALLED:
           case NOT_REQUIRED:

http://git-wip-us.apache.org/repos/asf/ambari/blob/8908d3e0/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
index 076190a..24d4f55 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
@@ -19,6 +19,7 @@
 package org.apache.ambari.server.events.listeners.upgrade;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.sql.SQLException;
 import java.util.ArrayList;
@@ -335,12 +336,12 @@ public class HostVersionOutOfSyncListenerTest {
 
     for (HostVersionEntity hostVersionEntity : hostVersions) {
       RepositoryVersionEntity repoVersion = hostVersionEntity.getRepositoryVersion();
-      if (repoVersion.getVersion().equals(INSTALLED_VERSION) || repoVersion.getVersion().equals(INSTALLED_VERSION_2))
{
-        if (changedHosts.contains(hostVersionEntity.getHostName())) {
-          assertEquals(hostVersionEntity.getState(), RepositoryVersionState.OUT_OF_SYNC);
-        } else {
-          assertEquals(hostVersionEntity.getState(), RepositoryVersionState.INSTALLED);
-        }
+
+      if (repoVersion.getVersion().equals(INSTALLED_VERSION_2)) {
+        assertEquals(RepositoryVersionState.INSTALLED, hostVersionEntity.getState());
+      } else if (repoVersion.getVersion().equals(INSTALLED_VERSION)) {
+        assertTrue(changedHosts.contains(hostVersionEntity.getHostName()));
+        assertEquals(RepositoryVersionState.OUT_OF_SYNC, hostVersionEntity.getState());
       }
     }
   }
@@ -598,6 +599,5 @@ public class HostVersionOutOfSyncListenerTest {
         }
       }
     }
-
   }
 }


Mime
View raw message