ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject [2/3] ambari git commit: AMBARI-22262. Server should fire a host level params update event when repository version is resolved. (mpapirkovskyy)
Date Wed, 18 Oct 2017 16:01:23 GMT
AMBARI-22262. Server should fire a host level params update event when repository version is
resolved. (mpapirkovskyy)


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

Branch: refs/heads/branch-3.0-perf
Commit: 62319963b02d2cc88326ae28944b48a5869040aa
Parents: 8035443
Author: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Authored: Tue Oct 17 17:18:25 2017 +0300
Committer: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Committed: Wed Oct 18 16:39:58 2017 +0300

----------------------------------------------------------------------
 .../ambari/server/api/services/AmbariMetaInfo.java    |  1 +
 .../listeners/upgrade/StackVersionListener.java       | 12 +++++++++++-
 .../listeners/upgrade/StackVersionListenerTest.java   | 14 +++++++-------
 3 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/62319963/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index 2a794de..407238d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -1527,6 +1527,7 @@ public class AmbariMetaInfo {
         command.setRepositoryVersionId(rve.getId());
         command.setRepositoryVersion(rve.getVersion());
         command.setStackName(rve.getStackName());
+        command.setResolved(rve.isResolved());
 
         // !!! a repository version entity has all the repos worked out.  We shouldn't use
         // the stack at all.

http://git-wip-us.apache.org/repos/asf/ambari/blob/62319963/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
index 4329cdb..7cd8360 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
@@ -19,6 +19,7 @@ package org.apache.ambari.server.events.listeners.upgrade;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.EagerSingleton;
+import org.apache.ambari.server.agent.stomp.HostLevelParamsHolder;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.events.HostComponentVersionAdvertisedEvent;
 import org.apache.ambari.server.events.publishers.VersionEventPublisher;
@@ -65,6 +66,9 @@ public class StackVersionListener {
   @Inject
   private Provider<AmbariMetaInfo> ambariMetaInfoProvider;
 
+  @Inject
+  private Provider<HostLevelParamsHolder> m_hostLevelParamsHolder;
+
   /**
    * Constructor.
    *
@@ -76,7 +80,7 @@ public class StackVersionListener {
   }
 
   @Subscribe
-  public void onAmbariEvent(HostComponentVersionAdvertisedEvent event) {
+  public void onAmbariEvent(HostComponentVersionAdvertisedEvent event) throws AmbariException
{
     LOG.debug("Received event {}", event);
 
     Cluster cluster = event.getCluster();
@@ -96,19 +100,25 @@ public class StackVersionListener {
       // exact version is not known in advance.
       RepositoryVersionEntity rve = repositoryVersionDAO.findByPK(event.getRepositoryVersionId());
       if (null != rve) {
+        boolean updated = false;
         String currentRepoVersion = rve.getVersion();
         if (!StringUtils.equals(currentRepoVersion, newVersion)) {
           rve.setVersion(newVersion);
           rve.setResolved(true);
           repositoryVersionDAO.merge(rve);
+          updated = true;
         } else {
           // the reported versions are the same - we should ensure that the repo
           // is resolved
           if (!rve.isResolved()) {
             rve.setResolved(true);
             repositoryVersionDAO.merge(rve);
+            updated = true;
           }
         }
+        if (updated) {
+          m_hostLevelParamsHolder.get().updateData(m_hostLevelParamsHolder.get().getCurrentData(sch.getHost().getHostId()));
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/62319963/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
index ffacab9..1ed8d38 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListenerTest.java
@@ -202,7 +202,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
 
 
   @Test
-  public void testNoActionTakenOnNullVersion() {
+  public void testNoActionTakenOnNullVersion() throws AmbariException {
     expect(componentInfo.isVersionAdvertised()).andReturn(true).once();
     resetAll();
     replayAll();
@@ -211,7 +211,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   }
 
   @Test
-  public void testSetUpgradeStateToCompleteWhenUpgradeIsInProgressAndNewVersionIsEqualToComponentDesiredVersion()
{
+  public void testSetUpgradeStateToCompleteWhenUpgradeIsInProgressAndNewVersionIsEqualToComponentDesiredVersion()
throws AmbariException {
     expect(cluster.getUpgradeInProgress()).andReturn(DUMMY_UPGRADE_ENTITY);
 
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
@@ -227,7 +227,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   }
 
   @Test
-  public void testSetUpgradeStateToNoneWhenNoUpgradeAndNewVersionIsEqualToComponentDesiredVersion()
{
+  public void testSetUpgradeStateToNoneWhenNoUpgradeAndNewVersionIsEqualToComponentDesiredVersion()
throws AmbariException {
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
     expect(sch.getUpgradeState()).andReturn(UpgradeState.IN_PROGRESS);
     expect(componentInfo.isVersionAdvertised()).andReturn(true).once();
@@ -258,7 +258,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   }
 
   @Test
-  public void testSetUpgradeStateToCompleteWhenHostHasVersionMismatchAndNewVersionIsEqualToComponentDesiredVersionAndClusterUpgradeIsInProgress()
{
+  public void testSetUpgradeStateToCompleteWhenHostHasVersionMismatchAndNewVersionIsEqualToComponentDesiredVersionAndClusterUpgradeIsInProgress()
throws AmbariException {
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
     expect(sch.getUpgradeState()).andReturn(UpgradeState.VERSION_MISMATCH);
     expect(cluster.getUpgradeInProgress()).andReturn(DUMMY_UPGRADE_ENTITY);
@@ -273,7 +273,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   }
 
   @Test
-  public void testSetUpgradeStateToNoneWhenHostHasVersionMismatchAndNewVersionIsEqualToComponentDesiredVersion()
{
+  public void testSetUpgradeStateToNoneWhenHostHasVersionMismatchAndNewVersionIsEqualToComponentDesiredVersion()
throws AmbariException {
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
     expect(sch.getUpgradeState()).andReturn(UpgradeState.VERSION_MISMATCH);
     expect(serviceComponent.getDesiredVersion()).andStubReturn(VALID_NEW_VERSION);
@@ -287,7 +287,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
   }
 
   @Test
-  public void testSetUpgradeStateToVersionMismatchByDefaultWhenHostAndNewVersionsAreValid()
{
+  public void testSetUpgradeStateToVersionMismatchByDefaultWhenHostAndNewVersionsAreValid()
throws AmbariException {
     expect(sch.getVersion()).andReturn(VALID_PREVIOUS_VERSION);
     expect(componentInfo.isVersionAdvertised()).andReturn(true).once();
     sch.setUpgradeState(UpgradeState.VERSION_MISMATCH);
@@ -406,7 +406,7 @@ public class StackVersionListenerTest extends EasyMockSupport {
     verifyAll();
   }
 
-  private void sendEventAndVerify(String newVersion) {
+  private void sendEventAndVerify(String newVersion) throws AmbariException {
     HostComponentVersionAdvertisedEvent event = new HostComponentVersionAdvertisedEvent(cluster,
sch, newVersion);
     listener.onAmbariEvent(event);
 


Mime
View raw message