Class HybridSourceReader<T>

java.lang.Object
org.apache.flink.connector.base.source.hybrid.HybridSourceReader<T>
All Implemented Interfaces:
AutoCloseable, org.apache.flink.api.common.state.CheckpointListener, org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>

public class HybridSourceReader<T> extends Object implements org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
Hybrid source reader that delegates to the actual source reader.

This reader processes splits from a sequence of sources as determined by the enumerator. The current source is provided with SwitchSourceEvent and the reader does not require upfront knowledge of the number and order of sources. At a given point in time one underlying reader is active.

When the underlying reader has consumed all input for a source, HybridSourceReader sends SourceReaderFinishedEvent to the coordinator.

This reader does not make assumptions about the order in which sources are activated. When recovering from a checkpoint it may start processing splits for a previous source, which is indicated via SwitchSourceEvent.

  • Constructor Details

    • HybridSourceReader

      public HybridSourceReader(org.apache.flink.api.connector.source.SourceReaderContext readerContext)
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
    • pollNext

      public org.apache.flink.core.io.InputStatus pollNext(org.apache.flink.api.connector.source.ReaderOutput output) throws Exception
      Specified by:
      pollNext in interface org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
      Throws:
      Exception
    • snapshotState

      public List<HybridSourceSplit> snapshotState(long checkpointId)
      Specified by:
      snapshotState in interface org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
    • notifyCheckpointComplete

      public void notifyCheckpointComplete(long checkpointId) throws Exception
      Specified by:
      notifyCheckpointComplete in interface org.apache.flink.api.common.state.CheckpointListener
      Specified by:
      notifyCheckpointComplete in interface org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
      Throws:
      Exception
    • notifyCheckpointAborted

      public void notifyCheckpointAborted(long checkpointId) throws Exception
      Specified by:
      notifyCheckpointAborted in interface org.apache.flink.api.common.state.CheckpointListener
      Throws:
      Exception
    • isAvailable

      public CompletableFuture<Void> isAvailable()
      Specified by:
      isAvailable in interface org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
    • addSplits

      public void addSplits(List<HybridSourceSplit> splits)
      Specified by:
      addSplits in interface org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
    • notifyNoMoreSplits

      public void notifyNoMoreSplits()
      Specified by:
      notifyNoMoreSplits in interface org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
    • handleSourceEvents

      public void handleSourceEvents(org.apache.flink.api.connector.source.SourceEvent sourceEvent)
      Specified by:
      handleSourceEvents in interface org.apache.flink.api.connector.source.SourceReader<T,HybridSourceSplit>
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception