public class ReconcilingBinlogReader extends Object implements Reader
BinlogReader duplicating the
lagging reader, but with a halting predicate that will halt it once it has passed the
final position of the leading reader.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
ReconcilingBinlogReader.OffsetLimitPredicate
A Predicate that returns false for any record beyond a given offset.
|
Reader.State| Modifier and Type | Field and Description |
|---|---|
private Boolean |
aReaderLeading |
private BinlogReader |
binlogReaderA |
private BinlogReader |
binlogReaderB |
private AtomicBoolean |
completed |
private static org.slf4j.Logger |
LOGGER |
private BinlogReader |
reconcilingReader |
private AtomicBoolean |
running |
private long |
serverId |
private BinlogReader |
unifiedReader |
private AtomicReference<Runnable> |
uponCompletion |
| Constructor and Description |
|---|
ReconcilingBinlogReader(BinlogReader binlogReaderA,
BinlogReader binlogReaderB,
BinlogReader unifiedReader,
long serverId)
Create a reconciling Binlog Reader.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
checkLaggingLeadingInfo() |
private void |
completeSuccessfully() |
private void |
determineLeadingReader() |
(package private) BinlogReader |
getLaggingReader() |
(package private) BinlogReader |
getLeadingReader() |
String |
name()
Get the name of this reader.
|
List<org.apache.kafka.connect.source.SourceRecord> |
poll()
Poll for the next batch of source records.
|
private void |
setupUnifiedReader() |
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. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdestroy, initializeprivate static final org.slf4j.Logger LOGGER
private final BinlogReader binlogReaderA
private final BinlogReader binlogReaderB
private final BinlogReader unifiedReader
private BinlogReader reconcilingReader
private Boolean aReaderLeading
private final AtomicBoolean running
private final AtomicBoolean completed
private final AtomicReference<Runnable> uponCompletion
private final long serverId
public ReconcilingBinlogReader(BinlogReader binlogReaderA, BinlogReader binlogReaderB, BinlogReader unifiedReader, long serverId)
binlogReaderA - the first binlog reader to unify.binlogReaderB - the second binlog reader to unify.unifiedReader - the final, unified binlog reader that will run once the reconciliation is complete.public Reader.State state()
Readerpublic void uponCompletion(Runnable handler)
ReaderReader.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 Readerhandler - the function; may not be nullpublic void start()
ReaderSourceRecords 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()
ReaderReader.State.STOPPING state until all remaining records
are consumed, at which point its state transitions to Reader.State.STOPPED.public List<org.apache.kafka.connect.source.SourceRecord> poll() throws InterruptedException
Readernull 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 Readernull 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()
private void setupUnifiedReader()
private void determineLeadingReader()
BinlogReader getLeadingReader()
BinlogReader getLaggingReader()
private void checkLaggingLeadingInfo()
Copyright © 2020 JBoss by Red Hat. All rights reserved.