Interface DataStreamSourceExternalContext<T>
- Type Parameters:
T- Type of elements after deserialization by source
- All Superinterfaces:
AutoCloseable,ExternalContext,org.apache.flink.api.java.typeutils.ResultTypeQueryable<T>
@Experimental
public interface DataStreamSourceExternalContext<T>
extends ExternalContext, org.apache.flink.api.java.typeutils.ResultTypeQueryable<T>
External context for DataStream sources.
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.flink.api.connector.source.Source<T,?, ?> createSource(TestingSourceSettings sourceSettings) Create an instance ofSourcesatisfying given options.createSourceSplitDataWriter(TestingSourceSettings sourceSettings) Create a new split in the external system and return a data writer corresponding to the new split.generateTestData(TestingSourceSettings sourceSettings, int splitIndex, long seed) Generate test data.Methods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface org.apache.flink.connector.testframe.external.ExternalContext
getConnectorJarPathsMethods inherited from interface org.apache.flink.api.java.typeutils.ResultTypeQueryable
getProducedType
-
Method Details
-
createSource
org.apache.flink.api.connector.source.Source<T,?, createSource?> (TestingSourceSettings sourceSettings) throws UnsupportedOperationException Create an instance ofSourcesatisfying given options.- Parameters:
sourceSettings- settings of the source- Throws:
UnsupportedOperationException- if the provided option is not supported.
-
createSourceSplitDataWriter
Create a new split in the external system and return a data writer corresponding to the new split.- Parameters:
sourceSettings- options of the source
-
generateTestData
Generate test data.These test data will be written to external system using
ExternalSystemSplitDataWriter, consume back by source in testing Flink job, and make comparison withObject.equals(Object)for validating correctness.Note: Make sure that the
Object.equals(Object)returns false when the records in different splits.- Parameters:
sourceSettings- options of the sourcesplitIndex- index of the split.seed- Seed for generating random test data set.- Returns:
- List of generated test data.
-