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

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/SchedulingUtils.java
 ##########
 @@ -0,0 +1,218 @@
+/*
+ * 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;
+
+import org.apache.flink.runtime.clusterframework.types.AllocationID;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.concurrent.FutureUtils.ConjunctFuture;
+import org.apache.flink.runtime.jobgraph.JobStatus;
+import 
org.apache.flink.runtime.jobmanager.scheduler.LocationPreferenceConstraint;
+import 
org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException;
+import org.apache.flink.runtime.jobmaster.slotpool.Scheduler;
+import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider;
+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;
+
+import static org.apache.flink.util.Preconditions.checkState;
+
+/**
+ * This class contains scheduling logic for EAGER and LAZY_FROM_SOURCES.
+ * It is used for normal scheduling and legacy failover strategy re-scheduling.
+ */
+public class SchedulingUtils {
+
+       /**
+        * Schedule vertices lazy. That means only vertices satisfying its 
input constraint will be scheduled.
+        *
+        * @param vertices Topologically sorted vertices to schedule.
+        * @param executionGraph The graph the given vertices belongs to.
+        */
+       public static CompletableFuture<Void> scheduleLazy(
+                       final Iterable<ExecutionVertex> vertices,
+                       final ExecutionGraph executionGraph) {
+
+               executionGraph.assertRunningInJobMasterMainThread();
+
+               final Set<AllocationID> previousAllocations = 
computePriorAllocationIdsIfRequiredByScheduling(
+                       vertices, executionGraph.getSlotProvider());
+
+               final ArrayList<CompletableFuture<Void>> schedulingFutures = 
new ArrayList<>();
+               for (ExecutionVertex executionVertex : vertices) {
+                       // only schedule vertex when its input constraint is 
satisfied
+                       if 
(executionVertex.getJobVertex().getJobVertex().isInputVertex() ||
+                               
executionVertex.checkInputDependencyConstraints()) {
 
 Review comment:
   current `executionVertex.checkInputDependencyConstraints` does not proper 
deal with the input vertex case. If the constraint is ANY and the vertex has no 
input, it will return false.
   Maybe we can fix the `checkInputDependencyConstraints` and simplify the 
check here?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to