ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject ambari git commit: AMBARI-8811 - Rolling Upgrade: inconsistent statuses (tbeerbower)
Date Fri, 09 Jan 2015 17:09:01 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 11763dca2 -> c4d131fbc


AMBARI-8811 - Rolling Upgrade: inconsistent statuses (tbeerbower)


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

Branch: refs/heads/trunk
Commit: c4d131fbc00eea9e224d3b6ed370c131fd0f99c0
Parents: 11763dc
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Fri Jan 9 09:21:44 2015 -0500
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Fri Jan 9 12:08:47 2015 -0500

----------------------------------------------------------------------
 .../internal/StageResourceProvider.java         |  7 +++--
 .../internal/StageResourceProviderTest.java     | 30 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c4d131fb/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
index 9529001..54e65fa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StageResourceProvider.java
@@ -374,14 +374,15 @@ public class StageResourceProvider extends AbstractResourceProvider
implements E
    */
   protected static HostRoleStatus calculateSummaryStatus(Map<HostRoleStatus, Integer>
counters, int total,
                                                          boolean failAll) {
-    return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING :
+    return counters.get(HostRoleStatus.PENDING) == total ? HostRoleStatus.PENDING :
+        counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING :
         counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED
:
         counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0 ? HostRoleStatus.HOLDING_TIMEDOUT
:
         counters.get(HostRoleStatus.FAILED) > 0 && failAll ? HostRoleStatus.FAILED
:
         counters.get(HostRoleStatus.ABORTED) > 0 ? HostRoleStatus.ABORTED :
         counters.get(HostRoleStatus.TIMEDOUT) > 0 && failAll ? HostRoleStatus.TIMEDOUT
:
-        counters.get(HostRoleStatus.IN_PROGRESS) > 0 ? HostRoleStatus.IN_PROGRESS :
-        counters.get(HostRoleStatus.COMPLETED) == total  && total > 0 ? HostRoleStatus.COMPLETED
: HostRoleStatus.PENDING;
+        counters.get(HostRoleStatus.COMPLETED) == total ? HostRoleStatus.COMPLETED :
+            HostRoleStatus.IN_PROGRESS;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4d131fb/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java
index cdb5eb7..87398a5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StageResourceProviderTest.java
@@ -283,6 +283,36 @@ public class StageResourceProviderTest {
     counts = StageResourceProvider.calculateTaskStatusCounts(hostRoleStatuses);
 
     assertEquals(HostRoleStatus.PENDING, StageResourceProvider.calculateSummaryStatus(counts,
hostRoleStatuses.size(), false));
+
+
+    hostRoleStatuses = new LinkedList<HostRoleStatus>();
+
+    hostRoleStatuses.add(HostRoleStatus.COMPLETED);
+    hostRoleStatuses.add(HostRoleStatus.IN_PROGRESS);
+    hostRoleStatuses.add(HostRoleStatus.PENDING);
+    hostRoleStatuses.add(HostRoleStatus.PENDING);
+    hostRoleStatuses.add(HostRoleStatus.PENDING);
+    hostRoleStatuses.add(HostRoleStatus.PENDING);
+
+    counts = StageResourceProvider.calculateTaskStatusCounts(hostRoleStatuses);
+
+    assertEquals(HostRoleStatus.IN_PROGRESS, StageResourceProvider.calculateSummaryStatus(counts,
hostRoleStatuses.size(), false));
+
+
+    hostRoleStatuses = new LinkedList<HostRoleStatus>();
+
+    hostRoleStatuses.add(HostRoleStatus.COMPLETED);
+    hostRoleStatuses.add(HostRoleStatus.COMPLETED);
+    hostRoleStatuses.add(HostRoleStatus.PENDING);
+    hostRoleStatuses.add(HostRoleStatus.PENDING);
+    hostRoleStatuses.add(HostRoleStatus.PENDING);
+    hostRoleStatuses.add(HostRoleStatus.PENDING);
+
+    counts = StageResourceProvider.calculateTaskStatusCounts(hostRoleStatuses);
+
+    // this used to be PENDING; Changing behavior so that IN_PROGRESS is returned if any
resource used in the calculation
+    // is past PENDING; AMBARI-8811
+    assertEquals(HostRoleStatus.IN_PROGRESS, StageResourceProvider.calculateSummaryStatus(counts,
hostRoleStatuses.size(), false));
   }
 
 


Mime
View raw message