Class TestSourceReader<T>
- java.lang.Object
-
- org.apache.flink.test.util.source.TestSourceReader<T>
-
- Type Parameters:
T- The type of records produced by this reader
- All Implemented Interfaces:
AutoCloseable,org.apache.flink.api.common.state.CheckpointListener,org.apache.flink.api.connector.source.SourceReader<T,TestSplit>
@PublicEvolving public class TestSourceReader<T> extends Object implements org.apache.flink.api.connector.source.SourceReader<T,TestSplit>
Base class for test source readers that provides default implementations for all SourceReader methods. Tests can extend this class and override only the methods they need to customize, typically justpollNext(ReaderOutput).By default, this reader:
- Returns
InputStatus.END_OF_INPUTfrompollNext(ReaderOutput) - Returns empty list from
snapshotState(long) - Provides a completed future from
isAvailable() - No-ops for all other methods
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.flink.api.connector.source.SourceReaderContextcontext
-
Constructor Summary
Constructors Constructor Description TestSourceReader(org.apache.flink.api.connector.source.SourceReaderContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSplits(List<TestSplit> splits)voidclose()CompletableFuture<Void>isAvailable()voidnotifyNoMoreSplits()org.apache.flink.core.io.InputStatuspollNext(org.apache.flink.api.connector.source.ReaderOutput<T> output)List<TestSplit>snapshotState(long checkpointId)voidstart()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Method Detail
-
start
public void start()
-
pollNext
public org.apache.flink.core.io.InputStatus pollNext(org.apache.flink.api.connector.source.ReaderOutput<T> output) throws Exception
-
isAvailable
public CompletableFuture<Void> isAvailable()
-
notifyNoMoreSplits
public void notifyNoMoreSplits()
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
-