ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From magyari_san...@apache.org
Subject ambari git commit: AMBARI-21229. Logical Request: Provision Cluster API request status updated as COMPLETED as soon as BP deploy starts (magyari_sandor)
Date Fri, 16 Jun 2017 20:03:37 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk eb17e4c69 -> 8f2663b2e


AMBARI-21229. Logical Request: Provision Cluster API request status updated as COMPLETED as
soon as BP deploy starts (magyari_sandor)


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

Branch: refs/heads/trunk
Commit: 8f2663b2e6d543c75433359cb800a565e90f492e
Parents: eb17e4c
Author: Sandor Magyari <smagyari@hortonworks.com>
Authored: Mon Jun 12 15:34:41 2017 +0200
Committer: Sandor Magyari <smagyari@hortonworks.com>
Committed: Fri Jun 16 22:02:09 2017 +0200

----------------------------------------------------------------------
 .../controller/internal/RequestResourceProvider.java    | 12 +++++++-----
 .../apache/ambari/server/topology/LogicalRequest.java   |  2 +-
 .../internal/RequestResourceProviderTest.java           | 11 ++++++++---
 3 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8f2663b2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
index deb0d7c..a8f7638 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
@@ -794,13 +794,15 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
     final CalculatedStatus status;
     LogicalRequest logicalRequest = topologyManager.getRequest(entity.getRequestId());
     if (summary.isEmpty() && null != logicalRequest) {
-      // in this case, it appears that there are no tasks but this is a logical
+      // In this case, it appears that there are no tasks but this is a logical
       // topology request, so it's a matter of hosts simply not registering yet
-      // for tasks to be created
-      if (logicalRequest.hasPendingHostRequests()) {
-        status = CalculatedStatus.PENDING;
-      } else {
+      // for tasks to be created ==> status = PENDING.
+      // For a new LogicalRequest there should be at least one HostRequest,
+      // while if they were removed already ==> status = COMPLETED.
+      if (logicalRequest.getHostRequests().isEmpty()) {
         status = CalculatedStatus.COMPLETED;
+      } else {
+        status = CalculatedStatus.PENDING;
       }
     } else {
       // there are either tasks or this is not a logical request, so do normal

http://git-wip-us.apache.org/repos/asf/ambari/blob/8f2663b2/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
index b5ee94b..4638dbf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
@@ -165,7 +165,7 @@ public class LogicalRequest extends Request {
   }
 
   public boolean hasPendingHostRequests() {
-    return !requestsWithReservedHosts.isEmpty() || !outstandingHostRequests.isEmpty();
+    return !(requestsWithReservedHosts.isEmpty() && outstandingHostRequests.isEmpty());
   }
 
   public Collection<HostRequest> getCompletedHostRequests() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/8f2663b2/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
index 6bc856d..d243e73 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
@@ -32,6 +32,7 @@ import static org.powermock.api.easymock.PowerMock.reset;
 import static org.powermock.api.easymock.PowerMock.verify;
 
 import java.lang.reflect.Field;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -80,6 +81,7 @@ import org.apache.ambari.server.topology.Blueprint;
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.HostGroup;
 import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.HostRequest;
 import org.apache.ambari.server.topology.LogicalRequest;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.apache.ambari.server.topology.TopologyRequest;
@@ -1731,7 +1733,10 @@ public class RequestResourceProviderTest {
 
 
     LogicalRequest logicalRequest = createNiceMock(LogicalRequest.class);
-    expect(logicalRequest.hasPendingHostRequests()).andReturn(true).anyTimes();
+    Collection<HostRequest> hostRequests = new ArrayList<>();
+    HostRequest hostRequest = createNiceMock(HostRequest.class);
+    hostRequests.add(hostRequest);
+    expect(logicalRequest.getHostRequests()).andReturn(hostRequests).anyTimes();
     expect(logicalRequest.constructNewPersistenceEntity()).andReturn(requestMock).anyTimes();
 
     reset(topologyManager);
@@ -1744,7 +1749,7 @@ public class RequestResourceProviderTest {
     expect(topologyManager.getStageSummaries(EasyMock.<Long>anyObject())).andReturn(
       Collections.<Long, HostRoleCommandStatusSummaryDTO>emptyMap()).anyTimes();
 
-    replay(actionManager, requestMock, requestDAO, hrcDAO, topologyManager, logicalRequest);
+    replay(actionManager, requestMock, requestDAO, hrcDAO, topologyManager, logicalRequest,
hostRequest);
 
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
       type,
@@ -1772,7 +1777,7 @@ public class RequestResourceProviderTest {
 
     // verify
     PowerMock.verifyAll();
-    verify(actionManager, requestMock, requestDAO, hrcDAO, topologyManager, logicalRequest);
+    verify(actionManager, requestMock, requestDAO, hrcDAO, topologyManager, logicalRequest,
hostRequest);
 
     Assert.assertEquals(1, resources.size());
     for (Resource resource : resources) {


Mime
View raw message