/* (non-Javadoc)
   * @see org.ourgrid.broker.heuristic.Heuristic#verifyFailure(org.ourgrid.common.job.Task)
   */
  public boolean verifyFailure(Task task, GridProcessState state) {

    int actualFails = task.getActualFails();

    if (state.equals(GridProcessState.FAILED)) {
      actualFails++;
    }

    return actualFails >= maxFails && !task.hasGridProcessInExecution();
  }
  private boolean verifyTaskCanBeProcessed(Task task) {

    if (task.getActualFails() >= maxFails
        || task.hasFinishedReplica()
        || GridProcessState.CANCELLED.equals(task.getState())) {
      return false;
    }

    return true;
  }
  private TaskStatusInfo fillTask(Task task) {

    List<GridProcessStatusInfo> processesList = new ArrayList<GridProcessStatusInfo>();

    for (GridProcess process : task.getGridProcesses()) {
      processesList.add(fillProcess(process));
    }

    TaskStatusInfo taskInfo =
        new TaskStatusInfo(
            task.getTaskid(),
            task.getJobId(),
            task.getState().toString(),
            task.getActualFails(),
            task.getSpec(),
            processesList,
            task.getCreationTime(),
            task.getFinalizationTime());

    return taskInfo;
  }