@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.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
Handover.ClosedException
An exception thrown by the Handover in the
pollNext() or produce(List)
method, after the Handover was closed via close(). |
| 构造器和说明 |
|---|
Handover() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close()
Closes the handover.
|
Throwable |
getError()
Return the error, if its set.
|
Object |
getLock() |
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()
@Nullable public Throwable getError()
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 在接口中 Closeableclose 在接口中 AutoCloseable@VisibleForTesting public Object getLock()
Copyright © 2025 The Apache Software Foundation. All rights reserved.