Ejemplo n.º 1
0
  /** Update tasks according to cluster status */
  protected synchronized void tasksRunning(Set<Task> taskFoundId) {
    LinkedList<Task> finished = null;

    // Any 'running' task that was not found should be marked as finished/ERROR
    for (Task task : executioner.getTasksRunning().values()) {

      if (!taskFoundId.contains(task) // Task not found by command?
          && (task.elapsedSecs()
              > TASK_STATE_MIN_START_TIME) // Make sure that it's been running for a while
                                           // (otherwise it might that the task has just started and
                                           // the cluster is not reporting it yet)
          && !task.isDone() // Is the task "not finished"?
      ) {
        // Task is missing.
        // Update counter: Should we consider this task as 'missing'?
        if (incMissingCount(task)) {
          if (finished == null) finished = new LinkedList<Task>();
          finished.add(task);
        }
      } else {
        // Task was found, reset 'missing' counter (if any)
        resetMissingCount(task);
      }
    }

    // ---
    // Any task to mark as finished/ERROR?
    // ---
    if (finished != null) {
      for (Task task : finished) {
        String tpid = task.getPid() != null ? task.getPid() : "";

        if (!tpid.isEmpty()
            && !task.isDone()) { // Make sure the task is not finished (race conditions?)
          if (debug) log("Task PID '" + task.getPid() + "' not found. Marking it as finished.");
          task.setErrorMsg("Task dissapeared from cluster's queue. Task or node failure?");
          task.setExitValue(Task.EXITCODE_ERROR);
          executioner.taskFinished(task, TaskState.ERROR);
        }
      }
    }
  }
Ejemplo n.º 2
0
  /** Find a running task given a PID */
  protected Set<Task> findRunningTaskByPid(Set<String> pids) {
    HashSet<Task> tasks = new HashSet<Task>();

    // Find task by PID
    for (Task t : executioner.getTasksRunning().values()) {
      String pid = t.getPid();

      if (pid != null) {
        // Matches pid?
        if (pids.contains(pid) || pids.contains(parsePidPart(pid))) {
          if (debug) log("Found task PID '" + pid + "'");
          tasks.add(t);
        }
      }
    }

    return tasks;
  }
Ejemplo n.º 3
0
 void log(String msg) {
   executioner.log(this.getClass().getSimpleName() + ":" + msg);
 }