Search in sources :

Example 1 with TestExpandingSink

use of org.apache.flink.streaming.util.TestExpandingSink in project flink by apache.

the class StreamGraphGeneratorTest method testAutoParallelismForExpandedTransformations.

@Test
public void testAutoParallelismForExpandedTransformations() {
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    env.setParallelism(2);
    DataStream<Integer> sourceDataStream = env.fromElements(1, 2, 3);
    // Parallelism is set to -1 (default parallelism identifier) to imitate the behavior of
    // the table planner. Parallelism should be set automatically after translating.
    sourceDataStream.sinkTo(new TestExpandingSink()).setParallelism(-1);
    StreamGraph graph = env.getStreamGraph();
    graph.getStreamNodes().forEach(node -> {
        if (!node.getOperatorName().startsWith("Source")) {
            assertEquals(2, node.getParallelism());
        }
    });
}
Also used : StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment) TestExpandingSink(org.apache.flink.streaming.util.TestExpandingSink) Test(org.junit.Test)

Aggregations

StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 TestExpandingSink (org.apache.flink.streaming.util.TestExpandingSink)1 Test (org.junit.Test)1