E - The rich element type that contains information for split state update or timestamp
extraction.T - The final element type to emit.SplitT - the immutable split type.SplitStateT - the mutable type of split state.@PublicEvolving public abstract class SourceReaderBase<E,T,SplitT extends org.apache.flink.api.connector.source.SourceSplit,SplitStateT> extends Object implements org.apache.flink.api.connector.source.SourceReader<T,SplitT>
SourceReader which provides some synchronization between
the mail box main thread and the SourceReader internal threads. This class allows user to just
provide a SplitReader and snapshot the split state.
This implementation provides the following metrics out of the box:
OperatorIOMetricGroup.getNumRecordsInCounter()
| 限定符和类型 | 字段和说明 |
|---|---|
protected org.apache.flink.configuration.Configuration |
config
The raw configurations that may be used by subclasses.
|
protected org.apache.flink.api.connector.source.SourceReaderContext |
context
The context of this source reader.
|
protected SourceReaderOptions |
options
The configuration for the reader.
|
protected RecordEmitter<E,T,SplitStateT> |
recordEmitter
The record emitter to handle the records read by the SplitReaders.
|
protected SplitFetcherManager<E,SplitT> |
splitFetcherManager
The split fetcher manager to run split fetchers.
|
| 构造器和说明 |
|---|
SourceReaderBase(FutureCompletingBlockingQueue<RecordsWithSplitIds<E>> elementsQueue,
SplitFetcherManager<E,SplitT> splitFetcherManager,
RecordEmitter<E,T,SplitStateT> recordEmitter,
org.apache.flink.configuration.Configuration config,
org.apache.flink.api.connector.source.SourceReaderContext context) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addSplits(List<SplitT> splits) |
void |
close() |
int |
getNumberOfCurrentlyAssignedSplits()
Gets the number of splits the reads has currently assigned.
|
void |
handleSourceEvents(org.apache.flink.api.connector.source.SourceEvent sourceEvent) |
protected abstract SplitStateT |
initializedState(SplitT split)
When new splits are added to the reader.
|
CompletableFuture<Void> |
isAvailable() |
void |
notifyNoMoreSplits() |
protected abstract void |
onSplitFinished(Map<String,SplitStateT> finishedSplitIds)
Handles the finished splits to clean the state if needed.
|
void |
pauseOrResumeSplits(Collection<String> splitsToPause,
Collection<String> splitsToResume) |
org.apache.flink.core.io.InputStatus |
pollNext(org.apache.flink.api.connector.source.ReaderOutput<T> output) |
List<SplitT> |
snapshotState(long checkpointId) |
void |
start() |
protected abstract SplitT |
toSplitType(String splitId,
SplitStateT splitState)
Convert a mutable SplitStateT to immutable SplitT.
|
protected final RecordEmitter<E,T,SplitStateT> recordEmitter
protected final SplitFetcherManager<E,SplitT extends org.apache.flink.api.connector.source.SourceSplit> splitFetcherManager
protected final SourceReaderOptions options
protected final org.apache.flink.configuration.Configuration config
protected org.apache.flink.api.connector.source.SourceReaderContext context
public SourceReaderBase(FutureCompletingBlockingQueue<RecordsWithSplitIds<E>> elementsQueue, SplitFetcherManager<E,SplitT> splitFetcherManager, RecordEmitter<E,T,SplitStateT> recordEmitter, org.apache.flink.configuration.Configuration config, org.apache.flink.api.connector.source.SourceReaderContext context)
public void start()
public org.apache.flink.core.io.InputStatus pollNext(org.apache.flink.api.connector.source.ReaderOutput<T> output) throws Exception
public CompletableFuture<Void> isAvailable()
public void notifyNoMoreSplits()
public void handleSourceEvents(org.apache.flink.api.connector.source.SourceEvent sourceEvent)
public void pauseOrResumeSplits(Collection<String> splitsToPause, Collection<String> splitsToResume)
public void close()
throws Exception
close 在接口中 AutoCloseableExceptionpublic int getNumberOfCurrentlyAssignedSplits()
These are the splits that have been added via addSplits(List) and have not yet
been finished by returning them from the SplitReader.fetch() as part of RecordsWithSplitIds.finishedSplits().
protected abstract void onSplitFinished(Map<String,SplitStateT> finishedSplitIds)
protected abstract SplitStateT initializedState(SplitT split)
split - a newly added split.protected abstract SplitT toSplitType(String splitId, SplitStateT splitState)
splitState - splitState.Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.