public static HostRoleStatus calculateSummaryStatusFromPartialSet(Map<HostRoleStatus, Integer> counters,
                                                      boolean skippable) {

    HostRoleStatus status = HostRoleStatus.PENDING;
    // By definition, any tasks in a future stage must be held in a PENDING status.
    if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) {
      status =  counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING :
          counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED :
              HostRoleStatus.HOLDING_TIMEDOUT;
    }

    // Because tasks are not skippable, guaranteed to be FAILED
    if (counters.get(HostRoleStatus.FAILED) > 0 && !skippable) {
      status = HostRoleStatus.FAILED;
    }

    // Because tasks are not skippable, guaranteed to be TIMEDOUT
    if (counters.get(HostRoleStatus.TIMEDOUT) > 0  && !skippable) {
      status = HostRoleStatus.TIMEDOUT;
    }

    int inProgressTasks =  counters.get(HostRoleStatus.QUEUED) + counters.get(HostRoleStatus.IN_PROGRESS);
    if (inProgressTasks > 0) {
      status = HostRoleStatus.IN_PROGRESS;
    }

    return status;
  }
@param counters counts of resources that are in various states
@param skippable {Boolean} <code>TRUE<code/> if failure of any of the task should not fail the stage
@return {@link HostRoleStatus}
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java