Class AbstractTestSourceBase<T,EnumChkptState>
- java.lang.Object
-
- org.apache.flink.test.util.source.AbstractTestSourceBase<T,EnumChkptState>
-
- Type Parameters:
T- The type of records produced by this sourceEnumChkptState- 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
AbstractTestSourcewhich fixes the enumerator state toVoid. Test cases that need checkpointing can create their own extensions of this base class.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractTestSourceBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.org.apache.flink.api.connector.source.SourceReader<T,TestSplit>createReader(org.apache.flink.api.connector.source.SourceReaderContext readerContext)Creates a source reader.org.apache.flink.api.connector.source.BoundednessgetBoundedness()abstract org.apache.flink.core.io.SimpleVersionedSerializer<EnumChkptState>getEnumeratorCheckpointSerializer()Returns the serializer for enumerator checkpoints.org.apache.flink.core.io.SimpleVersionedSerializer<TestSplit>getSplitSerializer()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.
-
-
-
Method Detail
-
getBoundedness
public org.apache.flink.api.connector.source.Boundedness getBoundedness()
- Specified by:
getBoundednessin interfaceorg.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:
createReaderin interfaceorg.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 aTestSplitEnumeratorwith no checkpoint state.- Specified by:
createEnumeratorin interfaceorg.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 newTestSplitEnumeratorand ignores the checkpoint state.- Specified by:
restoreEnumeratorin interfaceorg.apache.flink.api.connector.source.Source<T,TestSplit,EnumChkptState>- Parameters:
enumContext- The enumerator contextcheckpoint- The checkpoint state to restore from- Returns:
- The restored split enumerator
-
getSplitSerializer
public org.apache.flink.core.io.SimpleVersionedSerializer<TestSplit> getSplitSerializer()
- Specified by:
getSplitSerializerin interfaceorg.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:
getEnumeratorCheckpointSerializerin interfaceorg.apache.flink.api.connector.source.Source<T,TestSplit,EnumChkptState>
-
-