Class TestingReaderContext
- java.lang.Object
-
- org.apache.flink.connector.testutils.source.reader.TestingReaderContext
-
- All Implemented Interfaces:
SourceReaderContext
public class TestingReaderContext extends Object implements SourceReaderContext
A testing implementation of theSourceReaderContext
.
-
-
Constructor Summary
Constructors Constructor Description TestingReaderContext()
TestingReaderContext(Configuration config, SourceReaderMetricGroup metricGroup)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearSentEvents()
int
currentParallelism()
Get the current parallelism of this Source.Configuration
getConfiguration()
Gets the configuration with which Flink was started.int
getIndexOfSubtask()
String
getLocalHostName()
Gets the hostname of the machine where this reader is executed.int
getNumSplitRequests()
List<SourceEvent>
getSentEvents()
UserCodeClassLoader
getUserCodeClassLoader()
Gets theUserCodeClassLoader
to load classes that are not in system's classpath, but are part of the jar file of a user job.SourceReaderMetricGroup
metricGroup()
void
sendSourceEventToCoordinator(SourceEvent sourceEvent)
Send a source event to the source coordinator.void
sendSplitRequest()
Sends a split request to the source'sSplitEnumerator
.
-
-
-
Constructor Detail
-
TestingReaderContext
public TestingReaderContext()
-
TestingReaderContext
public TestingReaderContext(Configuration config, SourceReaderMetricGroup metricGroup)
-
-
Method Detail
-
metricGroup
public SourceReaderMetricGroup metricGroup()
- Specified by:
metricGroup
in interfaceSourceReaderContext
- Returns:
- The metric group this source belongs to.
-
getConfiguration
public Configuration getConfiguration()
Description copied from interface:SourceReaderContext
Gets the configuration with which Flink was started.- Specified by:
getConfiguration
in interfaceSourceReaderContext
-
getLocalHostName
public String getLocalHostName()
Description copied from interface:SourceReaderContext
Gets the hostname of the machine where this reader is executed. This can be used to request splits local to the machine, if needed.- Specified by:
getLocalHostName
in interfaceSourceReaderContext
-
getIndexOfSubtask
public int getIndexOfSubtask()
- Specified by:
getIndexOfSubtask
in interfaceSourceReaderContext
- Returns:
- The index of this subtask.
-
sendSplitRequest
public void sendSplitRequest()
Description copied from interface:SourceReaderContext
Sends a split request to the source'sSplitEnumerator
. This will result in a call to theSplitEnumerator.handleSplitRequest(int, String)
method, with this reader's parallel subtask id and the hostname where this reader runs.- Specified by:
sendSplitRequest
in interfaceSourceReaderContext
-
sendSourceEventToCoordinator
public void sendSourceEventToCoordinator(SourceEvent sourceEvent)
Description copied from interface:SourceReaderContext
Send a source event to the source coordinator.- Specified by:
sendSourceEventToCoordinator
in interfaceSourceReaderContext
- Parameters:
sourceEvent
- the source event to coordinator.
-
getUserCodeClassLoader
public UserCodeClassLoader getUserCodeClassLoader()
Description copied from interface:SourceReaderContext
Gets theUserCodeClassLoader
to load classes that are not in system's classpath, but are part of the jar file of a user job.- Specified by:
getUserCodeClassLoader
in interfaceSourceReaderContext
- See Also:
UserCodeClassLoader
-
currentParallelism
public int currentParallelism()
Description copied from interface:SourceReaderContext
Get the current parallelism of this Source.- Specified by:
currentParallelism
in interfaceSourceReaderContext
- Returns:
- the parallelism of the Source.
-
getNumSplitRequests
public int getNumSplitRequests()
-
getSentEvents
public List<SourceEvent> getSentEvents()
-
clearSentEvents
public void clearSentEvents()
-
-