public class BlockingReader extends Object implements Reader
Reader.State
Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
logger |
private Metronome |
metronome |
private String |
name |
private String |
runningLogMessage |
private AtomicReference<Reader.State> |
state |
private AtomicReference<Runnable> |
uponCompletion |
Constructor and Description |
---|
BlockingReader(String name,
String runningLogMessage) |
Modifier and Type | Method and Description |
---|---|
String |
name()
Get the name of this reader.
|
List<org.apache.kafka.connect.source.SourceRecord> |
poll()
Does nothing until the connector task is shut down, but regularly returns control back to Connect in order for being paused if requested.
|
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, wait
destroy, initialize
protected final org.slf4j.Logger logger
private final AtomicReference<Runnable> uponCompletion
private final AtomicReference<Reader.State> state
private final Metronome metronome
private final String name
private final String runningLogMessage
public List<org.apache.kafka.connect.source.SourceRecord> poll() throws InterruptedException
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 recordspublic Reader.State state()
Reader
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 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
.Copyright © 2020 JBoss by Red Hat. All rights reserved.