RESOLVED - BATCH-896: "DRY" FaultTolerantTasklet implementations
javadoc cleanup
This commit is contained in:
@@ -154,7 +154,9 @@ public abstract class AbstractFaultTolerantChunkOrientedTasklet<I, O> extends Ab
|
||||
}
|
||||
|
||||
/**
|
||||
* Incorporate retry into the item processor stage.
|
||||
* Incorporate retry into the item processor stage. If item processor
|
||||
* returns null for an input item, it is considered filtered and is not
|
||||
* added to outputs.
|
||||
*
|
||||
* @param inputs the items to process
|
||||
* @param outputs the items to write
|
||||
|
||||
@@ -42,18 +42,21 @@ import org.springframework.core.AttributeAccessor;
|
||||
* listener is invoked and the skip count incremented. A retryable exception is
|
||||
* thus also effectively also implicitly skippable.
|
||||
*
|
||||
* <code>ItemProcessor</code> is assumed to be transactional. In case of rollback caused by
|
||||
* error on write the processing phase will be repeated.
|
||||
* <code>ItemProcessor</code> is assumed to be transactional. In case of
|
||||
* rollback caused by error on write the processing phase will be repeated.
|
||||
*
|
||||
* @param <I> input item type
|
||||
* @param <O> output item type
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class FaultTolerantChunkOrientedTasklet<I, S> extends AbstractFaultTolerantChunkOrientedTasklet<I, S> {
|
||||
public class FaultTolerantChunkOrientedTasklet<I, O> extends AbstractFaultTolerantChunkOrientedTasklet<I, O> {
|
||||
|
||||
final static private String INPUT_BUFFER_KEY = "INPUT_BUFFER_KEY";
|
||||
|
||||
public FaultTolerantChunkOrientedTasklet(ItemReader<? extends I> itemReader,
|
||||
ItemProcessor<? super I, ? extends S> itemProcessor, ItemWriter<? super S> itemWriter,
|
||||
ItemProcessor<? super I, ? extends O> itemProcessor, ItemWriter<? super O> itemWriter,
|
||||
RepeatOperations chunkOperations, RetryOperations retryTemplate,
|
||||
Classifier<Throwable, Boolean> rollbackClassifier, ItemSkipPolicy readSkipPolicy,
|
||||
ItemSkipPolicy writeSkipPolicy, ItemSkipPolicy processSkipPolicy) {
|
||||
@@ -63,10 +66,9 @@ public class FaultTolerantChunkOrientedTasklet<I, S> extends AbstractFaultTolera
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next item from {@link #read(StepContribution, List)} and if not
|
||||
* null pass the item to {@link #write(List, StepContribution, Map)}. If the
|
||||
* {@link ItemProcessor} returns null, the write is omitted and another item
|
||||
* taken from the reader.
|
||||
* Read the next chunk of items and if not empty pass the items one-by-one
|
||||
* to {@link #process(StepContribution, List, List, Map)} and finally write
|
||||
* all items by {@link #write(List, StepContribution, Map)}.
|
||||
*
|
||||
* @see org.springframework.batch.core.step.tasklet.Tasklet#execute(org.springframework.batch.core.StepContribution,
|
||||
* AttributeAccessor)
|
||||
@@ -74,7 +76,7 @@ public class FaultTolerantChunkOrientedTasklet<I, S> extends AbstractFaultTolera
|
||||
public ExitStatus execute(final StepContribution contribution, AttributeAccessor attributes) throws Exception {
|
||||
|
||||
final List<I> inputs = getBufferedList(attributes, INPUT_BUFFER_KEY);
|
||||
final List<S> outputs = new ArrayList<S>();
|
||||
final List<O> outputs = new ArrayList<O>();
|
||||
|
||||
ExitStatus result = ExitStatus.CONTINUABLE;
|
||||
|
||||
@@ -108,7 +110,7 @@ public class FaultTolerantChunkOrientedTasklet<I, S> extends AbstractFaultTolera
|
||||
process(contribution, inputs, outputs, skippedInputs);
|
||||
}
|
||||
|
||||
Map<S, Exception> skippedOutputs = getBufferedSkips(attributes, SKIPPED_OUTPUTS_KEY);
|
||||
Map<O, Exception> skippedOutputs = getBufferedSkips(attributes, SKIPPED_OUTPUTS_KEY);
|
||||
outputs.removeAll(skippedOutputs.keySet());
|
||||
write(outputs, contribution, skippedOutputs);
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ import org.springframework.core.AttributeAccessor;
|
||||
* Note that the implementation relies on {@link Object#equals(Object)}
|
||||
* comparisons for recognizing items on retry/skip.
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*
|
||||
* @param <I> input item type
|
||||
* @param <O> output item type
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class NonbufferingFaultTolerantChunkOrientedTasklet<I, O> extends
|
||||
AbstractFaultTolerantChunkOrientedTasklet<I, O> {
|
||||
@@ -99,7 +99,7 @@ public class NonbufferingFaultTolerantChunkOrientedTasklet<I, O> extends
|
||||
* @param contribution current StepContribution holding skipped items count
|
||||
* @return next item for processing
|
||||
*/
|
||||
private I read(StepContribution contribution, final List<Exception> skipped) throws Exception {
|
||||
protected I read(StepContribution contribution, final List<Exception> skipped) throws Exception {
|
||||
|
||||
try {
|
||||
return doRead();
|
||||
|
||||
Reference in New Issue
Block a user