use of org.apache.flink.runtime.executiongraph.failover.flip1.SchedulingPipelinedRegionComputeUtil in project flink by apache.
the class DefaultExecutionTopology method generateNewPipelinedRegions.
private void generateNewPipelinedRegions(Iterable<ExecutionVertex> newExecutionVertices) {
final Iterable<DefaultExecutionVertex> newSchedulingExecutionVertices = IterableUtils.toStream(newExecutionVertices).map(ExecutionVertex::getID).map(executionVerticesById::get).collect(Collectors.toList());
Map<DefaultLogicalPipelinedRegion, List<DefaultExecutionVertex>> sortedExecutionVerticesInPipelinedRegion = new IdentityHashMap<>();
for (DefaultExecutionVertex schedulingVertex : newSchedulingExecutionVertices) {
sortedExecutionVerticesInPipelinedRegion.computeIfAbsent(logicalPipelinedRegionsByJobVertexId.get(schedulingVertex.getId().getJobVertexId()), ignore -> new ArrayList<>()).add(schedulingVertex);
}
long buildRegionsStartTime = System.nanoTime();
Set<Set<SchedulingExecutionVertex>> rawPipelinedRegions = Collections.newSetFromMap(new IdentityHashMap<>());
// SchedulingPipelinedRegions are both connected with inter-region blocking edges.
for (Map.Entry<DefaultLogicalPipelinedRegion, List<DefaultExecutionVertex>> entry : sortedExecutionVerticesInPipelinedRegion.entrySet()) {
DefaultLogicalPipelinedRegion logicalPipelinedRegion = entry.getKey();
List<DefaultExecutionVertex> schedulingExecutionVertices = entry.getValue();
if (containsIntraRegionAllToAllEdge(logicalPipelinedRegion)) {
// For edges inside one LogicalPipelinedRegion, if there is any all-to-all edge, it
// could be under two circumstances:
//
// 1. Pipelined all-to-all edge:
// Pipelined all-to-all edge will connect all vertices pipelined. Therefore,
// all execution vertices derived from this LogicalPipelinedRegion should be in one
// SchedulingPipelinedRegion.
//
// 2. Blocking all-to-all edge:
// For intra-region blocking all-to-all edge, we must make sure all the vertices
// are inside one SchedulingPipelinedRegion, so that there will be no deadlock
// happens during scheduling. For more details about this case, please refer to
// FLINK-17330 (https://issues.apache.org/jira/browse/FLINK-17330).
//
// Therefore, if a LogicalPipelinedRegion contains any intra-region all-to-all
// edge, we just convert the entire LogicalPipelinedRegion to a sole
// SchedulingPipelinedRegion directly.
rawPipelinedRegions.add(new HashSet<>(schedulingExecutionVertices));
} else {
// If there are only pointwise edges inside the LogicalPipelinedRegion, we can use
// SchedulingPipelinedRegionComputeUtil to compute the regions with O(N) computation
// complexity.
rawPipelinedRegions.addAll(SchedulingPipelinedRegionComputeUtil.computePipelinedRegions(schedulingExecutionVertices, executionVerticesById::get, resultPartitionsById::get));
}
}
for (Set<? extends SchedulingExecutionVertex> rawPipelinedRegion : rawPipelinedRegions) {
// noinspection unchecked
final DefaultSchedulingPipelinedRegion pipelinedRegion = new DefaultSchedulingPipelinedRegion((Set<DefaultExecutionVertex>) rawPipelinedRegion, resultPartitionsById::get);
pipelinedRegions.add(pipelinedRegion);
for (SchedulingExecutionVertex executionVertex : rawPipelinedRegion) {
pipelinedRegionsByVertex.put(executionVertex.getId(), pipelinedRegion);
}
}
long buildRegionsDuration = (System.nanoTime() - buildRegionsStartTime) / 1_000_000;
LOG.info("Built {} new pipelined regions in {} ms, total {} pipelined regions currently.", rawPipelinedRegions.size(), buildRegionsDuration, pipelinedRegions.size());
}
Aggregations