Class TransactionContext

java.lang.Object
io.debezium.pipeline.txmetadata.TransactionContext

@NotThreadSafe public class TransactionContext extends Object
The context holds internal state necessary for book-keeping of events in active transaction. The main data tracked are
  • active transaction id
  • the total event number seen from the transaction
  • the number of events per table/collection seen in the transaction
The state of this context is stored in offsets and is recovered upon restart.
Author:
Jiri Pechanec
  • Field Details

    • OFFSET_TRANSACTION_ID

      public static final String OFFSET_TRANSACTION_ID
      See Also:
    • OFFSET_TABLE_COUNT_PREFIX

      private static final String OFFSET_TABLE_COUNT_PREFIX
      See Also:
    • OFFSET_TABLE_COUNT_PREFIX_LENGTH

      private static final int OFFSET_TABLE_COUNT_PREFIX_LENGTH
    • transactionId

      private String transactionId
    • perTableEventCount

      private final Map<String,Long> perTableEventCount
    • viewPerTableEventCount

      private final Map<String,Long> viewPerTableEventCount
    • totalEventCount

      private long totalEventCount
  • Constructor Details

    • TransactionContext

      public TransactionContext()
  • Method Details

    • reset

      private void reset()
    • store

      public Map<String,Object> store(Map<String,Object> offset)
    • newTransactionContextFromOffsets

      public TransactionContext newTransactionContextFromOffsets(Map<String,?> offsets)
      Instance method to allow for overriding by custom transaction contexts.
      Parameters:
      offsets - Offsets to load
      Returns:
      TransactionContext instance with loaded offsets
    • load

      public static TransactionContext load(Map<String,?> offsets)
    • isTransactionInProgress

      public boolean isTransactionInProgress()
    • getTransactionId

      public String getTransactionId()
    • getTotalEventCount

      public long getTotalEventCount()
    • setTransactionId

      public void setTransactionId(String transactionId)
    • putPerTableEventCount

      public void putPerTableEventCount(Map<String,Long> perTableEventCount)
    • setTotalEventCount

      public void setTotalEventCount(long totalEventCount)
    • beginTransaction

      public void beginTransaction(TransactionInfo transactionInfo)
    • beginTransaction

      public void beginTransaction(String transactionId)
    • endTransaction

      public void endTransaction()
    • event

      public long event(DataCollectionId source)
    • getPerTableEventCount

      public Map<String,Long> getPerTableEventCount()
    • toString

      public String toString()
      Overrides:
      toString in class Object