Class FileCheckpointer

java.lang.Object
org.hyperledger.fabric.client.FileCheckpointer
All Implemented Interfaces:
AutoCloseable, Checkpoint, Checkpointer

public final class FileCheckpointer extends Object implements Checkpointer, AutoCloseable
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 Details

    • FileCheckpointer

      public FileCheckpointer(Path path) throws IOException
      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

      public void checkpointBlock(long blockNumber) throws IOException
      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 interface Checkpointer
      Parameters:
      blockNumber - a ledger block number.
      Throws:
      IOException - if an I/O error occurs.
    • checkpointTransaction

      public void checkpointTransaction(long blockNumber, String transactionID) throws IOException
      Description copied from interface: Checkpointer
      Checkpoint a transaction within a block.
      Specified by:
      checkpointTransaction in interface Checkpointer
      Parameters:
      blockNumber - a ledger block number.
      transactionID - transaction id within the block.
      Throws:
      IOException - if an I/O error occurs.
    • checkpointChaincodeEvent

      public void checkpointChaincodeEvent(ChaincodeEvent event) throws IOException
      Description copied from interface: Checkpointer
      Checkpoint a chaincode event.
      Specified by:
      checkpointChaincodeEvent in interface Checkpointer
      Parameters:
      event - a chaincode event.
      Throws:
      IOException - if an I/O error occurs.
    • getBlockNumber

      public OptionalLong getBlockNumber()
      Description copied from interface: Checkpoint
      The block number in which the next event is expected.
      Specified by:
      getBlockNumber in interface Checkpoint
      Returns:
      A ledger block number.
    • getTransactionId

      public Optional<String> getTransactionId()
      Description copied from interface: Checkpoint
      Transaction Id of the last successfully processed event within the current block.
      Specified by:
      getTransactionId in interface Checkpoint
      Returns:
      A transaction Id.
    • close

      public void close() throws IOException
      Releases the resources and closes the file channel.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException - if an I/O error occurs.
    • sync

      public void sync() throws IOException
      Commits file changes to the storage device.
      Throws:
      IOException - if an I/O error occurs.