private void updateActiveRequestsStatus(final Set<Long> requestIdsWithReceivedTaskStatus, Set<StageEntityPK> stagesWithChangedTaskStatus) {
    for (Long reportedRequestId : requestIdsWithReceivedTaskStatus) {
      if (activeRequestMap.containsKey(reportedRequestId)) {
        ActiveRequest request =  activeRequestMap.get(reportedRequestId);
        Boolean didStatusChange = updateRequestStatus(reportedRequestId, stagesWithChangedTaskStatus);
        if (didStatusChange) {
          requestDAO.updateStatus(reportedRequestId, request.getStatus(), request.getDisplayStatus());
        }
        if (request.isCompleted() && isAllTasksCompleted(reportedRequestId)) {
          // Request is considered ton have been finished if request status and all of it's tasks status are completed
          // in that case, request and it's stages
          // and tasks should no longer be tracked as active(running)
          removeRequestStageAndTasks(reportedRequestId);
        }
      } else {
        LOG.error(String.format("Received update for a task whose request %d is not being tracked as running request", reportedRequestId));
      }

    }
  }
update and persist changed request status
@param requestIdsWithReceivedTaskStatus set of request ids that has received tasks status
@param stagesWithChangedTaskStatus set of stages that have received tasks with changed status
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListener.java