Class SingleThreadMultiplexSourceReaderBase<E,T,SplitT extends SourceSplit,SplitStateT>
- java.lang.Object
-
- org.apache.flink.connector.base.source.reader.SourceReaderBase<E,T,SplitT,SplitStateT>
-
- org.apache.flink.connector.base.source.reader.SingleThreadMultiplexSourceReaderBase<E,T,SplitT,SplitStateT>
-
- Type Parameters:
E
- The type of the records (the raw type that typically contains checkpointing information).T
- The final type of the records emitted by the source.SplitT
- The type of the splits processed by the source.SplitStateT
- The type of the mutable state per split.
- All Implemented Interfaces:
AutoCloseable
,CheckpointListener
,SourceReader<T,SplitT>
- Direct Known Subclasses:
FileSourceReader
@PublicEvolving public abstract class SingleThreadMultiplexSourceReaderBase<E,T,SplitT extends SourceSplit,SplitStateT> extends SourceReaderBase<E,T,SplitT,SplitStateT>
A base forSourceReader
s that read splits with one thread using oneSplitReader
. The splits can be read either one after the other (like in a file source) or concurrently by changing the subscription in the split reader (like in the Kafka Source).To implement a source reader based on this class, implementors need to supply the following:
- A
SplitReader
, which connects to the source and reads/polls data. The split reader gets notified whenever there is a new split. The split reader would read files, contain a Kafka or other source client, etc. - A
RecordEmitter
that takes a record from the Split Reader and updates the checkpointing state and converts it into the final form. For example for Kafka, the Record Emitter takes aConsumerRecord
, puts the offset information into state, transforms the records with the deserializers into the final type, and emits the record. - The class must override the methods to convert back and forth between the immutable splits
(
SplitT
) and the mutable split state representation (SplitStateT
). - Finally, the reader must decide what to do when it starts (
SourceReaderBase.start()
) or when a split is finished (SourceReaderBase.onSplitFinished(java.util.Map)
).
-
-
Field Summary
-
Fields inherited from class org.apache.flink.connector.base.source.reader.SourceReaderBase
config, context, eofRecordEvaluator, options, recordEmitter, splitFetcherManager
-
-
Constructor Summary
-
Method Summary
-
Methods inherited from class org.apache.flink.connector.base.source.reader.SourceReaderBase
addSplits, close, getNumberOfCurrentlyAssignedSplits, handleSourceEvents, initializedState, isAvailable, notifyNoMoreSplits, onSplitFinished, pauseOrResumeSplits, pollNext, snapshotState, start, toSplitType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.api.common.state.CheckpointListener
notifyCheckpointAborted
-
Methods inherited from interface org.apache.flink.api.connector.source.SourceReader
notifyCheckpointComplete
-
-
-
-
Constructor Detail
-
SingleThreadMultiplexSourceReaderBase
public SingleThreadMultiplexSourceReaderBase(Supplier<SplitReader<E,SplitT>> splitReaderSupplier, RecordEmitter<E,T,SplitStateT> recordEmitter, Configuration config, SourceReaderContext context)
The primary constructor for the source reader.The reader will use a handover queue sized as configured via
SourceReaderOptions.ELEMENT_QUEUE_CAPACITY
.
-
SingleThreadMultiplexSourceReaderBase
public SingleThreadMultiplexSourceReaderBase(SingleThreadFetcherManager<E,SplitT> splitFetcherManager, RecordEmitter<E,T,SplitStateT> recordEmitter, Configuration config, SourceReaderContext context)
This constructor behaves likeSingleThreadMultiplexSourceReaderBase(Supplier, RecordEmitter, Configuration, SourceReaderContext)
, but accepts a specificFutureCompletingBlockingQueue
andSingleThreadFetcherManager
.
-
SingleThreadMultiplexSourceReaderBase
public SingleThreadMultiplexSourceReaderBase(SingleThreadFetcherManager<E,SplitT> splitFetcherManager, RecordEmitter<E,T,SplitStateT> recordEmitter, @Nullable RecordEvaluator<T> eofRecordEvaluator, Configuration config, SourceReaderContext context)
This constructor behaves likeSingleThreadMultiplexSourceReaderBase(Supplier, RecordEmitter, Configuration, SourceReaderContext)
, but accepts a specificFutureCompletingBlockingQueue
,SingleThreadFetcherManager
andRecordEvaluator
.
-
-