Interface Checkpointer
-
- All Superinterfaces:
java.lang.AutoCloseable
public interface Checkpointer extends java.lang.AutoCloseable
Persists the current block and transactions within that block to enable event listening to be resumed following an application outage.Default implementations can be obtained from
DefaultCheckpointers
. Application developers are encouraged to build their own implementations that use a persistent store suitable to their environment.Implementations must be thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description static long
UNSET_BLOCK_NUMBER
Block number indicating no stored value.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addTransactionId(java.lang.String transactionId)
Add a transaction ID for the current block.void
close()
long
getBlockNumber()
Get the current block number, orUNSET_BLOCK_NUMBER
if there is no previously saved state.java.util.Set<java.lang.String>
getTransactionIds()
Get the transaction IDs processed within the current block.void
setBlockNumber(long blockNumber)
Set the current block number.
-
-
-
Field Detail
-
UNSET_BLOCK_NUMBER
static final long UNSET_BLOCK_NUMBER
Block number indicating no stored value. This is the the default for a newly created checkpointer with no previously saved state.- See Also:
- Constant Field Values
-
-
Method Detail
-
getBlockNumber
long getBlockNumber() throws java.io.IOException
Get the current block number, orUNSET_BLOCK_NUMBER
if there is no previously saved state.- Returns:
- A block number.
- Throws:
java.io.IOException
- if the checkpointer fails to access persistent state.
-
setBlockNumber
void setBlockNumber(long blockNumber) throws java.io.IOException
Set the current block number. Also clears the stored transaction IDs. Typically set when the previous block has been processed.- Parameters:
blockNumber
- A block number.- Throws:
java.io.IOException
- if the checkpointer fails to access persistent state.
-
getTransactionIds
java.util.Set<java.lang.String> getTransactionIds() throws java.io.IOException
Get the transaction IDs processed within the current block.- Returns:
- Transaction IDs.
- Throws:
java.io.IOException
- if the checkpointer fails to access persistent state.
-
addTransactionId
void addTransactionId(java.lang.String transactionId) throws java.io.IOException
Add a transaction ID for the current block. Typically called once a transaction has been processed.- Parameters:
transactionId
- A transaction ID.- Throws:
java.io.IOException
- if the checkpointer fails to access persistent state.
-
close
void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.io.IOException
-
-