Search in sources :

Example 1 with LogicalVertex

use of org.apache.flink.runtime.jobgraph.topology.LogicalVertex in project flink by apache.

the class DefaultExecutionTopology method computeLogicalPipelinedRegionsByJobVertexId.

private static Map<JobVertexID, DefaultLogicalPipelinedRegion> computeLogicalPipelinedRegionsByJobVertexId(final ExecutionGraph executionGraph) {
    List<JobVertex> topologicallySortedJobVertices = IterableUtils.toStream(executionGraph.getVerticesTopologically()).map(ExecutionJobVertex::getJobVertex).collect(Collectors.toList());
    Iterable<DefaultLogicalPipelinedRegion> logicalPipelinedRegions = DefaultLogicalTopology.fromTopologicallySortedJobVertices(topologicallySortedJobVertices).getAllPipelinedRegions();
    Map<JobVertexID, DefaultLogicalPipelinedRegion> logicalPipelinedRegionsByJobVertexId = new HashMap<>();
    for (DefaultLogicalPipelinedRegion logicalPipelinedRegion : logicalPipelinedRegions) {
        for (LogicalVertex vertex : logicalPipelinedRegion.getVertices()) {
            logicalPipelinedRegionsByJobVertexId.put(vertex.getId(), logicalPipelinedRegion);
        }
    }
    return logicalPipelinedRegionsByJobVertexId;
}
Also used : LogicalVertex(org.apache.flink.runtime.jobgraph.topology.LogicalVertex) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) ExecutionJobVertex(org.apache.flink.runtime.executiongraph.ExecutionJobVertex) HashMap(java.util.HashMap) IdentityHashMap(java.util.IdentityHashMap) DefaultLogicalPipelinedRegion(org.apache.flink.runtime.jobgraph.topology.DefaultLogicalPipelinedRegion) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID)

Example 2 with LogicalVertex

use of org.apache.flink.runtime.jobgraph.topology.LogicalVertex in project flink by apache.

the class StreamingJobGraphGenerator method buildVertexRegionSlotSharingGroups.

/**
 * Maps a vertex to its region slot sharing group. If {@link
 * StreamGraph#isAllVerticesInSameSlotSharingGroupByDefault()} returns true, all regions will be
 * in the same slot sharing group.
 */
private Map<JobVertexID, SlotSharingGroup> buildVertexRegionSlotSharingGroups() {
    final Map<JobVertexID, SlotSharingGroup> vertexRegionSlotSharingGroups = new HashMap<>();
    final SlotSharingGroup defaultSlotSharingGroup = new SlotSharingGroup();
    streamGraph.getSlotSharingGroupResource(StreamGraphGenerator.DEFAULT_SLOT_SHARING_GROUP).ifPresent(defaultSlotSharingGroup::setResourceProfile);
    final boolean allRegionsInSameSlotSharingGroup = streamGraph.isAllVerticesInSameSlotSharingGroupByDefault();
    final Iterable<DefaultLogicalPipelinedRegion> regions = DefaultLogicalTopology.fromJobGraph(jobGraph).getAllPipelinedRegions();
    for (DefaultLogicalPipelinedRegion region : regions) {
        final SlotSharingGroup regionSlotSharingGroup;
        if (allRegionsInSameSlotSharingGroup) {
            regionSlotSharingGroup = defaultSlotSharingGroup;
        } else {
            regionSlotSharingGroup = new SlotSharingGroup();
            streamGraph.getSlotSharingGroupResource(StreamGraphGenerator.DEFAULT_SLOT_SHARING_GROUP).ifPresent(regionSlotSharingGroup::setResourceProfile);
        }
        for (LogicalVertex vertex : region.getVertices()) {
            vertexRegionSlotSharingGroups.put(vertex.getId(), regionSlotSharingGroup);
        }
    }
    return vertexRegionSlotSharingGroups;
}
Also used : LogicalVertex(org.apache.flink.runtime.jobgraph.topology.LogicalVertex) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) DefaultLogicalPipelinedRegion(org.apache.flink.runtime.jobgraph.topology.DefaultLogicalPipelinedRegion) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) SlotSharingGroup(org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup)

Aggregations

HashMap (java.util.HashMap)2 IdentityHashMap (java.util.IdentityHashMap)2 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)2 DefaultLogicalPipelinedRegion (org.apache.flink.runtime.jobgraph.topology.DefaultLogicalPipelinedRegion)2 LogicalVertex (org.apache.flink.runtime.jobgraph.topology.LogicalVertex)2 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)1 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)1 SlotSharingGroup (org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup)1