Updated the JsrStepExecutionSplitter to provide a copy of the JobExecution per partition

This commit is contained in:
Michael Minella
2013-12-16 14:07:44 -06:00
parent 874a171601
commit b9b23e639d
4 changed files with 30 additions and 2 deletions

View File

@@ -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.

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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();
}