Tweak step execution aggregation

This commit is contained in:
dsyer
2008-11-13 08:58:32 +00:00
parent ef00a5e333
commit d19145d0af
4 changed files with 19 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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