private Boolean updateActiveStagesStatus(final Set<StageEntityPK> stagesWithReceivedTaskStatus, List<HostRoleCommand> hostRoleCommandListAll) {
    Boolean didAnyStageStatusUpdated = Boolean.FALSE;
    for (StageEntityPK reportedStagePK : stagesWithReceivedTaskStatus) {
      if (activeStageMap.containsKey(reportedStagePK)) {
        Boolean didStatusChange = updateStageStatus(reportedStagePK, hostRoleCommandListAll);
        if (didStatusChange) {
          ActiveStage reportedStage = activeStageMap.get(reportedStagePK);
          stageDAO.updateStatus(reportedStagePK, reportedStage.getStatus(), reportedStage.getDisplayStatus());
          didAnyStageStatusUpdated = Boolean.TRUE;
        }
      } else {
        LOG.error(String.format("Received update for a task whose stage is not being tracked as running stage: %s", reportedStagePK.toString()));
      }

    }
    return didAnyStageStatusUpdated;
  }
update and persist all changed stage status
@param stagesWithReceivedTaskStatus set of stages that has received task status
@param hostRoleCommandListAll list of all task updates received from agent
@return  <code>true</code> if any of the stage has changed it's existing status;
         <code>false</code> otherwise
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListener.java