public class ParallelSnapshotReader extends Object implements Reader
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.Modifier and Type | Class and Description |
---|---|
(package private) static class |
ParallelSnapshotReader.ParallelHaltingPredicate
A Halting Predicate for the parallel snapshot reader.
|
Reader.State
Modifier and Type | Field and Description |
---|---|
private AtomicBoolean |
completed |
private static org.slf4j.Logger |
LOGGER |
private BinlogReader |
newTablesBinlogReader |
private ChainedReader |
newTablesReader |
private BinlogReader |
oldTablesReader |
private AtomicBoolean |
running |
private MySqlConnectorTask.ServerIdGenerator |
serverIdGenerator |
private AtomicReference<Runnable> |
uponCompletion |
Constructor and Description |
---|
ParallelSnapshotReader(BinlogReader oldTablesBinlogReader,
SnapshotReader newTablesSnapshotReader,
BinlogReader newTablesBinlogReader) |
ParallelSnapshotReader(Configuration config,
MySqlTaskContext noSnapshotContext,
Filters snapshotFilters,
MySqlConnectorTask.ServerIdGenerator serverIdGenerator)
Create a ParallelSnapshotReader.
|
Modifier and Type | Method and Description |
---|---|
private void |
completeSuccessfully() |
ReconcilingBinlogReader |
createReconcilingBinlogReader(BinlogReader unifiedReader)
Create and return a
ReconcilingBinlogReader for the two binlog readers contained in this
ParallelSnapshotReader. |
void |
initialize()
Perform any initialization of the reader before being started.
|
String |
name()
Get the name of this reader.
|
List<org.apache.kafka.connect.source.SourceRecord> |
poll()
Poll for the next batch of source records.
|
void |
start()
Start the reader and return immediately.
|
Reader.State |
state()
Get the current state of this reader.
|
void |
stop()
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 . |
void |
uponCompletion(Runnable handler)
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. |
private static final org.slf4j.Logger LOGGER
private final BinlogReader oldTablesReader
private final BinlogReader newTablesBinlogReader
private final ChainedReader newTablesReader
private final AtomicBoolean running
private final AtomicBoolean completed
private final AtomicReference<Runnable> uponCompletion
private final MySqlConnectorTask.ServerIdGenerator serverIdGenerator
public ParallelSnapshotReader(Configuration config, MySqlTaskContext noSnapshotContext, Filters snapshotFilters, MySqlConnectorTask.ServerIdGenerator serverIdGenerator)
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(BinlogReader oldTablesBinlogReader, SnapshotReader newTablesSnapshotReader, BinlogReader newTablesBinlogReader)
public ReconcilingBinlogReader createReconcilingBinlogReader(BinlogReader unifiedReader)
ReconcilingBinlogReader
for the two binlog readers contained in this
ParallelSnapshotReader.ReconcilingBinlogReader
public void uponCompletion(Runnable handler)
Reader
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.
uponCompletion
in interface Reader
handler
- the function; may not be nullpublic void initialize()
Reader
Reader.start()
is called, and it should block until all
initialization is completed.initialize
in interface Reader
public void start()
Reader
SourceRecord
s 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.
public void stop()
Reader
Reader.State.STOPPING
state until all remaining records
are consumed
, at which point its state transitions to Reader.State.STOPPED
.public Reader.State state()
Reader
public List<org.apache.kafka.connect.source.SourceRecord> poll() throws InterruptedException
Reader
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
.poll
in interface Reader
null
when there will be no more records
because the reader has completely Reader.State.STOPPED
.InterruptedException
- if this thread is interrupted while waiting for more recordsprivate void completeSuccessfully()
Copyright © 2020 JBoss by Red Hat. All rights reserved.