Beispiel #1
0
  public File getJobMetaDataFile(String jobId, int attempt) {
    ExecutableNode node = flow.getExecutableNode(jobId);
    File path = new File(execDir, node.getJobPropsSource());

    String metaDataFileName = JobRunner.createMetaDataFileName(execId, jobId, attempt);
    File metaDataFile = new File(path.getParentFile(), metaDataFileName);

    if (!metaDataFile.exists()) {
      return null;
    }

    return metaDataFile;
  }
Beispiel #2
0
  private Status getImpliedStatus(ExecutableNode node) {
    switch (node.getStatus()) {
      case FAILED:
      case KILLED:
      case SKIPPED:
      case SUCCEEDED:
      case QUEUED:
      case RUNNING:
        return null;
      default:
        break;
    }

    boolean shouldKill = false;
    for (String dependency : node.getInNodes()) {
      ExecutableNode dependencyNode = flow.getExecutableNode(dependency);

      Status depStatus = dependencyNode.getStatus();
      switch (depStatus) {
        case FAILED:
        case KILLED:
          shouldKill = true;
        case SKIPPED:
        case SUCCEEDED:
          continue;
        case RUNNING:
        case QUEUED:
        case DISABLED:
          return null;
        default:
          // Return null means it's not ready to run.
          return null;
      }
    }

    ExecutionOptions options = flow.getExecutionOptions();
    if (shouldKill
        || flowCancelled
        || (flowFailed && options.getFailureAction() != FailureAction.FINISH_ALL_POSSIBLE)) {
      return Status.KILLED;
    }

    // If it's disabled but ready to run, we want to make sure it continues being disabled.
    if (node.getStatus() == Status.DISABLED) {
      return Status.DISABLED;
    }

    // All good to go, ready to run.
    return Status.READY;
  }
Beispiel #3
0
  private boolean isFlowFinished() {
    if (!activeJobRunners.isEmpty()) {
      return false;
    }

    for (String end : flow.getEndNodes()) {
      ExecutableNode node = flow.getExecutableNode(end);
      if (!Status.isStatusFinished(node.getStatus())) {
        return false;
      }
    }

    return true;
  }
Beispiel #4
0
  private void reEnableDependents(ExecutableNode node) {
    for (String dependent : node.getOutNodes()) {
      ExecutableNode dependentNode = flow.getExecutableNode(dependent);

      if (dependentNode.getStatus() == Status.KILLED) {
        dependentNode.setStatus(Status.READY);
        dependentNode.setUpdateTime(System.currentTimeMillis());
        reEnableDependents(dependentNode);
      } else if (dependentNode.getStatus() == Status.SKIPPED) {
        dependentNode.setStatus(Status.DISABLED);
        dependentNode.setUpdateTime(System.currentTimeMillis());
        reEnableDependents(dependentNode);
      }
    }
  }
Beispiel #5
0
  public void retryJobs(List<String> jobIds, String user) {
    synchronized (mainSyncObj) {
      for (String jobId : jobIds) {
        ExecutableNode node = flow.getExecutableNode(jobId);
        if (node == null) {
          logger.error(
              "Job "
                  + jobId
                  + " doesn't exist in execution "
                  + flow.getExecutionId()
                  + ". Cannot retry.");
          continue;
        }

        if (Status.isStatusFinished(node.getStatus())) {
          // Resets the status and increments the attempt number
          node.resetForRetry();
          reEnableDependents(node);
          logger.info("Re-enabling job " + node.getJobId() + " attempt " + node.getAttempt());
        } else {
          logger.error("Cannot retry job " + jobId + " since it hasn't run yet. User " + user);
          continue;
        }
      }

      boolean isFailureFound = false;
      for (ExecutableNode node : flow.getExecutableNodes()) {
        Status nodeStatus = node.getStatus();
        if (nodeStatus == Status.FAILED || nodeStatus == Status.KILLED) {
          isFailureFound = true;
          break;
        }
      }

      if (!isFailureFound) {
        flow.setStatus(Status.RUNNING);
        flow.setUpdateTime(System.currentTimeMillis());
        flowFailed = false;
      }

      updateFlow();
      interrupt();
    }
  }