JunRuiLee commented on code in PR #26489: URL: https://github.com/apache/flink/pull/26489#discussion_r2052653921
########## flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/Dispatcher.java: ########## @@ -1093,13 +1093,25 @@ public CompletableFuture<String> stopWithSavepointAndGetLocation( @Override public CompletableFuture<Acknowledge> shutDownCluster() { - return shutDownCluster(ApplicationStatus.SUCCEEDED); + return internalShutDownCluster(ApplicationStatus.SUCCEEDED, false); } @Override public CompletableFuture<Acknowledge> shutDownCluster( final ApplicationStatus applicationStatus) { - shutDownFuture.complete(applicationStatus); + return internalShutDownCluster(applicationStatus, true); + } + + private CompletableFuture<Acknowledge> internalShutDownCluster( + final ApplicationStatus applicationStatus, + final boolean waitForAllJobTerminationFutures) { + final CompletableFuture<Void> allJobsTerminationFuture = + waitForAllJobTerminationFutures + ? FutureUtils.completeAll(jobManagerRunnerTerminationFutures.values()) + : CompletableFuture.completedFuture(null); + + FutureUtils.runAfterwards( + allJobsTerminationFuture, () -> shutDownFuture.complete(applicationStatus)); return CompletableFuture.completedFuture(Acknowledge.get()); Review Comment: minor question: Why this future directly return as a completed future instead of wait for the completion of allJobsTerminationFuture? -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org