Class TableChunkProgress

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

public class TableChunkProgress extends Object
Thread-safe progress tracking for chunked table snapshots across all table chunks.
Author:
Chris Cranford
  • Field Details

    • tableId

      private final TableId tableId
    • totalChunks

      private final int totalChunks
    • completedChunks

      private final AtomicInteger completedChunks
    • totalRowsScanned

      private final AtomicLong totalRowsScanned
    • firstRecordLatch

      private final CountDownLatch firstRecordLatch
    • chunksBeforeLastLatch

      private final CountDownLatch chunksBeforeLastLatch
  • Constructor Details

    • TableChunkProgress

      public TableChunkProgress(TableId tableId, int totalChunks)
  • Method Details

    • markChunkComplete

      public void markChunkComplete(long rowsScanned)
    • isTableComplete

      public boolean isTableComplete()
    • getTotalRowsScanned

      public long getTotalRowsScanned()
    • getCompletedChunks

      public int getCompletedChunks()
    • getTotalChunks

      public int getTotalChunks()
    • getTableId

      public TableId getTableId()
    • waitForFirstRecord

      public void waitForFirstRecord() throws InterruptedException
      Waits for the first record of this table (FIRST_IN_DATA_COLLECTION) 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 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 first record of this table has been emitted. Called by the chunk processing the first record (chunk 0).
    • waitForOtherChunks

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

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

      public void signalChunkComplete()
      Signals that a non-last chunk has completed all its records. Called by chunks 0 through N-2 after processing all their records.