Class ParallelSnapshotReader
java.lang.Object
io.debezium.connector.mysql.legacy.ParallelSnapshotReader
- All Implemented Interfaces:
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classA Halting Predicate for the parallel snapshot reader.Nested classes/interfaces inherited from interface io.debezium.connector.mysql.legacy.Reader
Reader.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate static final org.slf4j.Loggerprivate final BinlogReaderprivate final ChainedReaderprivate final BinlogReaderprivate final AtomicReference<MySqlPartition>private final AtomicBooleanprivate final MySqlConnectorTask.ServerIdGeneratorprivate final AtomicReference<Consumer<MySqlPartition>> -
Constructor Summary
ConstructorsConstructorDescriptionParallelSnapshotReader(Configuration config, MySqlTaskContext noSnapshotContext, Filters snapshotFilters, MySqlConnectorTask.ServerIdGenerator serverIdGenerator) Create a ParallelSnapshotReader.ParallelSnapshotReader(BinlogReader oldTablesBinlogReader, SnapshotReader newTablesSnapshotReader, BinlogReader newTablesBinlogReader) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcompleteSuccessfully(MySqlPartition partition) createReconcilingBinlogReader(BinlogReader unifiedReader) Create and return aReconcilingBinlogReaderfor the two binlog readers contained in this ParallelSnapshotReader.voidPerform any initialization of the reader before being started.name()Get the name of this reader.List<org.apache.kafka.connect.source.SourceRecord>poll()Poll for the next batch of source records.voidstart(MySqlPartition partition) Start the reader and return immediately.state()Get the current state of this reader.voidstop()Stop the reader from running and transition to theReader.State.STOPPINGstate until all remaining records areconsumed, at which point its state transitions toReader.State.STOPPED.voiduponCompletion(Consumer<MySqlPartition> handler) Set the function that should be called when this reader transitions from theReader.State.STOPPINGtoReader.State.STOPPEDstate, which is after all generated records have been consumed via thepollmethod.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
oldTablesReader
-
newTablesBinlogReader
-
newTablesReader
-
partition
-
running
-
completed
-
uponCompletion
-
serverIdGenerator
-
-
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-Filtersmatching the tables that should be snapshotted.serverIdGenerator- a generator for creating unconflicting serverIds.
-
ParallelSnapshotReader
ParallelSnapshotReader(BinlogReader oldTablesBinlogReader, SnapshotReader newTablesSnapshotReader, BinlogReader newTablesBinlogReader)
-
-
Method Details
-
createReconcilingBinlogReader
Create and return aReconcilingBinlogReaderfor the two binlog readers contained in this ParallelSnapshotReader.- Returns:
- a
ReconcilingBinlogReader
-
uponCompletion
Description copied from interface:ReaderSet the function that should be called when this reader transitions from theReader.State.STOPPINGtoReader.State.STOPPEDstate, which is after all generated records have been consumed via thepollmethod.This method should only be called while the reader is in the
Reader.State.STOPPEDstate.- Specified by:
uponCompletionin interfaceReader- Parameters:
handler- the function; may not be null
-
initialize
public void initialize()Description copied from interface:ReaderPerform any initialization of the reader before being started. This method should be called exactly once beforeReader.start(MySqlPartition)()} is called, and it should block until all initialization is completed.- Specified by:
initializein interfaceReader
-
start
Description copied from interface:ReaderStart the reader and return immediately. Once started, theSourceRecords generated by the reader can be obtained by periodically callingReader.poll()until that method returnsnull.This method does nothing if it is already running.
-
stop
public void stop()Description copied from interface:ReaderStop the reader from running and transition to theReader.State.STOPPINGstate until all remaining records areconsumed, at which point its state transitions toReader.State.STOPPED. -
state
Description copied from interface:ReaderGet the current state of this reader. -
poll
Description copied from interface:ReaderPoll for the next batch of source records. This method returnsnullonly when all records generated by this reader have been processed, following the natural or explicitstoppingof 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 returnsnull.- Specified by:
pollin interfaceReader- Returns:
- the list of source records that may or may not be empty; or
nullwhen there will be no more records because the reader has completelyReader.State.STOPPED. - Throws:
InterruptedException- if this thread is interrupted while waiting for more records
-
completeSuccessfully
-
name
Description copied from interface:ReaderGet the name of this reader.
-