public void AndTest() { ExitStatus running = ExitStatus.Executing; ExitStatus runnningAndNull = running.And(null); Assert.AreEqual(running, runnningAndNull); ExitStatus completed = ExitStatus.Completed; running = running.And(completed); Assert.AreEqual(completed, running); }
/// <summary> /// Call to listeners that might add some post execution behaviour. /// </summary> /// <param name="execution"></param> private void HandlePostExecution(JobExecution execution) { try { if (execution.Status.IsLessThanOrEqualTo(BatchStatus.Stopped) && !execution.StepExecutions.Any()) { ExitStatus exitStatus = execution.ExitStatus; ExitStatus newExitStatus = ExitStatus.Noop.AddExitDescription("All steps already completed or no steps configured for this job."); execution.ExitStatus = exitStatus.And(newExitStatus); } execution.EndTime = DateTime.Now; try { _listener.AfterJob(execution); } catch (Exception e) { Logger.Error(e, "Exception encountered in afterStep callback"); } JobRepository.Update(execution); Logger.Debug("Current job execution: {0}", execution); } finally { JobSynchronizationManager.Release(); } }
/// <summary> /// /// </summary> /// <param name="stepExecution"></param> /// <param name="exitStatus"></param> /// <returns></returns> private ExitStatus HandleListener(StepExecution stepExecution, ExitStatus exitStatus) { ExitStatus returnedExitStatus = exitStatus; try { // Update the step execution to the latest known value so the // listeners can act on it returnedExitStatus = returnedExitStatus.And(stepExecution.ExitStatus); stepExecution.ExitStatus = returnedExitStatus; Logger.Trace("_stepExecutionListener.AfterStep CALL"); returnedExitStatus = returnedExitStatus.And(_stepExecutionListener.AfterStep(stepExecution)); } catch (Exception e) { Logger.Error(e, "Exception in afterStep callback in step {0} in job {1}", Name, stepExecution.JobExecution.JobInstance.JobName); } return(returnedExitStatus); }
/// <summary> /// /// </summary> /// <param name="stepExecution"></param> /// <param name="exitStatus"></param> private void HandleUpdateStepExecution(StepExecution stepExecution, ExitStatus exitStatus) { try { JobRepository.Update(stepExecution); } catch (Exception e) { stepExecution.BatchStatus = BatchStatus.Unknown; stepExecution.ExitStatus = exitStatus.And(ExitStatus.Unknown); stepExecution.AddFailureException(e); Logger.Error(e, "Encountered an error saving batch meta data for step {0} in job {1}. This job is now in an unknown state and should not be restarted.", Name, stepExecution.JobExecution.JobInstance.JobName); } }
/// <summary> /// /// </summary> /// <param name="stepExecution"></param> /// <param name="exitStatus"></param> /// <returns></returns> private ExitStatus HandleUpdateExecutionContext(StepExecution stepExecution, ExitStatus exitStatus) { ExitStatus returnedExitStatus = exitStatus; try { JobRepository.UpdateExecutionContext(stepExecution); } catch (Exception e) { stepExecution.BatchStatus = BatchStatus.Unknown; returnedExitStatus = exitStatus.And(ExitStatus.Unknown); stepExecution.AddFailureException(e); Logger.Error(e, "Encountered an error saving batch meta data for step {0} in job {1}. This job is now in an unknown state and should not be restarted.", Name, stepExecution.JobExecution.JobInstance.JobName); } stepExecution.EndTime = DateTime.Now; stepExecution.ExitStatus = returnedExitStatus; return(returnedExitStatus); }
/// <summary> /// /// </summary> /// <param name="stepExecution"></param> /// <param name="e"></param> /// <param name="exitStatus"></param> /// <returns></returns> private ExitStatus HandleExecutionException(StepExecution stepExecution, Exception e, ExitStatus exitStatus) { stepExecution.UpgradeStatus(DetermineBatchStatus(e)); ExitStatus returnedExitStatus = exitStatus.And(GetDefaultExitStatusForFailure(e)); stepExecution.AddFailureException(e); if (stepExecution.BatchStatus == BatchStatus.Stopped) { Logger.Info("Encountered interruption executing step {0} in job {1} : {2}", Name, stepExecution.JobExecution.JobInstance.JobName, e.Message); if (Logger.IsDebugEnabled) { Logger.Debug(e, "Full exception"); } } else { Logger.Error(e, "Encountered an error executing step {0} in job {1} :", Name, stepExecution.JobExecution.JobInstance.JobName); } return(returnedExitStatus); }
/// <summary> /// /// </summary> /// <param name="stepExecution"></param> /// <param name="e"></param> /// <param name="exitStatus"></param> /// <returns></returns> private ExitStatus HandleExecutionException(StepExecution stepExecution, Exception e, ExitStatus exitStatus) { stepExecution.UpgradeStatus(DetermineBatchStatus(e)); ExitStatus returnedExitStatus = exitStatus.And(GetDefaultExitStatusForFailure(e)); stepExecution.AddFailureException(e); if (stepExecution.BatchStatus == BatchStatus.Stopped) { Logger.Info("Encountered interruption executing step {0} in job {1} : {2}", Name, stepExecution.JobExecution.JobInstance.JobName, e.Message); if (Logger.IsDebugEnabled) { Logger.Debug(e, "Full exception"); } } else { Logger.Error(e, "Encountered an error executing step {0} in job {1} :", Name, stepExecution.JobExecution.JobInstance.JobName); } return returnedExitStatus; }
/// <summary> /// /// </summary> /// <param name="stepExecution"></param> /// <param name="exitStatus"></param> /// <returns></returns> private ExitStatus HandleUpdateExecutionContext(StepExecution stepExecution, ExitStatus exitStatus) { ExitStatus returnedExitStatus = exitStatus; try { JobRepository.UpdateExecutionContext(stepExecution); } catch (Exception e) { stepExecution.BatchStatus = BatchStatus.Unknown; returnedExitStatus = exitStatus.And(ExitStatus.Unknown); stepExecution.AddFailureException(e); Logger.Error(e, "Encountered an error saving batch meta data for step {0} in job {1}. This job is now in an unknown state and should not be restarted.", Name, stepExecution.JobExecution.JobInstance.JobName); } stepExecution.EndTime = DateTime.Now; stepExecution.ExitStatus = returnedExitStatus; return returnedExitStatus; }
/// <summary> /// @see IFlowExecutor#UpdateJobExecutionStatus . /// </summary> /// <param name="status"></param> public void UpdateJobExecutionStatus(FlowExecutionStatus status) { _execution.Status = FindBatchStatus(status); ExitStatus = ExitStatus.And(new ExitStatus(status.Name)); _execution.ExitStatus = ExitStatus; }