First attempt at adding more explicit skip handling and removing the need for 'SimpleStepExecutor'. There's still some cleanup that needs to happen, but it's moving in the right direction.
This commit is contained in:
@@ -37,6 +37,6 @@ public interface Chunker extends ItemStream {
|
||||
* @return the {@link Chunk} that has been read.
|
||||
* @throws IllegalArgumentException if chunkSize is less than zero.
|
||||
*/
|
||||
public ChunkingResult chunk(int chunkSize, StepExecution stepExecution) throws ReadFailureException;
|
||||
public ChunkingResult chunk(int chunkSize, StepContribution stepContribution) throws ReadFailureException;
|
||||
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@ public interface Dechunker extends ItemStream{
|
||||
* discretion of various implementations.
|
||||
*
|
||||
* @param chunk to be 'dechunked'
|
||||
* @param stepExecution the chunk belongs to.
|
||||
* @param stepContribution the chunk belongs to.
|
||||
* @return a Dechunking result detailing whether or not dechunking was successful, and
|
||||
* if any items were skipped.
|
||||
* @throws Exception, specifically throws IllegalArgumentException if either the chunk
|
||||
* or StepExecution is null.
|
||||
*/
|
||||
DechunkingResult dechunk(Chunk chunk, StepExecution stepExecution) throws Exception;
|
||||
DechunkingResult dechunk(Chunk chunk, StepContribution stepContribution) throws Exception;
|
||||
}
|
||||
|
||||
@@ -15,30 +15,32 @@
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.io.exception.WriteFailureException;
|
||||
|
||||
/**
|
||||
* Interface for defining the contract to log out read and write
|
||||
* failures encountered during batch processing. It is expected
|
||||
* that any failures encountered while writing will be
|
||||
* represented as {@link WriteFailureException}s, which contain
|
||||
* the items which caused the exception.
|
||||
* failures encountered during batch processing.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public interface SkippedItemHandler {
|
||||
public interface ItemFailureHandler {
|
||||
|
||||
/**
|
||||
* Handler the list of exceptions. This will usually be done
|
||||
* Handle read failure. This will usually be done
|
||||
* by logging out the details of the exception to either a
|
||||
* file or database table. It is expected that any implementors of this
|
||||
* of this method will not throw an exception.
|
||||
*
|
||||
* @param exceptions
|
||||
* @param ex
|
||||
*/
|
||||
void handle(List exceptions);
|
||||
void handleReadFailure(Exception ex);
|
||||
|
||||
/**
|
||||
* Handle read failure. This will usually be done
|
||||
* by logging out the details of the exception to either a
|
||||
* file or database table. It is expected that any implementors of this
|
||||
* of this method will not throw an exception.
|
||||
*
|
||||
* @param ex
|
||||
*/
|
||||
void handleWriteFailure(Object item, Exception ex);
|
||||
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.domain;
|
||||
|
||||
import org.springframework.batch.core.domain.StepExecution;
|
||||
|
||||
/**
|
||||
* Policy for determining whether or not an item should be skipped.
|
||||
@@ -29,9 +28,9 @@ public interface ItemSkipPolicy {
|
||||
* continue for the current step execution with the given throwable.
|
||||
*
|
||||
* @param ex throwable encountered while reading
|
||||
* @param stepExecution currently running execution
|
||||
* @param stepContribution currently running execution
|
||||
* @return true if reading should continue, false otherwise.
|
||||
* @throws IllegalArgumentException if t or stepExecution is null
|
||||
*/
|
||||
boolean shouldSkip(Exception ex, StepExecution stepExecution);
|
||||
boolean shouldSkip(Exception ex, StepContribution stepContribution);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ public class StepContribution {
|
||||
private ExecutionContext executionContext;
|
||||
|
||||
private int commitCount;
|
||||
|
||||
private int skipCount;
|
||||
|
||||
/**
|
||||
* @param execution
|
||||
@@ -96,5 +98,13 @@ public class StepContribution {
|
||||
public boolean isTerminateOnly() {
|
||||
return execution.isTerminateOnly();
|
||||
}
|
||||
|
||||
public int getSkipCount() {
|
||||
return skipCount + execution.getSkipCount();
|
||||
}
|
||||
|
||||
public void incrementSkipCount(){
|
||||
skipCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -330,6 +330,7 @@ public class StepExecution extends Entity {
|
||||
// TODO: this should not be necessary - the step decides
|
||||
// executionContext = contribution.getExecutionContext();
|
||||
commitCount += contribution.getCommitCount();
|
||||
skipCount += contribution.getSkipCount();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user