Exemple #1
0
  /**
   * Change a task's state, and update the job's state if appropriate
   *
   * @param task The task to modify
   * @param newState The new state to set
   * @param force Whether to force the state transition regardless of the expected transition map
   * @return True on success
   */
  public synchronized boolean setTaskState(JobTask task, JobTaskState newState, boolean force) {
    JobTaskState prevState = task.getState();

    if (!task.setState(newState, force)) {
      return false;
    }
    if (prevState.isActiveState() && !newState.isActiveState()) {
      this.countActiveTasks--;
    } else if (!prevState.isActiveState() && newState.isActiveState()) {
      this.countActiveTasks++;
    }
    if (newState == JobTaskState.ERROR) {
      this.disabled = true;
    }
    calculateJobState(force);
    return true;
  }
Exemple #2
0
 static {
   for (JobTaskState state : JobTaskState.values()) {
     map.put(state.getValue(), state);
   }
 }