public boolean hasToleranceThresholdExceeded(Long executionId,
      String clusterName, Map<String, Integer> taskCounts) throws AmbariException {

    Cluster cluster = clusters.getCluster(clusterName);
    RequestExecution requestExecution = cluster.getAllRequestExecutions().get(executionId);

    if (requestExecution == null) {
      throw new AmbariException("Unable to find request schedule with id = "
        + executionId);
    }

    BatchSettings batchSettings = requestExecution.getBatch().getBatchSettings();

    boolean result = false;
    if (batchSettings != null) {
      if (batchSettings.getTaskFailureToleranceLimit() != null) {
        result = taskCounts.get(BatchRequestJob.BATCH_REQUEST_FAILED_TASKS_KEY) > batchSettings.getTaskFailureToleranceLimit();
      }
      if (batchSettings.getTaskFailureToleranceLimitPerBatch() != null) {
        result = result || taskCounts.get(BatchRequestJob.BATCH_REQUEST_FAILED_TASKS_IN_CURRENT_BATCH_KEY) >
            batchSettings.getTaskFailureToleranceLimitPerBatch();
      }
    }

    return result;
  }
Check if the allowed threshold for failed tasks has exceeded.
This needs to be an absolute value of tasks.
@param executionId
@param clusterName
@param taskCounts
@return
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java