Search in sources :

Example 1 with SourceStreamTask

use of org.apache.flink.streaming.runtime.tasks.SourceStreamTask in project flink by apache.

the class StreamSourceOperatorWatermarksTest method setupSourceStreamTask.

private static <T> StreamTaskTestHarness<T> setupSourceStreamTask(StreamSource<T, ?> sourceOperator, TypeInformation<T> outputType, final boolean cancelImmediatelyAfterCreation) {
    final StreamTaskTestHarness<T> testHarness = new StreamTaskTestHarness<>((env) -> {
        SourceStreamTask<T, ?, ?> sourceTask = new SourceStreamTask<>(env);
        if (cancelImmediatelyAfterCreation) {
            try {
                sourceTask.cancel();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return sourceTask;
    }, outputType);
    testHarness.setupOutputForSingletonOperatorChain();
    StreamConfig streamConfig = testHarness.getStreamConfig();
    streamConfig.setStreamOperator(sourceOperator);
    streamConfig.setOperatorID(new OperatorID());
    streamConfig.setTimeCharacteristic(TimeCharacteristic.EventTime);
    return testHarness;
}
Also used : StreamConfig(org.apache.flink.streaming.api.graph.StreamConfig) StreamTaskTestHarness(org.apache.flink.streaming.runtime.tasks.StreamTaskTestHarness) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) SourceStreamTask(org.apache.flink.streaming.runtime.tasks.SourceStreamTask) CancelTaskException(org.apache.flink.runtime.execution.CancelTaskException)

Aggregations

CancelTaskException (org.apache.flink.runtime.execution.CancelTaskException)1 OperatorID (org.apache.flink.runtime.jobgraph.OperatorID)1 StreamConfig (org.apache.flink.streaming.api.graph.StreamConfig)1 SourceStreamTask (org.apache.flink.streaming.runtime.tasks.SourceStreamTask)1 StreamTaskTestHarness (org.apache.flink.streaming.runtime.tasks.StreamTaskTestHarness)1