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_r335093669
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/runner/StoppedDispatcherLeaderProcess.java
 ##########
 @@ -0,0 +1,68 @@
+/*
+ * 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.runtime.clusterframework.ApplicationStatus;
+import org.apache.flink.runtime.dispatcher.DispatcherGateway;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * {@link DispatcherLeaderProcess} implementation which is stopped. This class
+ * is useful as the initial state of the {@link DefaultDispatcherRunner}.
+ */
+public enum StoppedDispatcherLeaderProcess implements DispatcherLeaderProcess {
+       INSTANCE;
+
+       private static final CompletableFuture<Void> TERMINATION_FUTURE = 
CompletableFuture.completedFuture(null);
+       private static final UUID LEADER_SESSION_ID = new UUID(0L, 0L);
+       private static final CompletableFuture<String> 
NEVER_COMPLETED_LEADER_SESSION_FUTURE = new CompletableFuture<>();
+       private static final CompletableFuture<ApplicationStatus> 
NEVER_COMPLETED_SHUTDOWN_FUTURE = new CompletableFuture<>();
+
+       @Override
+       public void start() {
+
+       }
+
+       @Override
+       public UUID getLeaderSessionId() {
+               return LEADER_SESSION_ID;
+       }
+
+       @Override
+       public CompletableFuture<DispatcherGateway> getDispatcherGateway() {
+               return null;
+       }
+
+       @Override
+       public CompletableFuture<String> getConfirmLeaderSessionFuture() {
+               return NEVER_COMPLETED_LEADER_SESSION_FUTURE;
 
 Review comment:
   > Should this method be changed to throw `IllegalStateException`? Afaik 
`getConfirmLeaderSessionFuture()` shouldn't be called on 
`StoppedDispatcherLeaderProcess`
   
   Ok, I might be wrong about this one.

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