use of org.apache.flink.streaming.util.EvenOddOutputSelector in project flink by apache.
the class StreamGraphGeneratorTest method testVirtualTransformations2.
/**
* This tests whether virtual Transformations behave correctly.
*
* Checks whether output selector, partitioning works correctly when applied on a union.
*/
@Test
public void testVirtualTransformations2() throws Exception {
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<Integer> source = env.fromElements(1, 10);
DataStream<Integer> rebalanceMap = source.rebalance().map(new NoOpIntMap());
DataStream<Integer> map1 = rebalanceMap.map(new NoOpIntMap());
DataStream<Integer> map2 = rebalanceMap.map(new NoOpIntMap());
DataStream<Integer> map3 = rebalanceMap.map(new NoOpIntMap());
EvenOddOutputSelector selector = new EvenOddOutputSelector();
SingleOutputStreamOperator<Integer> unionedMap = map1.union(map2).union(map3).broadcast().split(selector).select("foo").map(new NoOpIntMap());
unionedMap.addSink(new DiscardingSink<Integer>());
StreamGraph graph = env.getStreamGraph();
// verify that the properties are correctly set on all input operators
assertTrue(graph.getStreamNode(map1.getId()).getOutEdges().get(0).getPartitioner() instanceof BroadcastPartitioner);
assertTrue(graph.getStreamNode(map1.getId()).getOutEdges().get(0).getSelectedNames().get(0).equals("foo"));
assertTrue(graph.getStreamNode(map1.getId()).getOutputSelectors().contains(selector));
assertTrue(graph.getStreamNode(map2.getId()).getOutEdges().get(0).getPartitioner() instanceof BroadcastPartitioner);
assertTrue(graph.getStreamNode(map2.getId()).getOutEdges().get(0).getSelectedNames().get(0).equals("foo"));
assertTrue(graph.getStreamNode(map2.getId()).getOutputSelectors().contains(selector));
assertTrue(graph.getStreamNode(map3.getId()).getOutEdges().get(0).getPartitioner() instanceof BroadcastPartitioner);
assertTrue(graph.getStreamNode(map3.getId()).getOutEdges().get(0).getSelectedNames().get(0).equals("foo"));
assertTrue(graph.getStreamNode(map3.getId()).getOutputSelectors().contains(selector));
}
Aggregations