Search in sources :

Example 1 with ScheduleMode

use of org.apache.flink.runtime.jobgraph.ScheduleMode in project flink by apache.

the class ExecutionVertexDeploymentTest method testTddProducedPartitionsLazyScheduling.

/**
	 * Tests that the lazy scheduling flag is correctly forwarded to the produced partition descriptors.
	 */
@Test
public void testTddProducedPartitionsLazyScheduling() throws Exception {
    TestingUtils.QueuedActionExecutionContext context = TestingUtils.queuedActionExecutionContext();
    ExecutionJobVertex jobVertex = getExecutionVertex(new JobVertexID(), context);
    IntermediateResult result = new IntermediateResult(new IntermediateDataSetID(), jobVertex, 1, ResultPartitionType.PIPELINED);
    ExecutionVertex vertex = new ExecutionVertex(jobVertex, 0, new IntermediateResult[] { result }, Time.minutes(1));
    ExecutionEdge mockEdge = createMockExecutionEdge(1);
    result.getPartitions()[0].addConsumerGroup();
    result.getPartitions()[0].addConsumer(mockEdge, 0);
    AllocatedSlot allocatedSlot = mock(AllocatedSlot.class);
    when(allocatedSlot.getSlotAllocationId()).thenReturn(new AllocationID());
    Slot root = mock(Slot.class);
    when(root.getSlotNumber()).thenReturn(1);
    SimpleSlot slot = mock(SimpleSlot.class);
    when(slot.getRoot()).thenReturn(root);
    when(slot.getAllocatedSlot()).thenReturn(allocatedSlot);
    when(root.getAllocatedSlot()).thenReturn(allocatedSlot);
    for (ScheduleMode mode : ScheduleMode.values()) {
        vertex.getExecutionGraph().setScheduleMode(mode);
        TaskDeploymentDescriptor tdd = vertex.createDeploymentDescriptor(new ExecutionAttemptID(), slot, null, 1);
        Collection<ResultPartitionDeploymentDescriptor> producedPartitions = tdd.getProducedPartitions();
        assertEquals(1, producedPartitions.size());
        ResultPartitionDeploymentDescriptor desc = producedPartitions.iterator().next();
        assertEquals(mode.allowLazyDeployment(), desc.sendScheduleOrUpdateConsumersMessage());
    }
}
Also used : AllocatedSlot(org.apache.flink.runtime.jobmanager.slots.AllocatedSlot) ResultPartitionDeploymentDescriptor(org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) TestingUtils(org.apache.flink.runtime.testingUtils.TestingUtils) ScheduleMode(org.apache.flink.runtime.jobgraph.ScheduleMode) Slot(org.apache.flink.runtime.instance.Slot) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) AllocatedSlot(org.apache.flink.runtime.jobmanager.slots.AllocatedSlot) IntermediateDataSetID(org.apache.flink.runtime.jobgraph.IntermediateDataSetID) TaskDeploymentDescriptor(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor) Test(org.junit.Test)

Aggregations

AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)1 ResultPartitionDeploymentDescriptor (org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor)1 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)1 ExecutionGraphTestUtils.getExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex)1 SimpleSlot (org.apache.flink.runtime.instance.SimpleSlot)1 Slot (org.apache.flink.runtime.instance.Slot)1 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)1 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)1 ScheduleMode (org.apache.flink.runtime.jobgraph.ScheduleMode)1 AllocatedSlot (org.apache.flink.runtime.jobmanager.slots.AllocatedSlot)1 TestingUtils (org.apache.flink.runtime.testingUtils.TestingUtils)1 Test (org.junit.Test)1