Class FlinkUnboundedSourceReader<T>
- java.lang.Object
-
- org.apache.beam.runners.flink.translation.wrappers.streaming.io.source.FlinkSourceReaderBase<T,org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.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:
java.lang.AutoCloseable,org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.api.connector.source.SourceReader<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>,FlinkSourceSplit<T>>
public class FlinkUnboundedSourceReader<T> extends FlinkSourceReaderBase<T,org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>>
A FlinkSourceReaderimplementation that reads from the assignedFlinkSourceSplitsby using BeamUnboundedReaders.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
Fields Modifier and Type Field Description protected static java.lang.StringPENDING_BYTES_METRIC_NAME-
Fields inherited from class org.apache.beam.runners.flink.translation.wrappers.streaming.io.source.FlinkSourceReaderBase
AVAILABLE_NOW, context, idleTimeoutMs, invocationUtil, numRecordsInCounter, pipelineOptions, timestampExtractor
-
-
Constructor Summary
Constructors Modifier Constructor Description FlinkUnboundedSourceReader(java.lang.String stepName, org.apache.flink.api.connector.source.SourceReaderContext context, org.apache.beam.sdk.options.PipelineOptions pipelineOptions, @Nullable java.util.function.Function<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>,java.lang.Long> timestampExtractor)protectedFlinkUnboundedSourceReader(java.lang.String stepName, org.apache.flink.api.connector.source.SourceReaderContext context, org.apache.beam.sdk.options.PipelineOptions pipelineOptions, java.util.concurrent.ScheduledExecutorService executor, @Nullable java.util.function.Function<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>,java.lang.Long> timestampExtractor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddSplitsToUnfinishedForCheckpoint(long checkpointId, java.util.List<FlinkSourceSplit<T>> flinkSourceSplits)To be overridden in unbounded reader.protected org.apache.beam.sdk.io.Source.Reader<T>createReader(FlinkSourceSplit<T> sourceSplit)CreateSource.Readerfor givenFlinkSourceSplit.protected FlinkSourceSplit<T>getReaderCheckpoint(int splitId, FlinkSourceReaderBase.ReaderAndOutput readerAndOutput)CreateFlinkSourceSplitfor givensplitId.protected java.util.concurrent.CompletableFuture<java.lang.Void>isAvailableForAliveReaders()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<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.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, sourceSplits
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
PENDING_BYTES_METRIC_NAME
protected static final java.lang.String PENDING_BYTES_METRIC_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FlinkUnboundedSourceReader
public FlinkUnboundedSourceReader(java.lang.String stepName, org.apache.flink.api.connector.source.SourceReaderContext context, org.apache.beam.sdk.options.PipelineOptions pipelineOptions, @Nullable java.util.function.Function<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>,java.lang.Long> timestampExtractor)
-
FlinkUnboundedSourceReader
protected FlinkUnboundedSourceReader(java.lang.String stepName, org.apache.flink.api.connector.source.SourceReaderContext context, org.apache.beam.sdk.options.PipelineOptions pipelineOptions, java.util.concurrent.ScheduledExecutorService executor, @Nullable java.util.function.Function<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>,java.lang.Long> timestampExtractor)
-
-
Method Detail
-
addSplitsToUnfinishedForCheckpoint
protected void addSplitsToUnfinishedForCheckpoint(long checkpointId, java.util.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,org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>>
-
notifyCheckpointComplete
public void notifyCheckpointComplete(long checkpointId) throws java.lang.Exception- Throws:
java.lang.Exception
-
start
public void start()
- Specified by:
startin interfaceorg.apache.flink.api.connector.source.SourceReader<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>,FlinkSourceSplit<T>>- Overrides:
startin classFlinkSourceReaderBase<T,org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>>
-
pollNext
public org.apache.flink.core.io.InputStatus pollNext(org.apache.flink.api.connector.source.ReaderOutput<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>> output) throws java.lang.Exception
- Throws:
java.lang.Exception
-
isAvailableForAliveReaders
protected java.util.concurrent.CompletableFuture<java.lang.Void> 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,org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>>
-
getReaderCheckpoint
protected FlinkSourceSplit<T> getReaderCheckpoint(int splitId, FlinkSourceReaderBase.ReaderAndOutput readerAndOutput)
Description copied from class:FlinkSourceReaderBaseCreateFlinkSourceSplitfor givensplitId.- Specified by:
getReaderCheckpointin classFlinkSourceReaderBase<T,org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>>
-
createReader
protected org.apache.beam.sdk.io.Source.Reader<T> createReader(@Nonnull FlinkSourceSplit<T> sourceSplit) throws java.io.IOException
Description copied from class:FlinkSourceReaderBaseCreateSource.Readerfor givenFlinkSourceSplit.- Specified by:
createReaderin classFlinkSourceReaderBase<T,org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>>- Throws:
java.io.IOException
-
-