zhuzhurk commented on code in PR #24524:
URL: https://github.com/apache/flink/pull/24524#discussion_r1533349277


##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AdaptiveBatchScheduler.java:
##########
@@ -183,21 +193,59 @@ public AdaptiveBatchScheduler(
         this.hybridPartitionDataConsumeConstraint = 
hybridPartitionDataConsumeConstraint;
 
         this.sourceParallelismFuturesByJobVertexId = new HashMap<>();
+
+        // 
============================================================================
+        //  Speculative execution handler
+        // 
============================================================================

Review Comment:
   I would avoid the `// =============` comments.
   It's also better to introduce a `createSpeculativeExecutionHandler` method.



##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/DefaultSpeculativeExecutionHandler.java:
##########
@@ -7,62 +7,37 @@
  * "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
+ *     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.
+ * 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.

Review Comment:
   Is the change to the license format expected?



##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AdaptiveBatchScheduler.java:
##########
@@ -183,21 +193,59 @@ public AdaptiveBatchScheduler(
         this.hybridPartitionDataConsumeConstraint = 
hybridPartitionDataConsumeConstraint;
 
         this.sourceParallelismFuturesByJobVertexId = new HashMap<>();
+
+        // 
============================================================================
+        //  Speculative execution handler
+        // 
============================================================================
+        if 
(jobMasterConfiguration.get(BatchExecutionOptions.SPECULATIVE_ENABLED)) {
+            speculativeExecutionHandler =
+                    new DefaultSpeculativeExecutionHandler(
+                            jobMasterConfiguration.get(
+                                    
BatchExecutionOptions.SPECULATIVE_MAX_CONCURRENT_EXECUTIONS),
+                            jobMasterConfiguration.get(
+                                    
BatchExecutionOptions.BLOCK_SLOW_NODE_DURATION),
+                            blocklistOperations,
+                            new 
ExecutionTimeBasedSlowTaskDetector(jobMasterConfiguration),
+                            new SimpleCounter(),
+                            this::getExecutionVertex,
+                            () -> 
getExecutionGraph().getRegisteredExecutions(),
+                            (newSpeculativeExecutions, verticesToDeploy) ->
+                                    executionDeployer.allocateSlotsAndDeploy(
+                                            newSpeculativeExecutions,
+                                            
executionVertexVersioner.getExecutionVertexVersions(
+                                                    verticesToDeploy)),
+                            log);
+        } else {
+            speculativeExecutionHandler = new 
DummySpeculativeExecutionHandler();
+        }
     }
 
     @Override
     protected void startSchedulingInternal() {
+        speculativeExecutionHandler.registerMetrics(jobManagerJobMetricGroup);
+
         tryComputeSourceParallelismThenRunAsync(
                 (Void value, Throwable throwable) -> {
                     if (getExecutionGraph().getState() == JobStatus.CREATED) {
                         initializeVerticesIfPossible();
                         super.startSchedulingInternal();
                     }
                 });
+
+        speculativeExecutionHandler.startSlowTaskDetector(

Review Comment:
   I think we can merge the two methods `startSlowTaskDetector` and 
`registerMetrics` to one method `speculativeExecutionHandler.init()` .



##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AdaptiveBatchScheduler.java:
##########
@@ -183,21 +193,59 @@ public AdaptiveBatchScheduler(
         this.hybridPartitionDataConsumeConstraint = 
hybridPartitionDataConsumeConstraint;
 
         this.sourceParallelismFuturesByJobVertexId = new HashMap<>();
+
+        // 
============================================================================
+        //  Speculative execution handler
+        // 
============================================================================
+        if 
(jobMasterConfiguration.get(BatchExecutionOptions.SPECULATIVE_ENABLED)) {
+            speculativeExecutionHandler =
+                    new DefaultSpeculativeExecutionHandler(
+                            jobMasterConfiguration.get(

Review Comment:
   Maybe directly pass in `jobMasterConfiguration` to simplify the params?



##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptivebatch/AdaptiveBatchScheduler.java:
##########
@@ -183,21 +193,59 @@ public AdaptiveBatchScheduler(
         this.hybridPartitionDataConsumeConstraint = 
hybridPartitionDataConsumeConstraint;
 
         this.sourceParallelismFuturesByJobVertexId = new HashMap<>();
+
+        // 
============================================================================
+        //  Speculative execution handler
+        // 
============================================================================
+        if 
(jobMasterConfiguration.get(BatchExecutionOptions.SPECULATIVE_ENABLED)) {
+            speculativeExecutionHandler =
+                    new DefaultSpeculativeExecutionHandler(
+                            jobMasterConfiguration.get(
+                                    
BatchExecutionOptions.SPECULATIVE_MAX_CONCURRENT_EXECUTIONS),
+                            jobMasterConfiguration.get(
+                                    
BatchExecutionOptions.BLOCK_SLOW_NODE_DURATION),
+                            blocklistOperations,
+                            new 
ExecutionTimeBasedSlowTaskDetector(jobMasterConfiguration),
+                            new SimpleCounter(),

Review Comment:
   I think there is no need to take this counter as a param.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to