Class 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 or addReader(int) for custom split assignment.

    For common patterns, use the concrete implementations:

    • Field Detail

      • context

        protected final org.apache.flink.api.connector.source.SplitEnumeratorContext<TestSplit> context
    • Constructor Detail

      • TestSplitEnumerator

        public TestSplitEnumerator​(org.apache.flink.api.connector.source.SplitEnumeratorContext<TestSplit> context,
                                   EnumChkptState checkpointState)
    • Method Detail

      • start

        public void start()
        Specified by:
        start in interface org.apache.flink.api.connector.source.SplitEnumerator<TestSplit,​EnumChkptState>
      • handleSplitRequest

        public void handleSplitRequest​(int subtaskId,
                                       String requesterHostname)
        Specified by:
        handleSplitRequest in interface org.apache.flink.api.connector.source.SplitEnumerator<TestSplit,​EnumChkptState>
      • addSplitsBack

        public void addSplitsBack​(List<TestSplit> splits,
                                  int subtaskId)
        Specified by:
        addSplitsBack in interface org.apache.flink.api.connector.source.SplitEnumerator<TestSplit,​EnumChkptState>
      • addReader

        public void addReader​(int subtaskId)
        Specified by:
        addReader in interface org.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:
        snapshotState in interface org.apache.flink.api.connector.source.SplitEnumerator<TestSplit,​EnumChkptState>