我正在寻找默认值Spring Batch Framework添加了作业" BatchStatus"基于" EXITSTATUS"的值(寻找defalut值框架添加)。我试着查看一些我没有找到的spring批处理框架类文件的源代码。可以请一些人发布类名,我可以在框架源代码中找到默认逻辑。
例如何时(模拟代码)
if(EXITSTATUS is FAILED)
{
jobs.setBatchStatus(FAILED)
}
答案 0 :(得分:2)
1. Default Exit Status is UNKNOWN and Default Status is STARTING
(org.springframework.batch.core.JobExecution)
private volatile BatchStatus status = BatchStatus.STARTING;
private volatile ExitStatus exitStatus = ExitStatus.UNKNOWN;
2. First time run is STARTED as
org.springframework.batch.core.job.AbstractJob
if (execution.getStatus() != BatchStatus.STOPPING) {
execution.setStartTime(new Date());
updateStatus(execution, BatchStatus.STARTED);
3. If your job is based on SimpleJob so
Job Status is updated based on Step Execution's Status (Note: they will apply upgrade status ) and
Job Exit Status is updated base on Step Execution's Exit Status
org.springframework.batch.core.job.SimpleJob
if (stepExecution != null) {
logger.debug("Upgrading JobExecution status: " + stepExecution);
execution.upgradeStatus(stepExecution.getStatus());
execution.setExitStatus(stepExecution.getExitStatus());
}
4. If your job is based on FlowJob, Status and ExitStatus is updated based on the method
org.springframework.batch.core.job.flow.JobFlowExecutor
public void updateJobExecutionStatus(FlowExecutionStatus status) {
execution.setStatus(findBatchStatus(status));
exitStatus = exitStatus.and(new ExitStatus(status.getName()));
execution.setExitStatus(exitStatus);
}
We are seeing Status and Exit Status are updating separately and no logic Spring set Status based on Exit Status. They are based on StepExecutionStatus or FlowExecutionStatus.