dmvk commented on a change in pull request #18189:
URL: https://github.com/apache/flink/pull/18189#discussion_r780341370
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/runner/SessionDispatcherLeaderProcess.java
##########
@@ -92,34 +99,61 @@ private void startServices() {
}
}
- private void createDispatcherIfRunning(Collection<JobGraph> jobGraphs) {
- runIfStateIs(State.RUNNING, () -> createDispatcher(jobGraphs));
+ private void createDispatcherIfRunning(
+ Collection<JobGraph> jobGraphs, Collection<JobResult>
globallyTerminatedJobs) {
+ runIfStateIs(State.RUNNING, () -> createDispatcher(jobGraphs,
globallyTerminatedJobs));
}
- private void createDispatcher(Collection<JobGraph> jobGraphs) {
+ private void createDispatcher(
+ Collection<JobGraph> jobGraphs, Collection<JobResult>
globallyTerminatedJobs) {
final DispatcherGatewayService dispatcherService =
dispatcherGatewayServiceFactory.create(
- DispatcherId.fromUuid(getLeaderSessionId()),
jobGraphs, jobGraphStore);
+ DispatcherId.fromUuid(getLeaderSessionId()),
+ jobGraphs,
+ globallyTerminatedJobs,
+ jobGraphStore,
+ jobResultStore);
completeDispatcherSetup(dispatcherService);
}
- private CompletableFuture<Collection<JobGraph>> recoverJobsAsync() {
- return CompletableFuture.supplyAsync(this::recoverJobsIfRunning,
ioExecutor);
+ private CompletableFuture<Void>
+
createDispatcherBasedOnRecoveredJobGraphsAndGloballyTerminatedJobs() {
+ return CompletableFuture.supplyAsync(
+ this::getGloballyCompletedJobResultsIfRunning,
ioExecutor)
+ .thenCompose(
+ globallyTerminatedJobs ->
+ CompletableFuture.supplyAsync(
+ () ->
+
this.recoverJobsIfRunning(
+
globallyTerminatedJobs.stream()
+
.map(JobResult::getJobId)
+
.collect(
+
Collectors
+
.toSet())),
+ ioExecutor)
+ .thenAccept(
+ jobGraphs ->
+
createDispatcherIfRunning(
+ jobGraphs,
globallyTerminatedJobs))
+ .handle(this::onErrorIfRunning));
Review comment:
I've tried to reply via email, but it doesn't seem to have arrived :/
It would be executed in the same thread that has called the complete method
(which belongs to the pool). Passing the executor directly allows another
thread from the pool to execute the callback. Also the control mechanism is
kind of more explicit as you can never be sure that the "complete" method has
been called by the thread from previous stage.
--
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]