zhuzhurk commented on a change in pull request #18407:
URL: https://github.com/apache/flink/pull/18407#discussion_r790286777



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/DefaultOperatorCoordinatorHandler.java
##########
@@ -151,4 +161,28 @@ public void deliverOperatorEventToCoordinator(
                     "Coordinator of operator " + operator + " cannot handle 
client event");
         }
     }
+
+    @Override
+    public void registerAndStartNewCoordinators(
+            Collection<OperatorCoordinatorHolder> coordinators,
+            ComponentMainThreadExecutor mainThreadExecutor) {
+
+        for (OperatorCoordinatorHolder coordinator : coordinators) {
+            coordinatorMap.put(coordinator.operatorId(), coordinator);
+            coordinator.lazyInitialize(globalFailureHandler, 
mainThreadExecutor);
+
+            try {
+                coordinator.start();
+            } catch (Throwable t) {
+                ExceptionUtils.rethrowIfFatalErrorOrOOM(t);
+                IOUtils.closeQuietly(coordinator);
+                throw new FlinkRuntimeException("Failed to start operator 
coordinator", t);

Review comment:
       maybe introduce a method `startOperatorCoordinator(coordinator)` and 
also rework `startAllOperatorCoordinators` to use it.

##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/DefaultOperatorCoordinatorHandler.java
##########
@@ -62,11 +63,17 @@ public DefaultOperatorCoordinatorHandler(
     private static Map<OperatorID, OperatorCoordinatorHolder> 
createCoordinatorMap(
             ExecutionGraph executionGraph) {
         Map<OperatorID, OperatorCoordinatorHolder> coordinatorMap = new 
HashMap<>();
-        for (ExecutionJobVertex vertex : 
executionGraph.getAllVertices().values()) {
-            for (OperatorCoordinatorHolder holder : 
vertex.getOperatorCoordinators()) {
-                coordinatorMap.put(holder.operatorId(), holder);
-            }
-        }
+
+        executionGraph.getAllVertices().values().stream()
+                .filter(ExecutionJobVertex::isInitialized)
+                .forEach(
+                        jobVertex -> {
+                            for (OperatorCoordinatorHolder holder :
+                                    jobVertex.getOperatorCoordinators()) {
+                                coordinatorMap.put(holder.operatorId(), 
holder);
+                            }
+                        });
+
         return coordinatorMap;

Review comment:
       maybe 
   
   ```
           return executionGraph.getAllVertices().values().stream()
                   .filter(ExecutionJobVertex::isInitialized)
                   .flatMap(v -> v.getOperatorCoordinators().stream())
                   .collect(
                           Collectors.toMap(
                                   OperatorCoordinatorHolder::operatorId, 
Function.identity()));
   ```




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