private boolean verifyRunningProccess(Task task) {

    int running = 0;

    for (GridProcess replica : task.getGridProcesses()) {
      GridProcessState replicaState = replica.getState();

      if (GridProcessState.RUNNING.equals(replicaState)
          || GridProcessState.UNSTARTED.equals(replicaState)) {
        running++;
      }
    }

    return running < maxReplicas
        && (GridProcessState.RUNNING.equals(task.getState())
            || GridProcessState.UNSTARTED.equals(task.getState()));
  }
Esempio n. 2
0
  public void setAsRunning() {

    if (!GridProcessState.UNSTARTED.equals(this.state)) {
      throw new IllegalResultException(
          "This replica is already running or has already finished execution", replicaHandle);
    }

    this.state = GridProcessState.RUNNING;
  }
Esempio n. 3
0
  /**
   * Mark's this <code>GridProcess</code> as running, in other words this replica will change state
   * to <code>GridProcessState.RUNNING</code> if it is in <code>GridProcessState.UNSTARTED</code>.
   *
   * @param chosenWorker Spec of the worker that will run this replica.
   */
  public void allocate(WorkerEntry chosenWorker) {

    if (!GridProcessState.UNSTARTED.equals(this.state)) {
      throw new IllegalResultException(
          "This replica is already running or has already finished execution", replicaHandle);
    }

    this.workerEntry = chosenWorker;
    RequestSpecification requestSpec = workerEntry.getRequestSpecification();

    if (requestSpec != null) {
      this.replicaAccounting =
          new GridProcessAccounting(
              requestSpec.getRequestId(),
              requestSpec.getJobId(),
              requestSpec.getRequiredWorkers(),
              requestSpec.getMaxFails(),
              requestSpec.getMaxReplicas(),
              getWorkerEntry().getWorkerID(),
              getWorkerEntry().getWorkerPublicKey(),
              workerEntry.getWorkerSpecification());
    }
  }