public interface Reader
A reader starts out in the stopped state, and when started transitions to a
Reader.State.RUNNING state. The reader may either complete its work or be explicitly stopped, at which
point the reader transitions to a state until all already-generated SourceRecords
are consumed by the client via the poll method. Only after all records are consumed does the reader
transition to the stopped state and call the uponCompletion(Runnable) method.
See ChainedReader if multiple Reader implementations are to be run in-sequence while keeping the
correct start, stop, and completion semantics.
ChainedReader| Modifier and Type | Interface and Description |
|---|---|
static class |
Reader.State
The possible states of a reader.
|
| Modifier and Type | Method and Description |
|---|---|
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. |
String name()
Reader.State state()
void uponCompletion(Runnable handler)
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.
handler - the function; may not be nullvoid start()
SourceRecords generated by the reader can be obtained by
periodically calling poll() until that method returns null.
This method does nothing if it is already running.
void stop()
Reader.State.STOPPING state until all remaining records
are consumed, at which point its state transitions to Reader.State.STOPPED.List<org.apache.kafka.connect.source.SourceRecord> poll() throws InterruptedException
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.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 recordsorg.apache.kafka.connect.errors.ConnectException - if there is an error while this reader is runningCopyright © 2017 JBoss by Red Hat. All rights reserved.