Class FlinkUnboundedSourceReader<T>
java.lang.Object
org.apache.beam.runners.flink.translation.wrappers.streaming.io.source.FlinkSourceReaderBase<T,WindowedValue<ValueWithRecordId<T>>>
org.apache.beam.runners.flink.translation.wrappers.streaming.io.source.unbounded.FlinkUnboundedSourceReader<T>
- Type Parameters:
T- the output element type of the encapsulated BeamUnboundedReader.
- All Implemented Interfaces:
AutoCloseable,org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.api.connector.source.SourceReader<WindowedValue<ValueWithRecordId<T>>,FlinkSourceSplit<T>>
public class FlinkUnboundedSourceReader<T>
extends FlinkSourceReaderBase<T,WindowedValue<ValueWithRecordId<T>>>
A Flink
SourceReader implementation
that reads from the assigned FlinkSourceSplits by using Beam UnboundedReaders.
This reader consumes all the assigned source splits concurrently.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.beam.runners.flink.translation.wrappers.streaming.io.source.FlinkSourceReaderBase
FlinkSourceReaderBase.ReaderAndOutput -
Field Summary
FieldsFields inherited from class org.apache.beam.runners.flink.translation.wrappers.streaming.io.source.FlinkSourceReaderBase
AVAILABLE_NOW, context, idleTimeoutMs, invocationUtil, numRecordsInCounter, pipelineOptions, timestampExtractor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFlinkUnboundedSourceReader(String stepName, org.apache.flink.api.connector.source.SourceReaderContext context, PipelineOptions pipelineOptions, ScheduledExecutorService executor, @Nullable Function<WindowedValue<ValueWithRecordId<T>>, Long> timestampExtractor) FlinkUnboundedSourceReader(String stepName, org.apache.flink.api.connector.source.SourceReaderContext context, PipelineOptions pipelineOptions, @Nullable Function<WindowedValue<ValueWithRecordId<T>>, Long> timestampExtractor) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddSplitsToUnfinishedForCheckpoint(long checkpointId, List<FlinkSourceSplit<T>> flinkSourceSplits) To be overridden in unbounded reader.protected Source.Reader<T> createReader(FlinkSourceSplit<T> sourceSplit) CreateSource.Readerfor givenFlinkSourceSplit.protected FlinkSourceSplit<T> getReaderCheckpoint(int splitId, FlinkSourceReaderBase<T, WindowedValue<ValueWithRecordId<T>>>.ReaderAndOutput readerAndOutput) CreateFlinkSourceSplitfor givensplitId.protected CompletableFuture<Void> Check whether there are data available from alive readers.voidnotifyCheckpointComplete(long checkpointId) org.apache.flink.core.io.InputStatuspollNext(org.apache.flink.api.connector.source.ReaderOutput<WindowedValue<ValueWithRecordId<T>>> output) voidstart()Methods inherited from class org.apache.beam.runners.flink.translation.wrappers.streaming.io.source.FlinkSourceReaderBase
addSplits, allReaders, checkExceptionAndMaybeThrow, checkIdleTimeoutAndMaybeStartCountdown, close, createAndTrackNextReader, execute, finishSplit, hasException, ignoreReturnValue, isAvailable, noMoreSplits, notifyNoMoreSplits, recordException, scheduleTask, scheduleTaskAtFixedRate, snapshotState, sourceSplitsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.api.common.state.CheckpointListener
notifyCheckpointAbortedMethods inherited from interface org.apache.flink.api.connector.source.SourceReader
handleSourceEvents, pauseOrResumeSplits
-
Field Details
-
PENDING_BYTES_METRIC_NAME
- See Also:
-
-
Constructor Details
-
FlinkUnboundedSourceReader
public FlinkUnboundedSourceReader(String stepName, org.apache.flink.api.connector.source.SourceReaderContext context, PipelineOptions pipelineOptions, @Nullable Function<WindowedValue<ValueWithRecordId<T>>, Long> timestampExtractor) -
FlinkUnboundedSourceReader
protected FlinkUnboundedSourceReader(String stepName, org.apache.flink.api.connector.source.SourceReaderContext context, PipelineOptions pipelineOptions, ScheduledExecutorService executor, @Nullable Function<WindowedValue<ValueWithRecordId<T>>, Long> timestampExtractor)
-
-
Method Details
-
addSplitsToUnfinishedForCheckpoint
protected void addSplitsToUnfinishedForCheckpoint(long checkpointId, List<FlinkSourceSplit<T>> flinkSourceSplits) Description copied from class:FlinkSourceReaderBaseTo be overridden in unbounded reader. Notify the reader of created splits that will be part of checkpoint. Will be processed during notifyCheckpointComplete to finalize the associated CheckpointMarks.- Overrides:
addSplitsToUnfinishedForCheckpointin classFlinkSourceReaderBase<T,WindowedValue<ValueWithRecordId<T>>>
-
notifyCheckpointComplete
- Throws:
Exception
-
start
public void start()- Specified by:
startin interfaceorg.apache.flink.api.connector.source.SourceReader<WindowedValue<ValueWithRecordId<T>>,FlinkSourceSplit<T>> - Overrides:
startin classFlinkSourceReaderBase<T,WindowedValue<ValueWithRecordId<T>>>
-
pollNext
public org.apache.flink.core.io.InputStatus pollNext(org.apache.flink.api.connector.source.ReaderOutput<WindowedValue<ValueWithRecordId<T>>> output) throws Exception - Throws:
Exception
-
isAvailableForAliveReaders
Check whether there are data available from alive readers. If not, set a future and wait for the periodically running wake-up task to complete that future when the check interval passes. This method is only called by the main thread, which is the only thread writing to the future ref. Note that for UnboundedSource, because the splits never finishes, there are always alive readers after the first split assigment. Hence, the return value ofFlinkSourceReaderBase.isAvailable()will effectively be determined by this method after the first split assignment.- Specified by:
isAvailableForAliveReadersin classFlinkSourceReaderBase<T,WindowedValue<ValueWithRecordId<T>>>
-
getReaderCheckpoint
protected FlinkSourceSplit<T> getReaderCheckpoint(int splitId, FlinkSourceReaderBase<T, WindowedValue<ValueWithRecordId<T>>>.ReaderAndOutput readerAndOutput) Description copied from class:FlinkSourceReaderBaseCreateFlinkSourceSplitfor givensplitId.- Specified by:
getReaderCheckpointin classFlinkSourceReaderBase<T,WindowedValue<ValueWithRecordId<T>>>
-
createReader
protected Source.Reader<T> createReader(@Nonnull FlinkSourceSplit<T> sourceSplit) throws IOException Description copied from class:FlinkSourceReaderBaseCreateSource.Readerfor givenFlinkSourceSplit.- Specified by:
createReaderin classFlinkSourceReaderBase<T,WindowedValue<ValueWithRecordId<T>>> - Throws:
IOException
-