Class SnapshotProgress

java.lang.Object
io.debezium.pipeline.source.snapshot.chunked.SnapshotProgress

public class SnapshotProgress extends Object
Thread-safe coordination for global snapshot progress across all tables. Ensures correct emission ordering of FIRST and LAST snapshot markers.
Author:
Chris Cranford
  • Field Details

    • tableCount

      private final int tableCount
    • firstRecordLatch

      private final CountDownLatch firstRecordLatch
    • tablesBeforeLastLatch

      private final CountDownLatch tablesBeforeLastLatch
  • Constructor Details

    • SnapshotProgress

      public SnapshotProgress(int tableCount)
      Creates a new SnapshotProgress instance.
      Parameters:
      tableCount - the total number of tables in the snapshot
  • Method Details

    • waitForFirstRecord

      public void waitForFirstRecord() throws InterruptedException
      Waits for the global FIRST record to be emitted. Called by all records except the FIRST record before emission.
      Throws:
      InterruptedException - if the wait is interrupted
    • waitForFirstRecord

      public boolean waitForFirstRecord(long timeout, TimeUnit unit) throws InterruptedException
      Waits for the global FIRST record with a timeout.
      Parameters:
      timeout - the maximum time to wait
      unit - the time unit
      Returns:
      true if the latch was signaled, false if timeout elapsed
      Throws:
      InterruptedException - if the wait is interrupted
    • signalFirstRecordEmitted

      public void signalFirstRecordEmitted()
      Signals that the global FIRST record has been emitted. Called by the chunk processing the first record of the first table.
    • waitForOtherTables

      public void waitForOtherTables() throws InterruptedException
      Waits for all tables except the last one to complete. Called by the LAST record before emission.
      Throws:
      InterruptedException - if the wait is interrupted
    • waitForOtherTables

      public boolean waitForOtherTables(long timeout, TimeUnit unit) throws InterruptedException
      Waits for all tables except the last one with a timeout.
      Parameters:
      timeout - the maximum time to wait
      unit - the time unit
      Returns:
      true if all tables completed, false if timeout elapsed
      Throws:
      InterruptedException - if the wait is interrupted
    • signalTableComplete

      public void signalTableComplete()
      Signals that a table has completed all its records (including LAST_IN_DATA_COLLECTION). Called by non-last tables after emitting their final record.
    • getTableCount

      public int getTableCount()
      Returns:
      the total number of tables in the snapshot