Class CollectingSourceOutput<T>

java.lang.Object
io.github.flink.gcp.connector.testutils.CollectingSourceOutput<T>
All Implemented Interfaces:
org.apache.flink.api.common.eventtime.WatermarkOutput, org.apache.flink.api.connector.source.SourceOutput<T>

@Internal public final class CollectingSourceOutput<T> extends Object implements org.apache.flink.api.connector.source.SourceOutput<T>
SourceOutput recording emitted records and their timestamps — what a RecordEmitter is handed, and what a test driving one asserts against.

Written here rather than taken from Flink because flink-connector-base's test jar is not a dependency of any module in this repository.

timestamps() is padded rather than sparse: a record emitted without a timestamp appears as null rather than not appearing at all, so an assertion on it distinguishes "one record, no timestamp" from "no record".

Not thread-safe, and it does not need to be: a SourceReaderBase hands its record emitter the output on the thread that called pollNext, never on a fetcher thread. A test collecting from more than one thread has to synchronize itself.

  • Constructor Details

    • CollectingSourceOutput

      public CollectingSourceOutput()
  • Method Details

    • failOnCollect

      public void failOnCollect(RuntimeException failure)
      Makes every subsequent collect throw, standing in for a failing chained operator.
    • failOnCollect

      public void failOnCollect(Error failure)
      Makes every subsequent collect throw, standing in for a failing chained operator.
    • failAfterCollects

      public void failAfterCollects(int successfulCollects, RuntimeException failure)
      Makes collect throw after the requested number of successful calls.
    • failAfterCollects

      public void failAfterCollects(int successfulCollects, Error failure)
      Makes collect throw an error after the requested number of successful calls.
    • records

      public List<T> records()
    • timestamps

      public List<Long> timestamps()
    • collect

      public void collect(T record)
      Specified by:
      collect in interface org.apache.flink.api.connector.source.SourceOutput<T>
    • collect

      public void collect(T record, long timestamp)
      Specified by:
      collect in interface org.apache.flink.api.connector.source.SourceOutput<T>
    • emitWatermark

      public void emitWatermark(org.apache.flink.api.common.eventtime.Watermark watermark)
      Specified by:
      emitWatermark in interface org.apache.flink.api.common.eventtime.WatermarkOutput
    • markIdle

      public void markIdle()
      Specified by:
      markIdle in interface org.apache.flink.api.common.eventtime.WatermarkOutput
    • markActive

      public void markActive()
      Specified by:
      markActive in interface org.apache.flink.api.common.eventtime.WatermarkOutput