Tweak step execution aggregation
This commit is contained in:
@@ -74,7 +74,13 @@ public class PartitionStep extends AbstractStep {
|
||||
// Wait for task completion and then aggregate the results
|
||||
Collection<StepExecution> executions = partitionHandler.handle(stepExecutionSplitter, stepExecution);
|
||||
aggregator.aggregate(stepExecution, executions);
|
||||
if (stepExecution.getStatus()!=BatchStatus.COMPLETED) {
|
||||
|
||||
if (stepExecution.getJobExecution().isPaused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If anything failed or had a problem we need to crap out
|
||||
if (stepExecution.getStatus() != BatchStatus.COMPLETED) {
|
||||
throw new JobExecutionException("Partition handler returned an incomplete step");
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ public class StepExecutionAggregator {
|
||||
if (executions == null || executions.isEmpty()) {
|
||||
throw new IllegalArgumentException("Cannot aggregate empty or null executions: " + executions);
|
||||
}
|
||||
// Start with assumption that it is complete...
|
||||
result.setStatus(BatchStatus.COMPLETED);
|
||||
for (StepExecution stepExecution : executions) {
|
||||
BatchStatus status = stepExecution.getStatus();
|
||||
result.setStatus(BatchStatus.max(result.getStatus(), status));
|
||||
|
||||
@@ -43,6 +43,16 @@ public class StepExecutionAggregatorTests {
|
||||
assertEquals(BatchStatus.COMPLETED, result.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAggregateStatusFromFailure() {
|
||||
result.setStatus(BatchStatus.FAILED);
|
||||
stepExecution1.setStatus(BatchStatus.COMPLETED);
|
||||
stepExecution2.setStatus(BatchStatus.COMPLETED);
|
||||
aggregator.aggregate(result, Arrays.<StepExecution> asList(stepExecution1, stepExecution2));
|
||||
assertNotNull(result);
|
||||
assertEquals(BatchStatus.FAILED, result.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAggregateStatusIncomplete() {
|
||||
stepExecution1.setStatus(BatchStatus.COMPLETED);
|
||||
|
||||
@@ -105,6 +105,8 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
|
||||
|
||||
assertStepExecutionsAreEqual(stepExecution, retrieved);
|
||||
assertNotNull(retrieved.getVersion());
|
||||
assertNotNull(retrieved.getJobExecution());
|
||||
assertNotNull(retrieved.getJobExecution().getId());
|
||||
|
||||
assertNull(dao.getStepExecution(jobExecution, "not-existing step"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user