ifndef-SleePy commented on a change in pull request #9072: [FLINK-11630] Wait 
for the termination of all running Tasks when shutting down TaskExecutor
URL: https://github.com/apache/flink/pull/9072#discussion_r313938884
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
 ##########
 @@ -1826,4 +1838,30 @@ public SlotReport retrievePayload(ResourceID 
resourceID) {
                        return taskSlotTable.createSlotReport(getResourceID());
                }
        }
+
+       private static class TaskCompletionTracker {
+               private final Map<ExecutionAttemptID, Task> incompleteTasks;
+
+               private TaskCompletionTracker() {
+                       incompleteTasks = new ConcurrentHashMap<>(8);
+               }
+
+               void trackTaskCompletion(Task task) {
+                       incompleteTasks.put(task.getExecutionId(), task);
+                       task.getTerminationFuture().thenRun(() -> 
incompleteTasks.remove(task.getExecutionId()));
 
 Review comment:
   This is also my concern. We already have 
`TaskExecutor#unregisterTaskAndNotifyFinalState` and 
`Task#getTerminationFuture`. I think we should unify them somehow.

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