private boolean createAndAllocateExecution(Job job, Task task, WorkerEntry chosenWorker) {

    GridProcess replica = null;
    if (canReplicate(task)) {
      replica = job.createAndAllocateExecution(task.getTaskid(), chosenWorker);
      replica.setRunningState(stateMachine.getInitialState());
    }

    if (replica != null) {
      chosenWorker.allocate(replica);

      WorkerEntry worker =
          WorkerInfo.getInstance()
              .getWorker(chosenWorker.getServiceID().getContainerID().toString());
      worker.allocate(replica);
      return true;
    }

    return false;
  }
  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;
  }
  private List<GetOperationTO> fillFinalGetOperations(
      List<ProcessCommand> list, Task task, int processId, String workerID, long requestId) {
    List<GetOperationTO> getOperationsList = new ArrayList<GetOperationTO>();

    for (ProcessCommand process : list) {

      GetOperationTO to = new GetOperationTO();
      to.setEndTime(process.getTransferEnd());
      to.setInitTime(process.getTransferBegin());
      to.setJobID(task.getJobId());
      to.setLocalFilePath(process.getFileName());
      to.setProcessID(processId);
      to.setRemoteFilePath(process.getDestination());
      to.setRequestID2(requestId);
      to.setTaskID(task.getTaskid());
      to.setTransferDescription(process.getHandle().getDescription());
      to.setWorkerID2(workerID);
      to.setFileSize(process.getFileSize());

      getOperationsList.add(to);
    }

    return getOperationsList;
  }