Class TestSplitEnumerator<EnumChkptState>
- java.lang.Object
-
- org.apache.flink.test.util.source.TestSplitEnumerator<EnumChkptState>
-
- Type Parameters:
EnumChkptState- The type of the enumerator checkpoint state
- All Implemented Interfaces:
AutoCloseable,org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.api.connector.source.SplitEnumerator<TestSplit,EnumChkptState>
- Direct Known Subclasses:
SingleSplitEnumerator
@PublicEvolving public class TestSplitEnumerator<EnumChkptState> extends Object implements org.apache.flink.api.connector.source.SplitEnumerator<TestSplit,EnumChkptState>
Base split enumerator for test sources that provides sensible defaults for most methods.By default, this enumerator immediately signals no more splits to ensure bounded completion. Test sources can extend this class and only override the methods they need, typically just
snapshotState(long)for checkpointing behavior oraddReader(int)for custom split assignment.For common patterns, use the concrete implementations:
SingleSplitEnumerator- First reader gets one split, others get nothing
-
-
Field Summary
Fields Modifier and Type Field Description protected EnumChkptStatecheckpointStateprotected org.apache.flink.api.connector.source.SplitEnumeratorContext<TestSplit>context
-
Constructor Summary
Constructors Constructor Description TestSplitEnumerator(org.apache.flink.api.connector.source.SplitEnumeratorContext<TestSplit> context, EnumChkptState checkpointState)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReader(int subtaskId)voidaddSplitsBack(List<TestSplit> splits, int subtaskId)voidclose()voidhandleSplitRequest(int subtaskId, String requesterHostname)EnumChkptStatesnapshotState(long checkpointId)Subclasses should override this method to provide their checkpoint state.voidstart()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
context
protected final org.apache.flink.api.connector.source.SplitEnumeratorContext<TestSplit> context
-
checkpointState
protected final EnumChkptState checkpointState
-
-
Constructor Detail
-
TestSplitEnumerator
public TestSplitEnumerator(org.apache.flink.api.connector.source.SplitEnumeratorContext<TestSplit> context, EnumChkptState checkpointState)
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<TestSplit,EnumChkptState>
-
handleSplitRequest
public void handleSplitRequest(int subtaskId, String requesterHostname)- Specified by:
handleSplitRequestin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<TestSplit,EnumChkptState>
-
addSplitsBack
public void addSplitsBack(List<TestSplit> splits, int subtaskId)
- Specified by:
addSplitsBackin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<TestSplit,EnumChkptState>
-
addReader
public void addReader(int subtaskId)
- Specified by:
addReaderin interfaceorg.apache.flink.api.connector.source.SplitEnumerator<TestSplit,EnumChkptState>
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceorg.apache.flink.api.connector.source.SplitEnumerator<TestSplit,EnumChkptState>
-
snapshotState
public EnumChkptState snapshotState(long checkpointId)
Subclasses should override this method to provide their checkpoint state. The default implementation returns the checkpoint state passed in the constructor.- Specified by:
snapshotStatein interfaceorg.apache.flink.api.connector.source.SplitEnumerator<TestSplit,EnumChkptState>
-
-