Search in sources :

Example 1 with ExecutionVertexDeploymentOption

use of org.apache.flink.runtime.scheduler.ExecutionVertexDeploymentOption in project flink by apache.

the class SchedulingStrategyUtils method createExecutionVertexDeploymentOptions.

static List<ExecutionVertexDeploymentOption> createExecutionVertexDeploymentOptions(final Collection<ExecutionVertexID> verticesToDeploy, final Function<ExecutionVertexID, DeploymentOption> deploymentOptionRetriever) {
    final List<ExecutionVertexDeploymentOption> deploymentOptions = new ArrayList<>(verticesToDeploy.size());
    for (ExecutionVertexID executionVertexId : verticesToDeploy) {
        final ExecutionVertexDeploymentOption deploymentOption = new ExecutionVertexDeploymentOption(executionVertexId, deploymentOptionRetriever.apply(executionVertexId));
        deploymentOptions.add(deploymentOption);
    }
    return deploymentOptions;
}
Also used : ArrayList(java.util.ArrayList) ExecutionVertexDeploymentOption(org.apache.flink.runtime.scheduler.ExecutionVertexDeploymentOption)

Example 2 with ExecutionVertexDeploymentOption

use of org.apache.flink.runtime.scheduler.ExecutionVertexDeploymentOption in project flink by apache.

the class PipelinedRegionSchedulingStrategyTest method testSchedulingTopologyWithCrossRegionConsumedPartitionGroups.

@Test
public void testSchedulingTopologyWithCrossRegionConsumedPartitionGroups() throws Exception {
    final JobVertex v1 = createJobVertex("v1", 4);
    final JobVertex v2 = createJobVertex("v2", 3);
    final JobVertex v3 = createJobVertex("v3", 2);
    v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
    v3.connectNewDataSetAsInput(v2, DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING);
    v3.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
    final List<JobVertex> ordered = new ArrayList<>(Arrays.asList(v1, v2, v3));
    final JobGraph jobGraph = JobGraphBuilder.newBatchJobGraphBuilder().addJobVertices(ordered).build();
    final ExecutionGraph executionGraph = TestingDefaultExecutionGraphBuilder.newBuilder().setJobGraph(jobGraph).build();
    final SchedulingTopology schedulingTopology = executionGraph.getSchedulingTopology();
    // Test whether the topology is built correctly
    final List<SchedulingPipelinedRegion> regions = new ArrayList<>();
    schedulingTopology.getAllPipelinedRegions().forEach(regions::add);
    assertEquals(2, regions.size());
    final ExecutionVertex v31 = executionGraph.getJobVertex(v3.getID()).getTaskVertices()[0];
    final Set<ExecutionVertexID> region1 = new HashSet<>();
    schedulingTopology.getPipelinedRegionOfVertex(v31.getID()).getVertices().forEach(vertex -> region1.add(vertex.getId()));
    assertEquals(5, region1.size());
    final ExecutionVertex v32 = executionGraph.getJobVertex(v3.getID()).getTaskVertices()[1];
    final Set<ExecutionVertexID> region2 = new HashSet<>();
    schedulingTopology.getPipelinedRegionOfVertex(v32.getID()).getVertices().forEach(vertex -> region2.add(vertex.getId()));
    assertEquals(4, region2.size());
    // Test whether region 1 is scheduled correctly
    PipelinedRegionSchedulingStrategy schedulingStrategy = startScheduling(schedulingTopology);
    assertEquals(1, testingSchedulerOperation.getScheduledVertices().size());
    final List<ExecutionVertexDeploymentOption> deploymentOptions1 = testingSchedulerOperation.getScheduledVertices().get(0);
    assertEquals(5, deploymentOptions1.size());
    for (ExecutionVertexDeploymentOption deploymentOption : deploymentOptions1) {
        assertTrue(region1.contains(deploymentOption.getExecutionVertexId()));
    }
    // Test whether the region 2 is scheduled correctly when region 1 is finished
    final ExecutionVertex v22 = executionGraph.getJobVertex(v2.getID()).getTaskVertices()[1];
    v22.finishAllBlockingPartitions();
    schedulingStrategy.onExecutionStateChange(v22.getID(), ExecutionState.FINISHED);
    assertEquals(2, testingSchedulerOperation.getScheduledVertices().size());
    final List<ExecutionVertexDeploymentOption> deploymentOptions2 = testingSchedulerOperation.getScheduledVertices().get(1);
    assertEquals(4, deploymentOptions2.size());
    for (ExecutionVertexDeploymentOption deploymentOption : deploymentOptions2) {
        assertTrue(region2.contains(deploymentOption.getExecutionVertexId()));
    }
}
Also used : ArrayList(java.util.ArrayList) ExecutionVertexDeploymentOption(org.apache.flink.runtime.scheduler.ExecutionVertexDeploymentOption) ExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionVertex) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ExecutionGraph(org.apache.flink.runtime.executiongraph.ExecutionGraph) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 ExecutionVertexDeploymentOption (org.apache.flink.runtime.scheduler.ExecutionVertexDeploymentOption)2 HashSet (java.util.HashSet)1 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)1 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)1 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)1 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)1 Test (org.junit.Test)1