Class ChunkMonitor
java.lang.Object
org.springframework.batch.item.ItemStreamSupport
org.springframework.batch.core.step.item.ChunkMonitor
- All Implemented Interfaces:
ItemStream
Manage the offset data between the last successful commit and updates made to an input
chunk. Only works with single threaded steps because it has to use a
ThreadLocal
to manage the state and coordinate between the caller and the
wrapped ItemStream
.- Since:
- 2.0
- Author:
- Dave Syer, Mahmoud Ben Hassine, Seungrae Kim
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
If any resources are needed for the stream to operate they need to be destroyed here.int
void
void
open
(ExecutionContext executionContext) Open the stream for the providedExecutionContext
.void
registerItemStream
(ItemStream stream) void
void
setChunkSize
(int chunkSize) void
setItemReader
(ItemReader<?> reader) void
update
(ExecutionContext executionContext) Indicates that the execution context provided during open is about to be saved.Methods inherited from class org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, getName, setExecutionContextName, setName
-
Constructor Details
-
ChunkMonitor
public ChunkMonitor()
-
-
Method Details
-
registerItemStream
- Parameters:
stream
- the stream to set
-
setItemReader
- Parameters:
reader
- the reader to set
-
incrementOffset
public void incrementOffset() -
getOffset
public int getOffset() -
resetOffset
public void resetOffset() -
setChunkSize
public void setChunkSize(int chunkSize) -
close
Description copied from interface:ItemStream
If any resources are needed for the stream to operate they need to be destroyed here. Once this method has been called all other methods (except open) may throw an exception.- Throws:
ItemStreamException
-
open
Description copied from interface:ItemStream
Open the stream for the providedExecutionContext
.- Parameters:
executionContext
- current step'sExecutionContext
. Will be the executionContext from the last run of the step on a restart.- Throws:
ItemStreamException
-
update
Description copied from interface:ItemStream
Indicates that the execution context provided during open is about to be saved. If any state is remaining, but has not been put in the context, it should be added here.- Parameters:
executionContext
- to be updated- Throws:
ItemStreamException
-