@Test public void testGroupOrdersForNonRolling() { Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1"); assertTrue(upgrades.size() > 0); assertTrue(upgrades.containsKey("upgrade_test_nonrolling")); UpgradePack upgrade = upgrades.get("upgrade_test_nonrolling"); List<String> expected_up = Arrays.asList( "PRE_CLUSTER", "Stop High-Level Daemons", "Backups", "Stop Low-Level Daemons", "UPDATE_DESIRED_STACK_ID", "ALL_HOST_OPS", "ZOOKEEPER", "HDFS", "MR and YARN", "POST_CLUSTER"); List<String> expected_down = Arrays.asList( "Restore Backups", "UPDATE_DESIRED_STACK_ID", "ALL_HOST_OPS", "ZOOKEEPER", "HDFS", "MR and YARN", "POST_CLUSTER"); Iterator<String> itr_up = expected_up.iterator(); List<Grouping> upgrade_groups = upgrade.getGroups(Direction.UPGRADE); for (Grouping g : upgrade_groups) { assertEquals(true, itr_up.hasNext()); assertEquals(itr_up.next(), g.name); } Iterator<String> itr_down = expected_down.iterator(); List<Grouping> downgrade_groups = upgrade.getGroups(Direction.DOWNGRADE); for (Grouping g : downgrade_groups) { assertEquals(true, itr_down.hasNext()); assertEquals(itr_down.next(), g.name); } }
public List<Grouping> getGroups(Direction direction) { List<Grouping> list = new ArrayList<Grouping>(); if (direction.isUpgrade()) { list = groups; } else { switch (type) { case NON_ROLLING: list = getDowngradeGroupsForNonrolling(); break; case HOST_ORDERED: case ROLLING: default: list = getDowngradeGroupsForRolling(); break; } } List<Grouping> checked = new ArrayList<Grouping>(); for (Grouping group : list) { if (null == group.intendedDirection || direction == group.intendedDirection) { checked.add(group); } } return checked; }
UpgradePack { public List<Grouping> getGroups(Direction direction) { List<Grouping> list = new ArrayList<Grouping>(); if (direction.isUpgrade()) { list = groups; } else { switch (type) { case NON_ROLLING: list = getDowngradeGroupsForNonrolling(); break; case HOST_ORDERED: case ROLLING: default: list = getDowngradeGroupsForRolling(); break; } } List<Grouping> checked = new ArrayList<Grouping>(); for (Grouping group : list) { if (null == group.intendedDirection || direction == group.intendedDirection) { checked.add(group); } } return checked; } }
UpgradePack { public List<Grouping> getGroups(Direction direction) { List<Grouping> list = new ArrayList<Grouping>(); if (direction.isUpgrade()) { list = groups; } else { switch (type) { case NON_ROLLING: list = getDowngradeGroupsForNonrolling(); break; case HOST_ORDERED: case ROLLING: default: list = getDowngradeGroupsForRolling(); break; } } List<Grouping> checked = new ArrayList<Grouping>(); for (Grouping group : list) { if (null == group.intendedDirection || direction == group.intendedDirection) { checked.add(group); } } return checked; }  }
UpgradePack { public List<Grouping> getGroups(Direction direction) { List<Grouping> list = new ArrayList<Grouping>(); if (direction.isUpgrade()) { list = groups; } else { switch (type) { case NON_ROLLING: list = getDowngradeGroupsForNonrolling(); break; case HOST_ORDERED: case ROLLING: default: list = getDowngradeGroupsForRolling(); break; } } List<Grouping> checked = new ArrayList<Grouping>(); for (Grouping group : list) { if (null == group.intendedDirection || direction == group.intendedDirection) { checked.add(group); } } return checked; }  String getName(); void setName(String name); String getTarget(); UpgradeType getType(); List<String> getPrerequisiteChecks(); PrerequisiteCheckConfig getPrerequisiteCheckConfig(); void mergePrerequisiteChecks(UpgradePack pack); void mergeProcessing(UpgradePack pack); List<IntermediateStack> getIntermediateStacks(); String getTargetStack(); boolean isComponentFailureAutoSkipped(); boolean isServiceCheckFailureAutoSkipped(); List<Grouping> getAllGroups(); List<Grouping> getGroups(Direction direction); boolean isDowngradeAllowed(); boolean canBeApplied(String targetVersion); Map<String, Map<String, ProcessingComponent>> getTasks(); boolean isAllTarget(); }
UpgradePack { public List<Grouping> getGroups(Direction direction) { List<Grouping> list = new ArrayList<Grouping>(); if (direction.isUpgrade()) { list = groups; } else { switch (type) { case NON_ROLLING: list = getDowngradeGroupsForNonrolling(); break; case HOST_ORDERED: case ROLLING: default: list = getDowngradeGroupsForRolling(); break; } } List<Grouping> checked = new ArrayList<Grouping>(); for (Grouping group : list) { if (null == group.intendedDirection || direction == group.intendedDirection) { checked.add(group); } } return checked; }  String getName(); void setName(String name); String getTarget(); UpgradeType getType(); List<String> getPrerequisiteChecks(); PrerequisiteCheckConfig getPrerequisiteCheckConfig(); void mergePrerequisiteChecks(UpgradePack pack); void mergeProcessing(UpgradePack pack); List<IntermediateStack> getIntermediateStacks(); String getTargetStack(); boolean isComponentFailureAutoSkipped(); boolean isServiceCheckFailureAutoSkipped(); List<Grouping> getAllGroups(); List<Grouping> getGroups(Direction direction); boolean isDowngradeAllowed(); boolean canBeApplied(String targetVersion); Map<String, Map<String, ProcessingComponent>> getTasks(); boolean isAllTarget();  }