zhuzhurk commented on a change in pull request #8851: [FLINK-12876] [runtime] 
Add an adapter of region failover NG for legacy scheduler
URL: https://github.com/apache/flink/pull/8851#discussion_r296989612
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/failover/AdaptedSchedulingUtils.java
 ##########
 @@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.executiongraph.failover;
+
+import org.apache.flink.runtime.clusterframework.types.AllocationID;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.executiongraph.Execution;
+import org.apache.flink.runtime.executiongraph.ExecutionGraph;
+import org.apache.flink.runtime.executiongraph.ExecutionVertex;
+import 
org.apache.flink.runtime.jobmanager.scheduler.LocationPreferenceConstraint;
+import 
org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.FlinkException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * This class contains scheduling logic similar to that in ExecutionGraph.
+ * It is used by legacy failover strategy as the strategy will do the 
re-scheduling work by itself.
+ * We extract it from ExecutionGraph to avoid affect existing scheduling logic.
+ */
+public class AdaptedSchedulingUtils {
+
+       static CompletableFuture<Void> scheduleLazy(
+               final Set<ExecutionVertex> vertices,
+               final ExecutionGraph executionGraph) {
+
+               final Set<AllocationID> previousAllocations = 
getAllPriorAllocationIds(vertices);
+
+               final ArrayList<CompletableFuture<Void>> schedulingFutures = 
new ArrayList<>(vertices.size());
+               for (ExecutionVertex executionVertex : vertices) {
 
 Review comment:
   Theoretically, it should not cause any issue as these vertices are scheduled 
individually. And only vertex satisfying the input constraint will be 
scheduled. 
   
   In implementation, however, there is a bit higher chance that downstream 
task get launched earlier than its source tasks, and causes a resource 
deadlock. But even doing it topologically does not prevent this to happen. 
   To avoid resource deadlock, users need to set `InputDependencyConstraint` to 
be ALL. In this case, any schedule order should be OK.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to