Class FakeSourceReaderContext
- All Implemented Interfaces:
org.apache.flink.api.connector.source.SourceReaderContext
SourceReaderContext for the tests of a pull-assignment source reader.
sendSplitRequest() is counted rather than refused, because asking for the next split
is how such a reader gets work and a test has to be able to count the asks. A
push-assigned source wants its own fake, in which that method throws — the Pub/Sub source
keeps one for exactly that reason, so a test fails if it ever starts requesting splits (
docs/adr/0050).
The metric group is a constructor parameter rather than something built here: a caller already
holds one that its assertions read through, and taking it keeps
InternalSourceReaderMetricGroup — an unannotated flink-runtime type — out of this module's main
sources and therefore out of the Flink API tier audit.
Everything else answers what a reader reads, and sendSourceEventToCoordinator records:
sourceEvents() returns what the reader sent, in order, which is how a test of a reader
that reports to its coordinator asserts the report was made.
-
Constructor Summary
ConstructorsConstructorDescriptionFakeSourceReaderContext(org.apache.flink.metrics.groups.SourceReaderMetricGroup metricGroup) FakeSourceReaderContext(org.apache.flink.metrics.groups.SourceReaderMetricGroup metricGroup, org.apache.flink.configuration.Configuration configuration) -
Method Summary
Modifier and TypeMethodDescriptionintorg.apache.flink.configuration.Configurationintorg.apache.flink.util.UserCodeClassLoaderImplemented here rather than throughSimpleUserCodeClassLoader.create(...): that factory is unannotated, and the interface it satisfies is@PublicEvolvingwith two methods, so writing them costs less than carrying an allowlist entry for a helper.org.apache.flink.metrics.groups.SourceReaderMetricGroupvoidsendSourceEventToCoordinator(org.apache.flink.api.connector.source.SourceEvent sourceEvent) voidList<org.apache.flink.api.connector.source.SourceEvent>Returns the source events sent to the coordinator, in order.intReturns how many splits this reader has asked the enumerator for.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.flink.api.connector.source.SourceReaderContext
emitWatermark
-
Constructor Details
-
FakeSourceReaderContext
public FakeSourceReaderContext(org.apache.flink.metrics.groups.SourceReaderMetricGroup metricGroup) -
FakeSourceReaderContext
public FakeSourceReaderContext(org.apache.flink.metrics.groups.SourceReaderMetricGroup metricGroup, org.apache.flink.configuration.Configuration configuration)
-
-
Method Details
-
splitRequests
public int splitRequests()Returns how many splits this reader has asked the enumerator for. -
sourceEvents
Returns the source events sent to the coordinator, in order. -
metricGroup
public org.apache.flink.metrics.groups.SourceReaderMetricGroup metricGroup()- Specified by:
metricGroupin interfaceorg.apache.flink.api.connector.source.SourceReaderContext
-
getConfiguration
public org.apache.flink.configuration.Configuration getConfiguration()- Specified by:
getConfigurationin interfaceorg.apache.flink.api.connector.source.SourceReaderContext
-
getLocalHostName
- Specified by:
getLocalHostNamein interfaceorg.apache.flink.api.connector.source.SourceReaderContext
-
getIndexOfSubtask
public int getIndexOfSubtask()- Specified by:
getIndexOfSubtaskin interfaceorg.apache.flink.api.connector.source.SourceReaderContext
-
sendSplitRequest
public void sendSplitRequest()- Specified by:
sendSplitRequestin interfaceorg.apache.flink.api.connector.source.SourceReaderContext
-
sendSourceEventToCoordinator
public void sendSourceEventToCoordinator(org.apache.flink.api.connector.source.SourceEvent sourceEvent) - Specified by:
sendSourceEventToCoordinatorin interfaceorg.apache.flink.api.connector.source.SourceReaderContext
-
getUserCodeClassLoader
public org.apache.flink.util.UserCodeClassLoader getUserCodeClassLoader()Implemented here rather than throughSimpleUserCodeClassLoader.create(...): that factory is unannotated, and the interface it satisfies is@PublicEvolvingwith two methods, so writing them costs less than carrying an allowlist entry for a helper.- Specified by:
getUserCodeClassLoaderin interfaceorg.apache.flink.api.connector.source.SourceReaderContext
-
currentParallelism
public int currentParallelism()- Specified by:
currentParallelismin interfaceorg.apache.flink.api.connector.source.SourceReaderContext
-