Search in sources :

Example 6 with TestingBatchExecNode

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]))));
}
Also used : TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with TestingBatchExecNode

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());
}
Also used : TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode) TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode) ExecNode(org.apache.flink.table.planner.plan.nodes.exec.ExecNode) Test(org.junit.Test)

Example 8 with TestingBatchExecNode

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]));
}
Also used : TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode) TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode) ExecNode(org.apache.flink.table.planner.plan.nodes.exec.ExecNode) Test(org.junit.Test)

Example 9 with TestingBatchExecNode

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);
}
Also used : InputProperty(org.apache.flink.table.planner.plan.nodes.exec.InputProperty) Configuration(org.apache.flink.configuration.Configuration) TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode) Test(org.junit.Test) RowType(org.apache.flink.table.types.logical.RowType) ExecNode(org.apache.flink.table.planner.plan.nodes.exec.ExecNode) Consumer(java.util.function.Consumer) StreamExchangeMode(org.apache.flink.streaming.api.transformations.StreamExchangeMode) ExecEdge(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge) BatchExecExchange(org.apache.flink.table.planner.plan.nodes.exec.batch.BatchExecExchange) Optional(java.util.Optional) Assert(org.junit.Assert) Collections(java.util.Collections) ExecEdge(org.apache.flink.table.planner.plan.nodes.exec.ExecEdge) Configuration(org.apache.flink.configuration.Configuration) TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode) BatchExecExchange(org.apache.flink.table.planner.plan.nodes.exec.batch.BatchExecExchange) TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode) ExecNode(org.apache.flink.table.planner.plan.nodes.exec.ExecNode) Test(org.junit.Test)

Example 10 with TestingBatchExecNode

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;
}
Also used : TestingBatchExecNode(org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode)

Aggregations

TestingBatchExecNode (org.apache.flink.table.planner.plan.nodes.exec.TestingBatchExecNode)10 Test (org.junit.Test)9 ExecNode (org.apache.flink.table.planner.plan.nodes.exec.ExecNode)6 Configuration (org.apache.flink.configuration.Configuration)2 BatchExecExchange (org.apache.flink.table.planner.plan.nodes.exec.batch.BatchExecExchange)2 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 StreamExchangeMode (org.apache.flink.streaming.api.transformations.StreamExchangeMode)1 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)1 InputProperty (org.apache.flink.table.planner.plan.nodes.exec.InputProperty)1 RowType (org.apache.flink.table.types.logical.RowType)1 Assert (org.junit.Assert)1