Class AbstractTestSourceBase<T,​EnumChkptState>

  • Type Parameters:
    T - The type of records produced by this source
    EnumChkptState - The type of the enumerator checkpoint state
    All Implemented Interfaces:
    Serializable, org.apache.flink.api.connector.source.Source<T,​TestSplit,​EnumChkptState>, org.apache.flink.api.connector.source.SourceReaderFactory<T,​TestSplit>
    Direct Known Subclasses:
    AbstractTestSource

    @PublicEvolving
    public abstract class AbstractTestSourceBase<T,​EnumChkptState>
    extends Object
    implements org.apache.flink.api.connector.source.Source<T,​TestSplit,​EnumChkptState>
    Base class for test sources that allows customization of the enumerator checkpoint type.

    Most test cases should extend AbstractTestSource which fixes the enumerator state to Void. Test cases that need checkpointing can create their own extensions of this base class.

    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractTestSourceBase

        public AbstractTestSourceBase()
    • Method Detail

      • getBoundedness

        public org.apache.flink.api.connector.source.Boundedness getBoundedness()
        Specified by:
        getBoundedness in interface org.apache.flink.api.connector.source.Source<T,​TestSplit,​EnumChkptState>
      • createReader

        public org.apache.flink.api.connector.source.SourceReader<T,​TestSplit> createReader​(org.apache.flink.api.connector.source.SourceReaderContext readerContext)
        Creates a source reader. The default implementation returns an empty reader that immediately returns END_OF_INPUT. Subclasses can override this method to provide their specific reader implementation.
        Specified by:
        createReader in interface org.apache.flink.api.connector.source.SourceReaderFactory<T,​EnumChkptState>
      • createEnumerator

        public org.apache.flink.api.connector.source.SplitEnumerator<TestSplit,​EnumChkptState> createEnumerator​(org.apache.flink.api.connector.source.SplitEnumeratorContext<TestSplit> enumContext)
        Creates a new split enumerator for fresh starts. Subclasses can override this to provide custom enumerator behavior. The default implementation returns a TestSplitEnumerator with no checkpoint state.
        Specified by:
        createEnumerator in interface org.apache.flink.api.connector.source.Source<T,​TestSplit,​EnumChkptState>
        Parameters:
        enumContext - The enumerator context
        Returns:
        The split enumerator
      • restoreEnumerator

        public org.apache.flink.api.connector.source.SplitEnumerator<TestSplit,​EnumChkptState> restoreEnumerator​(org.apache.flink.api.connector.source.SplitEnumeratorContext<TestSplit> enumContext,
                                                                                                                       EnumChkptState checkpoint)
        Restores a split enumerator from a checkpoint. Subclasses can override this to provide custom restoration logic. The default implementation creates a new TestSplitEnumerator and ignores the checkpoint state.
        Specified by:
        restoreEnumerator in interface org.apache.flink.api.connector.source.Source<T,​TestSplit,​EnumChkptState>
        Parameters:
        enumContext - The enumerator context
        checkpoint - The checkpoint state to restore from
        Returns:
        The restored split enumerator
      • getSplitSerializer

        public org.apache.flink.core.io.SimpleVersionedSerializer<TestSplit> getSplitSerializer()
        Specified by:
        getSplitSerializer in interface org.apache.flink.api.connector.source.Source<T,​TestSplit,​EnumChkptState>
      • getEnumeratorCheckpointSerializer

        public abstract org.apache.flink.core.io.SimpleVersionedSerializer<EnumChkptState> getEnumeratorCheckpointSerializer()
        Returns the serializer for enumerator checkpoints. Subclasses must implement this to provide the appropriate serializer for their checkpoint type.
        Specified by:
        getEnumeratorCheckpointSerializer in interface org.apache.flink.api.connector.source.Source<T,​TestSplit,​EnumChkptState>