Class FromElementsSource<OUT>
- java.lang.Object
-
- org.apache.flink.connector.testframe.source.FromElementsSource<OUT>
-
- All Implemented Interfaces:
Serializable
,Source<OUT,FromElementsSplit,NoOpEnumState>
,SourceReaderFactory<OUT,FromElementsSplit>
public class FromElementsSource<OUT> extends Object implements Source<OUT,FromElementsSplit,NoOpEnumState>
ASource
implementation that reads data from a list or from aFromElementsSource.ElementsSupplier
and stops reading at the fixed position. The source will wait until the checkpoint or savepoint triggered, the source is useful for connector tests.Note: This parallelism of source must be 1.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FromElementsSource.ElementsSupplier<OUT>
A supplier of elements that allows to get those from any offset at any time.
-
Constructor Summary
Constructors Constructor Description FromElementsSource(List<OUT> elements)
FromElementsSource(Boundedness boundedness, List<OUT> elements, Integer emittedElementsNum)
FromElementsSource(FromElementsSource.ElementsSupplier<OUT> elementsSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SplitEnumerator<FromElementsSplit,NoOpEnumState>
createEnumerator(SplitEnumeratorContext<FromElementsSplit> enumContext)
Creates a new SplitEnumerator for this source, starting a new input.SourceReader<OUT,FromElementsSplit>
createReader(SourceReaderContext readerContext)
Creates a new reader to read data from the splits it gets assigned.Boundedness
getBoundedness()
Get the boundedness of this source.SimpleVersionedSerializer<NoOpEnumState>
getEnumeratorCheckpointSerializer()
Creates the serializer for theSplitEnumerator
checkpoint.SimpleVersionedSerializer<FromElementsSplit>
getSplitSerializer()
Creates a serializer for the source splits.SplitEnumerator<FromElementsSplit,NoOpEnumState>
restoreEnumerator(SplitEnumeratorContext<FromElementsSplit> enumContext, NoOpEnumState checkpoint)
Restores an enumerator from a checkpoint.
-
-
-
Constructor Detail
-
FromElementsSource
public FromElementsSource(FromElementsSource.ElementsSupplier<OUT> elementsSupplier)
-
FromElementsSource
public FromElementsSource(Boundedness boundedness, List<OUT> elements, Integer emittedElementsNum)
-
-
Method Detail
-
getBoundedness
public Boundedness getBoundedness()
Description copied from interface:Source
Get the boundedness of this source.- Specified by:
getBoundedness
in interfaceSource<OUT,FromElementsSplit,NoOpEnumState>
- Returns:
- the boundedness of this source.
-
createReader
public SourceReader<OUT,FromElementsSplit> createReader(SourceReaderContext readerContext) throws Exception
Description copied from interface:SourceReaderFactory
Creates a new reader to read data from the splits it gets assigned. The reader starts fresh and does not have any state to resume.- Specified by:
createReader
in interfaceSourceReaderFactory<OUT,FromElementsSplit>
- Parameters:
readerContext
- Thecontext
for the source reader.- Returns:
- A new SourceReader.
- Throws:
Exception
- The implementor is free to forward all exceptions directly. Exceptions thrown from this method cause task failure/recovery.
-
createEnumerator
public SplitEnumerator<FromElementsSplit,NoOpEnumState> createEnumerator(SplitEnumeratorContext<FromElementsSplit> enumContext) throws Exception
Description copied from interface:Source
Creates a new SplitEnumerator for this source, starting a new input.- Specified by:
createEnumerator
in interfaceSource<OUT,FromElementsSplit,NoOpEnumState>
- Parameters:
enumContext
- Thecontext
for the split enumerator.- Returns:
- A new SplitEnumerator.
- Throws:
Exception
- The implementor is free to forward all exceptions directly. Exceptions thrown from this method cause JobManager failure/recovery.
-
restoreEnumerator
public SplitEnumerator<FromElementsSplit,NoOpEnumState> restoreEnumerator(SplitEnumeratorContext<FromElementsSplit> enumContext, NoOpEnumState checkpoint) throws Exception
Description copied from interface:Source
Restores an enumerator from a checkpoint.- Specified by:
restoreEnumerator
in interfaceSource<OUT,FromElementsSplit,NoOpEnumState>
- Parameters:
enumContext
- Thecontext
for the restored split enumerator.checkpoint
- The checkpoint to restore the SplitEnumerator from.- Returns:
- A SplitEnumerator restored from the given checkpoint.
- Throws:
Exception
- The implementor is free to forward all exceptions directly. Exceptions thrown from this method cause JobManager failure/recovery.
-
getSplitSerializer
public SimpleVersionedSerializer<FromElementsSplit> getSplitSerializer()
Description copied from interface:Source
Creates a serializer for the source splits. Splits are serialized when sending them from enumerator to reader, and when checkpointing the reader's current state.- Specified by:
getSplitSerializer
in interfaceSource<OUT,FromElementsSplit,NoOpEnumState>
- Returns:
- The serializer for the split type.
-
getEnumeratorCheckpointSerializer
public SimpleVersionedSerializer<NoOpEnumState> getEnumeratorCheckpointSerializer()
Description copied from interface:Source
Creates the serializer for theSplitEnumerator
checkpoint. The serializer is used for the result of theSplitEnumerator.snapshotState(long)
method.- Specified by:
getEnumeratorCheckpointSerializer
in interfaceSource<OUT,FromElementsSplit,NoOpEnumState>
- Returns:
- The serializer for the SplitEnumerator checkpoint.
-
-