Search in sources :

Example 11 with ConsumedPartitionGroup

use of org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup in project flink by apache.

the class PointwisePatternTest method test3NToN.

@Test
public void test3NToN() throws Exception {
    final int N = 17;
    ExecutionJobVertex target = setUpExecutionGraphAndGetDownstreamVertex(3 * N, N);
    for (ExecutionVertex ev : target.getTaskVertices()) {
        assertEquals(1, ev.getNumberOfInputs());
        ConsumedPartitionGroup consumedPartitionGroup = ev.getConsumedPartitionGroup(0);
        assertEquals(3, consumedPartitionGroup.size());
        int idx = 0;
        for (IntermediateResultPartitionID partitionId : consumedPartitionGroup) {
            assertEquals(ev.getParallelSubtaskIndex() * 3L + idx++, partitionId.getPartitionNumber());
        }
    }
}
Also used : ConsumedPartitionGroup(org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID) Test(org.junit.Test)

Example 12 with ConsumedPartitionGroup

use of org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup in project flink by apache.

the class PointwisePatternTest method testLowToHigh.

private void testLowToHigh(int lowDop, int highDop) throws Exception {
    if (highDop < lowDop) {
        throw new IllegalArgumentException();
    }
    final int factor = highDop / lowDop;
    final int delta = highDop % lowDop == 0 ? 0 : 1;
    ExecutionJobVertex target = setUpExecutionGraphAndGetDownstreamVertex(lowDop, highDop);
    int[] timesUsed = new int[lowDop];
    for (ExecutionVertex ev : target.getTaskVertices()) {
        assertEquals(1, ev.getNumberOfInputs());
        ConsumedPartitionGroup consumedPartitionGroup = ev.getConsumedPartitionGroup(0);
        assertEquals(1, consumedPartitionGroup.size());
        timesUsed[consumedPartitionGroup.getFirst().getPartitionNumber()]++;
    }
    for (int used : timesUsed) {
        assertTrue(used >= factor && used <= factor + delta);
    }
}
Also used : ConsumedPartitionGroup(org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup)

Example 13 with ConsumedPartitionGroup

use of org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup in project flink by apache.

the class PointwisePatternTest method test2NToN.

@Test
public void test2NToN() throws Exception {
    final int N = 17;
    ExecutionJobVertex target = setUpExecutionGraphAndGetDownstreamVertex(2 * N, N);
    for (ExecutionVertex ev : target.getTaskVertices()) {
        assertEquals(1, ev.getNumberOfInputs());
        ConsumedPartitionGroup consumedPartitionGroup = ev.getConsumedPartitionGroup(0);
        assertEquals(2, consumedPartitionGroup.size());
        int idx = 0;
        for (IntermediateResultPartitionID partitionId : consumedPartitionGroup) {
            assertEquals(ev.getParallelSubtaskIndex() * 2L + idx++, partitionId.getPartitionNumber());
        }
    }
}
Also used : ConsumedPartitionGroup(org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID) Test(org.junit.Test)

Example 14 with ConsumedPartitionGroup

use of org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup in project flink by apache.

the class PointwisePatternTest method testNTo7N.

@Test
public void testNTo7N() throws Exception {
    final int N = 11;
    ExecutionJobVertex target = setUpExecutionGraphAndGetDownstreamVertex(N, 7 * N);
    for (ExecutionVertex ev : target.getTaskVertices()) {
        assertEquals(1, ev.getNumberOfInputs());
        ConsumedPartitionGroup consumedPartitionGroup = ev.getConsumedPartitionGroup(0);
        assertEquals(1, consumedPartitionGroup.size());
        assertEquals(ev.getParallelSubtaskIndex() / 7, consumedPartitionGroup.getFirst().getPartitionNumber());
    }
}
Also used : ConsumedPartitionGroup(org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup) Test(org.junit.Test)

Example 15 with ConsumedPartitionGroup

use of org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup in project flink by apache.

the class IntermediateResultPartitionTest method testBlockingPartitionConsumable.

@Test
public void testBlockingPartitionConsumable() throws Exception {
    IntermediateResult result = createResult(ResultPartitionType.BLOCKING, 2);
    IntermediateResultPartition partition1 = result.getPartitions()[0];
    IntermediateResultPartition partition2 = result.getPartitions()[1];
    ConsumedPartitionGroup consumedPartitionGroup = partition1.getConsumedPartitionGroups().get(0);
    // Not consumable on init
    assertFalse(partition1.isConsumable());
    assertFalse(partition2.isConsumable());
    assertFalse(consumedPartitionGroup.areAllPartitionsFinished());
    // Not consumable if only one partition is FINISHED
    partition1.markFinished();
    assertTrue(partition1.isConsumable());
    assertFalse(partition2.isConsumable());
    assertFalse(consumedPartitionGroup.areAllPartitionsFinished());
    // Consumable after all partitions are FINISHED
    partition2.markFinished();
    assertTrue(partition1.isConsumable());
    assertTrue(partition2.isConsumable());
    assertTrue(consumedPartitionGroup.areAllPartitionsFinished());
    // Not consumable if failover happens
    result.resetForNewExecution();
    assertFalse(partition1.isConsumable());
    assertFalse(partition2.isConsumable());
    assertFalse(consumedPartitionGroup.areAllPartitionsFinished());
}
Also used : ConsumedPartitionGroup(org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup) Test(org.junit.Test)

Aggregations

ConsumedPartitionGroup (org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup)30 IntermediateResultPartitionID (org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)15 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)9 ExecutionVertexID (org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID)6 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)4 SchedulingResultPartition (org.apache.flink.runtime.scheduler.strategy.SchedulingResultPartition)4 HashSet (java.util.HashSet)3 List (java.util.List)3 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)3 ConsumerVertexGroup (org.apache.flink.runtime.scheduler.strategy.ConsumerVertexGroup)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ExecutionState (org.apache.flink.runtime.execution.ExecutionState)2 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)2 IntermediateResultPartition (org.apache.flink.runtime.executiongraph.IntermediateResultPartition)2 ResultPartitionType (org.apache.flink.runtime.io.network.partition.ResultPartitionType)2 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)2