@ThreadSafe @Internal public class Handover extends Object implements Closeable
interrupting threads.
This class is used in the Flink Debezium Engine Consumer to hand over data and exceptions between the thread that runs the DebeziumEngine class and the main thread.
The Handover can also be "closed", signalling from one thread to the other that it the thread has terminated.
| Modifier and Type | Class and Description |
|---|---|
static class |
Handover.ClosedException
An exception thrown by the Handover in the
pollNext() or produce(List)
method, after the Handover was closed via close(). |
| Constructor and Description |
|---|
Handover() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the handover.
|
boolean |
hasError()
Return whether there is an error.
|
List<io.debezium.engine.ChangeEvent<org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.connect.source.SourceRecord>> |
pollNext()
Polls the next element from the Handover, possibly blocking until the next element is
available.
|
void |
produce(List<io.debezium.engine.ChangeEvent<org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.connect.source.SourceRecord>> element)
Hands over an element from the producer.
|
void |
reportError(Throwable t)
Reports an exception.
|
public List<io.debezium.engine.ChangeEvent<org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.connect.source.SourceRecord>> pollNext() throws Exception
If an exception was handed in by the producer (reportError(Throwable)), then that
exception is thrown rather than an element being returned.
Handover.ClosedException - Thrown if the Handover was closed.Exception - Rethrows exceptions from the reportError(Throwable) method.public void produce(List<io.debezium.engine.ChangeEvent<org.apache.kafka.connect.source.SourceRecord,org.apache.kafka.connect.source.SourceRecord>> element) throws InterruptedException
This behavior is similar to a "size one" blocking queue.
element - The next element to hand over.InterruptedException - Thrown, if the thread is interrupted while blocking for the
Handover to be empty.public void reportError(Throwable t)
pollNext() method, or the next time it calls that method.
After this method has been called, no call to either produce( List) or pollNext() will ever return regularly any more, but will always return exceptionally.
If another exception was already reported, this method does nothing.
For the producer, the Handover will appear as if it was closed.
t - The exception to report.public boolean hasError()
public void close()
produce(List) method and the pollNext() will
throw a Handover.ClosedException on any currently blocking and future invocations.
If an exception was previously reported via the reportError(Throwable) method,
that exception will not be overridden. The consumer thread will throw that exception upon
calling pollNext(), rather than the ClosedException.
close in interface Closeableclose in interface AutoCloseableCopyright © 2022 The Apache Software Foundation. All rights reserved.