private void aggregate(Map<Long, HostRoleCommandStatusSummaryDTO> smap,
      Resource upgradeGroup, Long requestId, Set<Long> stageIds, Set<String> requestedIds) {

    int size = 0;

    Map<HostRoleStatus, Integer> counts = CalculatedStatus.calculateTaskStatusCounts(smap, stageIds);

    CalculatedStatus stageStatus = CalculatedStatus.statusFromStageSummary(smap, stageIds);

    for (Integer i : counts.values()) {
      size += i.intValue();
    }

    Integer inProgress = 0;
    Integer completed = 0;

    for (Entry<HostRoleStatus, Integer> entry : counts.entrySet()) {
      if (entry.getKey().isCompletedState()) {
        completed += entry.getValue();
      } else if (entry.getKey().isInProgress()) {
        inProgress += entry.getValue();
      }
    }
    setResourceProperty(upgradeGroup, UPGRADE_GROUP_TOTAL_TASKS, size, requestedIds);
    setResourceProperty(upgradeGroup, UPGRADE_GROUP_IN_PROGRESS_TASKS, inProgress, requestedIds);
    setResourceProperty(upgradeGroup, UPGRADE_GROUP_COMPLETED_TASKS, completed, requestedIds);

    setResourceProperty(upgradeGroup, UPGRADE_GROUP_STATUS, stageStatus.getStatus(), requestedIds);
    setResourceProperty(upgradeGroup, UPGRADE_GROUP_DISPLAY_STATUS, stageStatus.getDisplayStatus(), requestedIds);
    setResourceProperty(upgradeGroup, UPGRADE_GROUP_PROGRESS_PERCENT, stageStatus.getPercent(), requestedIds);
  }
Aggregates status, percent complete, and count information for stages and
puts the results on the upgrade group

@param upgradeGroup  the resource representing an upgrade group
@param stageIds      the set of resources ids of the stages
@param requestedIds  the ids for the request
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeGroupResourceProvider.java