Class ParallelSnapshotReader

java.lang.Object
io.debezium.connector.mysql.legacy.ParallelSnapshotReader
All Implemented Interfaces:
Reader

public class ParallelSnapshotReader extends Object implements Reader
A reader that runs a ChainedReader consisting of a SnapshotReader and a BinlogReader for all tables newly added to the config in parallel with a BinlogReader for all the tables previously in the config.
  • Field Details

  • Constructor Details

    • ParallelSnapshotReader

      public ParallelSnapshotReader(Configuration config, MySqlTaskContext noSnapshotContext, Filters snapshotFilters, MySqlConnectorTask.ServerIdGenerator serverIdGenerator)
      Create a ParallelSnapshotReader.
      Parameters:
      config - the current connector configuration.
      noSnapshotContext - The context for those tables not undergoing a snapshot.
      snapshotFilters - Filters matching the tables that should be snapshotted.
      serverIdGenerator - a generator for creating unconflicting serverIds.
    • ParallelSnapshotReader

      ParallelSnapshotReader(BinlogReader oldTablesBinlogReader, SnapshotReader newTablesSnapshotReader, BinlogReader newTablesBinlogReader)
  • Method Details

    • createReconcilingBinlogReader

      public ReconcilingBinlogReader createReconcilingBinlogReader(BinlogReader unifiedReader)
      Create and return a ReconcilingBinlogReader for the two binlog readers contained in this ParallelSnapshotReader.
      Returns:
      a ReconcilingBinlogReader
    • uponCompletion

      public void uponCompletion(Consumer<MySqlPartition> handler)
      Description copied from interface: Reader
      Set the function that should be called when this reader transitions from the Reader.State.STOPPING to Reader.State.STOPPED state, which is after all generated records have been consumed via the poll method.

      This method should only be called while the reader is in the Reader.State.STOPPED state.

      Specified by:
      uponCompletion in interface Reader
      Parameters:
      handler - the function; may not be null
    • initialize

      public void initialize()
      Description copied from interface: Reader
      Perform any initialization of the reader before being started. This method should be called exactly once before Reader.start(MySqlPartition) ()} is called, and it should block until all initialization is completed.
      Specified by:
      initialize in interface Reader
    • start

      public void start(MySqlPartition partition)
      Description copied from interface: Reader
      Start the reader and return immediately. Once started, the SourceRecords generated by the reader can be obtained by periodically calling Reader.poll() until that method returns null.

      This method does nothing if it is already running.

      Specified by:
      start in interface Reader
    • stop

      public void stop()
      Description copied from interface: Reader
      Stop the reader from running and transition to the Reader.State.STOPPING state until all remaining records are consumed, at which point its state transitions to Reader.State.STOPPED.
      Specified by:
      stop in interface Reader
    • state

      public Reader.State state()
      Description copied from interface: Reader
      Get the current state of this reader.
      Specified by:
      state in interface Reader
      Returns:
      the state; never null
    • poll

      public List<org.apache.kafka.connect.source.SourceRecord> poll() throws InterruptedException
      Description copied from interface: Reader
      Poll for the next batch of source records. This method returns null only when all records generated by this reader have been processed, following the natural or explicit stopping of this reader. Note that this method may block if no additional records are available but the reader may produce more, thus callers should call this method continually until this method returns null.
      Specified by:
      poll in interface Reader
      Returns:
      the list of source records that may or may not be empty; or null when there will be no more records because the reader has completely Reader.State.STOPPED.
      Throws:
      InterruptedException - if this thread is interrupted while waiting for more records
    • completeSuccessfully

      private void completeSuccessfully(MySqlPartition partition)
    • name

      public String name()
      Description copied from interface: Reader
      Get the name of this reader.
      Specified by:
      name in interface Reader
      Returns:
      the reader's name; never null