Пример #1
0
  /**
   * Finalizes a {@code Step} execution by a given context in which the step was performed and by
   * the exit status of the step.
   *
   * @param context The context in which the {@code Step} was executed.
   * @param step The step to finalize.
   * @param exitStatus Indicates if the execution described by the step ended successfully or not.
   */
  public static void endStep(ExecutionContext context, Step step, boolean exitStatus) {
    if (context == null) {
      return;
    }
    if (context.isMonitored()) {
      Job job = context.getJob();
      try {
        if (step != null) {
          step.markStepEnded(exitStatus);
          JobRepositoryFactory.getJobRepository().updateStep(step);
        }

        if (context.getExecutionMethod() == ExecutionMethod.AsJob && job != null && !exitStatus) {
          // step failure will cause the job to be marked as failed
          context.setCompleted(true);
          job.markJobEnded(false);
          JobRepositoryFactory.getJobRepository().updateCompletedJobAndSteps(job);
        } else {
          Step parentStep = context.getStep();
          if (context.getExecutionMethod() == ExecutionMethod.AsStep && parentStep != null) {
            context.setCompleted(true);
            if (!exitStatus) {
              job.markJobEnded(false);
              JobRepositoryFactory.getJobRepository().updateCompletedJobAndSteps(job);
            }
          }
        }
      } catch (Exception e) {
        log.error(e);
      }
    }
  }
Пример #2
0
 private static void endJob(boolean exitStatus, Job job) {
   job.markJobEnded(exitStatus);
   try {
     JobRepositoryFactory.getJobRepository().updateCompletedJobAndSteps(job);
   } catch (Exception e) {
     log.errorFormat("Failed to end Job {0}, {1}", job.getId(), job.getActionType().name(), e);
   }
 }
Пример #3
0
 /**
  * Updates Job for the same entity for a specific action as completed with a given exit status.
  *
  * @param entityId The entity to search for its jobs
  * @param actionType The action type to search for
  * @param status The exist status to be set for the job
  */
 public static void updateSpecificActionJobCompleted(
     Guid entityId, VdcActionType actionType, boolean status) {
   try {
     List<Job> jobs =
         JobRepositoryFactory.getJobRepository().getJobsByEntityAndAction(entityId, actionType);
     for (Job job : jobs) {
       if (job.getStatus() == JobExecutionStatus.STARTED) job.markJobEnded(status);
       JobRepositoryFactory.getJobRepository().updateCompletedJobAndSteps(job);
     }
   } catch (RuntimeException e) {
     log.error(e);
   }
 }