}
private Map<String, ExecutionContext> getContexts(StepExecution stepExecution, int gridSize) {
ExecutionContext context = stepExecution.getExecutionContext();
String key = SimpleStepExecutionSplitter.class.getSimpleName() + ".GRID_SIZE";
// If this is a restart we must retain the same grid size, ignoring the
// one passed in...
int splitSize = (int) context.getLong(key, gridSize);
context.putLong(key, splitSize);
Map<String, ExecutionContext> result;
if (context.isDirty()) {
// The context changed so we didn't already know the partitions
jobRepository.updateExecutionContext(stepExecution);
result = partitioner.partition(splitSize);
}
else {
if (partitioner instanceof PartitionNameProvider) {
result = new HashMap<String, ExecutionContext>();
Collection<String> names = ((PartitionNameProvider) partitioner).getPartitionNames(splitSize);
for (String name : names) {
/*
* We need to return the same keys as the original (failed)
* execution, but the execution contexts will be discarded
* so they can be empty.
*/
result.put(name, new ExecutionContext());
}
}
else {
// If no names are provided, grab the partition again.
result = partitioner.partition(splitSize);