rmetzger commented on a change in pull request #13424:
URL: https://github.com/apache/flink/pull/13424#discussion_r493255184



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/InitializingJobManagerRunner.java
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "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
+ *
+ * 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.
+ */
+
+package org.apache.flink.runtime.dispatcher;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.client.JobInitializationException;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.jobmaster.JobManagerRunner;
+import org.apache.flink.runtime.messages.Acknowledge;
+import org.apache.flink.runtime.rpc.RpcUtils;
+import org.apache.flink.util.function.SupplierWithException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.concurrent.GuardedBy;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Wrapper for an initializing JobManagerRunner.
+ */
+public class InitializingJobManagerRunner {
+       private final Logger log = 
LoggerFactory.getLogger(InitializingJobManagerRunner.class);
+
+       private final CompletableFuture<JobManagerRunner> 
jobManagerRunnerFuture = new CompletableFuture<>();
+
+       private final Thread initializationRunner;
+
+       private final Object lock = new Object();
+
+       @GuardedBy("lock")
+       private CompletableFuture<Acknowledge> cancellationFuture;
+
+       public 
InitializingJobManagerRunner(SupplierWithException<JobManagerRunner, 
JobInitializationException> initializationRunnable, JobID jobID) {
+               String threadName = "jobmanager-initialization-" + jobID;
+               this.initializationRunner = new Thread(() -> {

Review comment:
       You are right. I assumed Futures are never really cancellable, because 
`CompletableFuture.cancel()` has the following javadoc:
   ```
        * @param mayInterruptIfRunning this value has no effect in this
        * implementation because interrupts are not used to control
        * processing.
   ```
   
   I will use the ioExecutor of the Dispatcher.




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


Reply via email to