Package org.hyperledger.fabric.client
Class FileCheckpointer
java.lang.Object
org.hyperledger.fabric.client.FileCheckpointer
- All Implemented Interfaces:
AutoCloseable
,Checkpoint
,Checkpointer
Checkpointer implementation backed by persistent file storage.
It can be used to checkpoint progress after successfully processing events, allowing eventing to be resumed from this point.
-
Constructor Summary
ConstructorDescriptionFileCheckpointer
(Path path) To create a checkpointer instance backed by persistent file storage. -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkpointBlock
(long blockNumber) Checkpoint a successfully processed block.void
Checkpoint a chaincode event.void
checkpointTransaction
(long blockNumber, String transactionID) Checkpoint a transaction within a block.void
close()
Releases the resources and closes the file channel.The block number in which the next event is expected.Transaction Id of the last successfully processed event within the current block.void
sync()
Commits file changes to the storage device.
-
Constructor Details
-
FileCheckpointer
To create a checkpointer instance backed by persistent file storage.- Parameters:
path
- Path of the file which has to store the checkpointer state.- Throws:
IOException
- if the file cannot be opened, is unwritable, or contains invalid checkpointer state data.
-
-
Method Details
-
checkpointBlock
Description copied from interface:Checkpointer
Checkpoint a successfully processed block.Note that the block number is an unsigned 64-bit integer, with the sign bit used to hold the top bit of the number.
- Specified by:
checkpointBlock
in interfaceCheckpointer
- Parameters:
blockNumber
- a ledger block number.- Throws:
IOException
- if an I/O error occurs.
-
checkpointTransaction
Description copied from interface:Checkpointer
Checkpoint a transaction within a block.- Specified by:
checkpointTransaction
in interfaceCheckpointer
- Parameters:
blockNumber
- a ledger block number.transactionID
- transaction id within the block.- Throws:
IOException
- if an I/O error occurs.
-
checkpointChaincodeEvent
Description copied from interface:Checkpointer
Checkpoint a chaincode event.- Specified by:
checkpointChaincodeEvent
in interfaceCheckpointer
- Parameters:
event
- a chaincode event.- Throws:
IOException
- if an I/O error occurs.
-
getBlockNumber
Description copied from interface:Checkpoint
The block number in which the next event is expected.- Specified by:
getBlockNumber
in interfaceCheckpoint
- Returns:
- A ledger block number.
-
getTransactionId
Description copied from interface:Checkpoint
Transaction Id of the last successfully processed event within the current block.- Specified by:
getTransactionId
in interfaceCheckpoint
- Returns:
- A transaction Id.
-
close
Releases the resources and closes the file channel.- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
- if an I/O error occurs.
-
sync
Commits file changes to the storage device.- Throws:
IOException
- if an I/O error occurs.
-