Class HybridSourceSplitEnumerator
- java.lang.Object
-
- org.apache.flink.connector.base.source.hybrid.HybridSourceSplitEnumerator
-
- All Implemented Interfaces:
AutoCloseable,org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>
public class HybridSourceSplitEnumerator extends Object implements org.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>
Wraps the actual split enumerators and facilitates source switching. Enumerators are created lazily when source switch occurs to support runtime position conversion.This enumerator delegates to the current underlying split enumerator and transitions to the next source once all readers have indicated via
SourceReaderFinishedEventthat all input was consumed.Switching between enumerators occurs by creating the new enumerator via
Source.createEnumerator(SplitEnumeratorContext). The start position can be fixed at pipeline construction time through the source or supplied at switch time through a converter function by using the end state of the previous enumerator.During subtask recovery, splits that have been assigned since the last checkpoint will be added back by the source coordinator. These splits may originate from a previous enumerator that is no longer active. In that case
HybridSourceSplitEnumeratorwill suspend forwarding to the current enumerator and replay the returned splits by activating the previous readers. After returned splits were processed, delegation to the current underlying enumerator resumes.
-
-
Constructor Summary
Constructors Constructor Description HybridSourceSplitEnumerator(org.apache.flink.api.connector.source.SplitEnumeratorContext<HybridSourceSplit> context, List<org.apache.flink.connector.base.source.hybrid.HybridSource.SourceListEntry> sources, int initialSourceIndex, HybridSourceEnumeratorState restoredEnumeratorState)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReader(int subtaskId)voidaddSplitsBack(List<HybridSourceSplit> splits, int subtaskId)voidclose()voidhandleSourceEvent(int subtaskId, org.apache.flink.api.connector.source.SourceEvent sourceEvent)voidhandleSplitRequest(int subtaskId, String requesterHostname)voidnotifyCheckpointAborted(long checkpointId)voidnotifyCheckpointComplete(long checkpointId)HybridSourceEnumeratorStatesnapshotState(long checkpointId)voidstart()
-
-
-
Constructor Detail
-
HybridSourceSplitEnumerator
public HybridSourceSplitEnumerator(org.apache.flink.api.connector.source.SplitEnumeratorContext<HybridSourceSplit> context, List<org.apache.flink.connector.base.source.hybrid.HybridSource.SourceListEntry> sources, int initialSourceIndex, HybridSourceEnumeratorState restoredEnumeratorState)
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>
-
handleSplitRequest
public void handleSplitRequest(int subtaskId, String requesterHostname)- Specified by:
handleSplitRequestin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>
-
addSplitsBack
public void addSplitsBack(List<HybridSourceSplit> splits, int subtaskId)
- Specified by:
addSplitsBackin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>
-
addReader
public void addReader(int subtaskId)
- Specified by:
addReaderin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>
-
snapshotState
public HybridSourceEnumeratorState snapshotState(long checkpointId) throws Exception
- Specified by:
snapshotStatein interfaceorg.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>- Throws:
Exception
-
notifyCheckpointComplete
public void notifyCheckpointComplete(long checkpointId) throws Exception- Specified by:
notifyCheckpointCompletein interfaceorg.apache.flink.api.common.state.CheckpointListener- Specified by:
notifyCheckpointCompletein interfaceorg.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>- Throws:
Exception
-
notifyCheckpointAborted
public void notifyCheckpointAborted(long checkpointId) throws Exception- Specified by:
notifyCheckpointAbortedin interfaceorg.apache.flink.api.common.state.CheckpointListener- Throws:
Exception
-
handleSourceEvent
public void handleSourceEvent(int subtaskId, org.apache.flink.api.connector.source.SourceEvent sourceEvent)- Specified by:
handleSourceEventin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceorg.apache.flink.api.connector.source.SplitEnumerator<HybridSourceSplit,HybridSourceEnumeratorState>- Throws:
IOException
-
-