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 Details

    • createSource

      org.apache.flink.api.connector.source.Source<T,?,?> createSource(TestingSourceSettings sourceSettings) throws UnsupportedOperationException
      Create an instance of Source satisfying given options.
      Parameters:
      sourceSettings - settings of the source
      Throws:
      UnsupportedOperationException - if the provided option is not supported.
    • createSourceSplitDataWriter

      ExternalSystemSplitDataWriter<T> createSourceSplitDataWriter(TestingSourceSettings sourceSettings)
      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

      List<T> generateTestData(TestingSourceSettings sourceSettings, int splitIndex, long seed)
      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 with Object.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 source
      splitIndex - index of the split.
      seed - Seed for generating random test data set.
      Returns:
      List of generated test data.