protected final class Replicator.BufferableRecorder extends Object implements BlockingConsumer<org.apache.kafka.connect.source.SourceRecord>
BlockingConsumer implementation that will buffer the last source record
only during an initial sync, so that when the initial sync is complete the last record's offset can be updated
to reflect the completion of the initial sync before it is flushed.| Modifier and Type | Field and Description |
|---|---|
private BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> |
actual |
private BufferedBlockingConsumer<org.apache.kafka.connect.source.SourceRecord> |
buffered |
private BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> |
current |
| Constructor and Description |
|---|
BufferableRecorder(BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> actual) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(org.apache.kafka.connect.source.SourceRecord t) |
protected void |
startBuffering()
Start buffering the most recently source record so it can be updated before the
initial sync
is completed. |
protected void |
stopBuffering(Map<String,?> newOffset)
Stop buffering source records, and flush any buffered records by replacing their offset with the provided offset.
|
private final BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> actual
private BufferedBlockingConsumer<org.apache.kafka.connect.source.SourceRecord> buffered
private volatile BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> current
public BufferableRecorder(BlockingConsumer<org.apache.kafka.connect.source.SourceRecord> actual)
protected void startBuffering()
throws InterruptedException
initial sync
is completed.InterruptedException - if the thread is interrupted while waiting for any existing record to be flushedprotected void stopBuffering(Map<String,?> newOffset) throws InterruptedException
offset and does not change the
value of the record, which may contain information about the snapshot.newOffset - the offset that reflects that the snapshot has been completed; may not be nullInterruptedException - if the thread is interrupted while waiting for the new record to be flushedpublic void accept(org.apache.kafka.connect.source.SourceRecord t)
throws InterruptedException
accept in interface BlockingConsumer<org.apache.kafka.connect.source.SourceRecord>InterruptedExceptionCopyright © 2019 JBoss by Red Hat. All rights reserved.