use of org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode in project flink by apache.
the class InputOrderCalculatorTest method testCheckPipelinedPath.
@Test
public void testCheckPipelinedPath() {
// P = InputProperty.DamBehavior.PIPELINED, E = InputProperty.DamBehavior.END_INPUT B =
// InputProperty.DamBehavior.BLOCKING
//
// 0 -P-> 1 ----E----\
// \-P-\ \
// 2 ----E----> 3 -P-> 4
// 5 -P-> 6 -B-/
TestingBatchExecNode[] nodes = new TestingBatchExecNode[7];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = new TestingBatchExecNode("TestingBatchExecNode" + i);
}
nodes[1].addInput(nodes[0]);
nodes[3].addInput(nodes[1]);
nodes[3].addInput(nodes[2], InputProperty.builder().damBehavior(InputProperty.DamBehavior.END_INPUT).build());
nodes[3].addInput(nodes[6], InputProperty.builder().damBehavior(InputProperty.DamBehavior.BLOCKING).build());
nodes[4].addInput(nodes[1], InputProperty.builder().damBehavior(InputProperty.DamBehavior.END_INPUT).build());
nodes[4].addInput(nodes[3]);
nodes[6].addInput(nodes[5]);
Assert.assertFalse(InputOrderCalculator.checkPipelinedPath(nodes[4], new HashSet<>(Arrays.asList(nodes[2], nodes[5], nodes[6]))));
Assert.assertTrue(InputOrderCalculator.checkPipelinedPath(nodes[4], new HashSet<>(Arrays.asList(nodes[0], nodes[2]))));
}
use of org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode in project flink by apache.
the class InputOrderCalculatorTest method testCalculateInputOrderWithRelatedBoundaries.
@Test
public void testCalculateInputOrderWithRelatedBoundaries() {
// P = InputProperty.DamBehavior.PIPELINED, B = InputProperty.DamBehavior.BLOCKING
// P1 = PIPELINED + priority 1
//
// /------------(P0)------------\
// 0 -(P0)-> 1 -(B0)-> 2 -(P0)-> 4 -(P1)-> 5
// 3 -(P1)-/ 6 -(B0)-/
TestingBatchExecNode[] nodes = new TestingBatchExecNode[7];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = new TestingBatchExecNode("TestingBatchExecNode" + i);
}
nodes[1].addInput(nodes[0]);
nodes[2].addInput(nodes[1], InputProperty.builder().damBehavior(InputProperty.DamBehavior.BLOCKING).build());
nodes[2].addInput(nodes[3], InputProperty.builder().priority(1).build());
nodes[4].addInput(nodes[0]);
nodes[4].addInput(nodes[2]);
nodes[5].addInput(nodes[4], InputProperty.builder().priority(1).build());
nodes[5].addInput(nodes[6], InputProperty.builder().damBehavior(InputProperty.DamBehavior.BLOCKING).build());
InputOrderCalculator calculator = new InputOrderCalculator(nodes[5], new HashSet<>(Arrays.asList(nodes[0], nodes[1], nodes[3], nodes[6])), InputProperty.DamBehavior.BLOCKING);
Map<ExecNode<?>, Integer> result = calculator.calculate();
Assert.assertEquals(4, result.size());
Assert.assertEquals(1, result.get(nodes[0]).intValue());
Assert.assertEquals(1, result.get(nodes[1]).intValue());
Assert.assertEquals(2, result.get(nodes[3]).intValue());
Assert.assertEquals(0, result.get(nodes[6]).intValue());
}
use of org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode in project flink by apache.
the class InputPriorityGraphGeneratorTest method testCalculateBoundedPipelinedAncestors.
@Test
public void testCalculateBoundedPipelinedAncestors() {
// P = InputProperty.DamBehavior.PIPELINED, E = InputProperty.DamBehavior.END_INPUT
//
// 0 -P-> 1 -P-> 2
// 3 -P-> 4 -E/
TestingBatchExecNode[] nodes = new TestingBatchExecNode[5];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = new TestingBatchExecNode("TestingBatchExecNode" + i);
}
nodes[1].addInput(nodes[0]);
nodes[2].addInput(nodes[1]);
nodes[2].addInput(nodes[4], InputProperty.builder().damBehavior(InputProperty.DamBehavior.END_INPUT).build());
nodes[4].addInput(nodes[3]);
TestingInputPriorityConflictResolver resolver = new TestingInputPriorityConflictResolver(Collections.singletonList(nodes[2]), new HashSet<>(Collections.singleton(nodes[1])), InputProperty.DamBehavior.END_INPUT);
List<ExecNode<?>> ancestors = resolver.calculatePipelinedAncestors(nodes[2]);
Assert.assertEquals(1, ancestors.size());
Assert.assertTrue(ancestors.contains(nodes[1]));
}
use of org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode in project flink by apache.
the class InputPriorityConflictResolverTest method testDeadlockCausedByExchange.
@Test
public void testDeadlockCausedByExchange() {
// P1 = PIPELINED + priority 1
//
// 0 -(P0)-> exchange --(P0)-> 1
// \-(P1)-/
TestingBatchExecNode[] nodes = new TestingBatchExecNode[2];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = new TestingBatchExecNode("TestingBatchExecNode" + i);
}
BatchExecExchange exchange = new BatchExecExchange(InputProperty.builder().requiredDistribution(InputProperty.ANY_DISTRIBUTION).build(), (RowType) nodes[0].getOutputType(), "Exchange");
exchange.setRequiredExchangeMode(StreamExchangeMode.BATCH);
ExecEdge execEdge = ExecEdge.builder().source(nodes[0]).target(exchange).build();
exchange.setInputEdges(Collections.singletonList(execEdge));
nodes[1].addInput(exchange, InputProperty.builder().priority(0).build());
nodes[1].addInput(exchange, InputProperty.builder().priority(1).build());
InputPriorityConflictResolver resolver = new InputPriorityConflictResolver(Collections.singletonList(nodes[1]), InputProperty.DamBehavior.END_INPUT, StreamExchangeMode.BATCH, new Configuration());
resolver.detectAndResolve();
ExecNode<?> input0 = nodes[1].getInputNodes().get(0);
ExecNode<?> input1 = nodes[1].getInputNodes().get(1);
Assert.assertNotSame(input0, input1);
Consumer<ExecNode<?>> checkExchange = execNode -> {
Assert.assertTrue(execNode instanceof BatchExecExchange);
BatchExecExchange e = (BatchExecExchange) execNode;
Assert.assertEquals(Optional.of(StreamExchangeMode.BATCH), e.getRequiredExchangeMode());
Assert.assertEquals(nodes[0], e.getInputEdges().get(0).getSource());
};
checkExchange.accept(input0);
checkExchange.accept(input1);
}
use of org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode in project flink by apache.
the class TopologyGraphTest method buildLinkedNodes.
private TestingBatchExecNode[] buildLinkedNodes() {
// 0 -> 1 -> 2 --------> 5
// \-> 3 -> 4 ----/
// \
// \-> 6 -> 7
TestingBatchExecNode[] nodes = new TestingBatchExecNode[8];
for (int i = 0; i < nodes.length; i++) {
nodes[i] = new TestingBatchExecNode("TestingBatchExecNode" + i);
}
nodes[1].addInput(nodes[0]);
nodes[2].addInput(nodes[1]);
nodes[3].addInput(nodes[1]);
nodes[4].addInput(nodes[3]);
nodes[5].addInput(nodes[2]);
nodes[5].addInput(nodes[4]);
nodes[6].addInput(nodes[3]);
nodes[7].addInput(nodes[6]);
return nodes;
}
Aggregations