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/12/05 20:27:59 UTC
ambari git commit: AMBARI-19074. Host-Ordered: Empty groups are
returned for Downgrade (ncole)
Repository: ambari
Updated Branches:
refs/heads/trunk 8fbc2718e -> 50ead4d23
AMBARI-19074. Host-Ordered: Empty groups are returned for Downgrade (ncole)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/50ead4d2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/50ead4d2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/50ead4d2
Branch: refs/heads/trunk
Commit: 50ead4d237b0c03fee68192a5983044409e3e9db
Parents: 8fbc271
Author: Nate Cole <nc...@hortonworks.com>
Authored: Mon Dec 5 12:54:41 2016 -0500
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Mon Dec 5 15:27:19 2016 -0500
----------------------------------------------------------------------
.../ambari/server/state/stack/UpgradePack.java | 19 ++++++++--
.../ambari/server/state/UpgradeHelperTest.java | 39 +++++++++++---------
2 files changed, 36 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/50ead4d2/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
index aa97fa3..76f1897 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/UpgradePack.java
@@ -289,10 +289,15 @@ public class UpgradePack {
if (direction.isUpgrade()) {
list = groups;
} else {
- if (type == UpgradeType.ROLLING) {
- list = getDowngradeGroupsForRolling();
- } else if (type == UpgradeType.NON_ROLLING) {
- list = getDowngradeGroupsForNonrolling();
+ switch (type) {
+ case NON_ROLLING:
+ list = getDowngradeGroupsForNonrolling();
+ break;
+ case HOST_ORDERED:
+ case ROLLING:
+ default:
+ list = getDowngradeGroupsForRolling();
+ break;
}
}
@@ -358,6 +363,12 @@ public class UpgradePack {
private List<Grouping> getDowngradeGroupsForRolling() {
List<Grouping> reverse = new ArrayList<Grouping>();
+ // !!! Testing exposed groups.size() == 1 issue. Normally there's no precedent for
+ // a one-group upgrade pack, so take it into account anyway.
+ if (groups.size() == 1) {
+ return groups;
+ }
+
int idx = 0;
int iter = 0;
Iterator<Grouping> it = groups.iterator();
http://git-wip-us.apache.org/repos/asf/ambari/blob/50ead4d2/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
index 6b4b85a..ea1f18a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -1921,25 +1922,27 @@ public class UpgradeHelperTest {
ServiceComponentHost sch1 = sc.addServiceComponentHost("h1");
ServiceComponentHost sch2 = sc.addServiceComponentHost("h2");
- UpgradePack upgradePack = new UpgradePack() {
- @Override
- public List<Grouping> getGroups(Direction direction) {
- HostOrderItem hostItem = new HostOrderItem(HostOrderActionType.HOST_UPGRADE,
- Lists.newArrayList("h1", "h2"));
- HostOrderItem checkItem = new HostOrderItem(HostOrderActionType.SERVICE_CHECK,
- Lists.newArrayList("ZOOKEEPER", "STORM"));
-
- Grouping g = new HostOrderGrouping();
- ((HostOrderGrouping) g).setHostOrderItems(Lists.newArrayList(hostItem, checkItem));
- g.title = "Some Title";
- return Lists.newArrayList(g);
- }
+ // !!! make a custom grouping
+ HostOrderItem hostItem = new HostOrderItem(HostOrderActionType.HOST_UPGRADE,
+ Lists.newArrayList("h1", "h2"));
+ HostOrderItem checkItem = new HostOrderItem(HostOrderActionType.SERVICE_CHECK,
+ Lists.newArrayList("ZOOKEEPER", "STORM"));
+
+ Grouping g = new HostOrderGrouping();
+ ((HostOrderGrouping) g).setHostOrderItems(Lists.newArrayList(hostItem, checkItem));
+ g.title = "Some Title";
+
+ UpgradePack upgradePack = new UpgradePack();
+
+ // !!! set the groups directly; allow the logic in getGroups(Direction) to happen
+ Field field = UpgradePack.class.getDeclaredField("groups");
+ field.setAccessible(true);
+ field.set(upgradePack, Lists.newArrayList(g));
+
+ field = UpgradePack.class.getDeclaredField("type" );
+ field.setAccessible(true);
+ field.set(upgradePack, UpgradeType.HOST_ORDERED);
- @Override
- public Map<String, Map<String, ProcessingComponent>> getTasks() {
- return new HashMap<>();
- }
- };
MasterHostResolver resolver = new MasterHostResolver(m_configHelper, c);
UpgradeContext context = new UpgradeContext(c, UpgradeType.HOST_ORDERED, Direction.UPGRADE, new HashMap<String, Object>());