T
- The type of the record emitted by this source reader.SplitT
- The type of the the source splits.@PublicEvolving public interface SourceReader<T,SplitT extends SourceSplit> extends AutoCloseable
SplitEnumerator
.Modifier and Type | Method and Description |
---|---|
void |
addSplits(List<SplitT> splits)
Adds a list of splits for this reader to read.
|
default void |
handleSourceEvents(SourceEvent sourceEvent)
Handle a source event sent by the
SplitEnumerator . |
CompletableFuture<Void> |
isAvailable() |
default void |
notifyCheckpointAborted(long checkpointId)
Called when a checkpoint is aborted.
|
default void |
notifyCheckpointComplete(long checkpointId)
We have an empty default implementation here because most source readers do not have to
implement the method.
|
void |
notifyNoMoreSplits()
This method is called when the reader is notified that it will not receive any further
splits.
|
InputStatus |
pollNext(ReaderOutput<T> output)
Poll the next available record into the
SourceOutput . |
List<SplitT> |
snapshotState(long checkpointId)
Checkpoint on the state of the source.
|
void |
start()
Start the reader.
|
close
void start()
InputStatus pollNext(ReaderOutput<T> output) throws Exception
SourceOutput
.
The implementation must make sure this method is non-blocking.
Although the implementation can emit multiple records into the given SourceOutput, it is
recommended not doing so. Instead, emit one record into the SourceOutput and return a InputStatus.MORE_AVAILABLE
to let the caller thread know there are more records available.
Exception
List<SplitT> snapshotState(long checkpointId)
CompletableFuture<Void> isAvailable()
void addSplits(List<SplitT> splits)
splits
- The splits assigned by the split enumerator.void notifyNoMoreSplits()
It is triggered when the enumerator calls SplitEnumeratorContext.signalNoMoreSplits(int)
with the reader's parallel subtask.
default void handleSourceEvents(SourceEvent sourceEvent)
SplitEnumerator
.
This method has a default implementation that does nothing, because most sources do not require any custom events.
sourceEvent
- the event sent by the SplitEnumerator
.default void notifyCheckpointComplete(long checkpointId) throws Exception
Exception
default void notifyCheckpointAborted(long checkpointId)
NOTE: This method is here only in the backport to the Flink 1.11 branch. In 1.12, this default method is inherited from the CheckpointListener interface.
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.