GJL commented on a change in pull request #9832: [FLINK-11843] Bind lifespan of 
Dispatcher to leader session
URL: https://github.com/apache/flink/pull/9832#discussion_r335019283
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/runner/AbstractDispatcherLeaderProcess.java
 ##########
 @@ -0,0 +1,244 @@
+/*
+ * 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.runner;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.clusterframework.ApplicationStatus;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.dispatcher.DispatcherGateway;
+import org.apache.flink.runtime.dispatcher.DispatcherId;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.runtime.jobmanager.JobGraphWriter;
+import org.apache.flink.runtime.rpc.FatalErrorHandler;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
+import org.apache.flink.util.AutoCloseableAsync;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nullable;
+
+import java.util.Collection;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+abstract class AbstractDispatcherLeaderProcess implements 
DispatcherLeaderProcess {
+
+       protected final Logger log = LoggerFactory.getLogger(getClass());
+
+       private final Object lock = new Object();
+
+       private final UUID leaderSessionId;
+
+       private final FatalErrorHandler fatalErrorHandler;
+
+       private final CompletableFuture<DispatcherGateway> 
dispatcherGatewayFuture;
+
+       private final CompletableFuture<String> confirmLeaderSessionFuture;
+
+       private final CompletableFuture<Void> terminationFuture;
+
+       private final CompletableFuture<ApplicationStatus> shutDownFuture;
+
+       private State state;
+
+       @Nullable
+       private DispatcherService dispatcherService;
+
+       AbstractDispatcherLeaderProcess(UUID leaderSessionId, FatalErrorHandler 
fatalErrorHandler) {
+               this.leaderSessionId = leaderSessionId;
+               this.fatalErrorHandler = fatalErrorHandler;
+
+               this.dispatcherGatewayFuture = new CompletableFuture<>();
+               this.confirmLeaderSessionFuture = 
dispatcherGatewayFuture.thenApply(RestfulGateway::getAddress);
+               this.terminationFuture = new CompletableFuture<>();
+               this.shutDownFuture = new CompletableFuture<>();
+
+               this.state = State.CREATED;
+               this.dispatcherService = null;
 
 Review comment:
   nit: this assignment is not needed, default value is already null

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to