private Integer countFailedTasksBeforeStartingBatch(RequestExecution requestExecution, long startingBatchOrderId) throws AmbariException {
    int result = 0;
    Batch batch = requestExecution.getBatch();
    if (batch != null) {
      List<BatchRequest> batchRequests = batch.getBatchRequests();
      if (batchRequests != null) {
        Collections.sort(batchRequests);
        for (BatchRequest batchRequest : batchRequests) {
          if (batchRequest.getOrderId() >= startingBatchOrderId) break;

          if (batchRequest.getRequestId() != null) {
            BatchRequestResponse batchRequestResponse = getBatchRequestResponse(batchRequest.getRequestId(), requestExecution.getClusterName());
            if (batchRequestResponse != null) {
               result += batchRequestResponse.getFailedTaskCount() +
                         batchRequestResponse.getAbortedTaskCount() +
                         batchRequestResponse.getTimedOutTaskCount();
            }
          }
        }
      }
    }
    return result;
  }
Persist jobs based on the request batches staring from the defined batch and create trigger for the first
job
@param requestExecution
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java