Updated the JsrStepExecutionSplitter to provide a copy of the JobExecution per partition
This commit is contained in:
@@ -64,6 +64,23 @@ public class JobExecution extends Entity {
|
||||
|
||||
private final String jobConfigurationName;
|
||||
|
||||
public JobExecution(JobExecution original) {
|
||||
this.jobParameters = original.getJobParameters();
|
||||
this.jobInstance = original.getJobInstance();
|
||||
this.stepExecutions = original.getStepExecutions();
|
||||
this.status = original.getStatus();
|
||||
this.startTime = original.getStartTime();
|
||||
this.createTime = original.getCreateTime();
|
||||
this.endTime = original.getEndTime();
|
||||
this.lastUpdated = original.getLastUpdated();
|
||||
this.exitStatus = original.getExitStatus();
|
||||
this.executionContext = original.getExecutionContext();
|
||||
this.failureExceptions = original.getFailureExceptions();
|
||||
this.jobConfigurationName = original.getJobConfigurationName();
|
||||
this.setId(original.getId());
|
||||
this.setVersion(original.getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Because a JobExecution isn't valid unless the job is set, this
|
||||
* constructor is the only valid one from a modeling point of view.
|
||||
|
||||
@@ -76,7 +76,8 @@ public class JsrStepExecutionSplitter implements StepExecutionSplitter {
|
||||
|
||||
for(int i = 0; i < gridSize; i++) {
|
||||
String stepName = this.stepName + ":partition" + i;
|
||||
StepExecution curStepExecution = jobExecution.createStepExecution(stepName);
|
||||
JobExecution curJobExecution = new JobExecution(jobExecution);
|
||||
StepExecution curStepExecution = new StepExecution(stepName, curJobExecution);
|
||||
executions.add(curStepExecution);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import javax.batch.api.partition.PartitionPlanImpl;
|
||||
import javax.batch.runtime.BatchStatus;
|
||||
import javax.batch.runtime.JobExecution;
|
||||
import javax.batch.runtime.context.JobContext;
|
||||
import javax.batch.runtime.context.StepContext;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -300,12 +301,21 @@ public class PartitionParserTests {
|
||||
@BatchProperty
|
||||
String artifactName;
|
||||
|
||||
@Inject
|
||||
StepContext stepContext;
|
||||
|
||||
@Inject
|
||||
JobContext jobContext;
|
||||
|
||||
@Override
|
||||
public String process() throws Exception {
|
||||
artifactNames.add(artifactName);
|
||||
threadNames.add(Thread.currentThread().getName());
|
||||
processed++;
|
||||
|
||||
stepContext.setExitStatus("bad step exit status");
|
||||
jobContext.setExitStatus("bad job exit status");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ public class JobContextTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testIllegalContextId() throws Exception {
|
||||
context = new JobContext(new JobExecution(null));
|
||||
context = new JobContext(new JobExecution((Long) null));
|
||||
context.getId();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user