@Override
  public void merge(Iterator<Grouping> iterator) throws AmbariException {
    if (executionStages == null) {
      executionStages = new ArrayList<>();
    }
    Map<String, List<ExecuteStage>> skippedStages = new HashMap<>();
    while (iterator.hasNext()) {
      Grouping next = iterator.next();
      if (!(next instanceof ClusterGrouping)) {
        throw new AmbariException("Invalid group type " + next.getClass().getSimpleName() + " expected cluster group");
      }
      ClusterGrouping clusterGroup = (ClusterGrouping) next;

      boolean added = addGroupingStages(clusterGroup.executionStages, clusterGroup.addAfterGroupEntry);
      if (added) {
        addSkippedStages(skippedStages, clusterGroup.executionStages);
      }
      else {
        // store these services until later
        if (skippedStages.containsKey(next.addAfterGroupEntry)) {
          List<ExecuteStage> tmp = skippedStages.get(clusterGroup.addAfterGroupEntry);
          tmp.addAll(clusterGroup.executionStages);
        }
        else {
          skippedStages.put(clusterGroup.addAfterGroupEntry, clusterGroup.executionStages);
        }
      }
    }
  }
Attempts to merge the given cluster groupings.  This merges the execute stages
in an order specific manner.
ambari-server/src/main/java/org/apache/ambari/server/stack/upgrade/ClusterGrouping.java