Class FlinkUnboundedSourceReader<T>

  • Type Parameters:
    T - the output element type of the encapsulated Beam UnboundedReader.
    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 Flink SourceReader implementation that reads from the assigned FlinkSourceSplits by using Beam UnboundedReaders.

    This reader consumes all the assigned source splits concurrently.

    • 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: FlinkSourceReaderBase
        To 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:
        addSplitsToUnfinishedForCheckpoint in class FlinkSourceReaderBase<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:
        start in interface org.apache.flink.api.connector.source.SourceReader<org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>,​FlinkSourceSplit<T>>
        Overrides:
        start in class FlinkSourceReaderBase<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 of FlinkSourceReaderBase.isAvailable() will effectively be determined by this method after the first split assignment.
        Specified by:
        isAvailableForAliveReaders in class FlinkSourceReaderBase<T,​org.apache.beam.sdk.values.WindowedValue<org.apache.beam.sdk.values.ValueWithRecordId<T>>>