XComp commented on code in PR #22384:
URL: https://github.com/apache/flink/pull/22384#discussion_r1203508182


##########
flink-runtime/src/test/java/org/apache/flink/runtime/leaderelection/TestingLeaderElection.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.leaderelection;
+
+import org.apache.flink.util.Preconditions;
+
+import javax.annotation.Nullable;
+
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * {@code TestingLeaderElection} implements simple leader election for test 
cases where no {@code
+ * LeaderElectionService} is required.
+ */
+public class TestingLeaderElection implements LeaderElection {
+
+    /**
+     * Is {@code null} if the {@code LeaderElection} isn't started.
+     *
+     * @see LeaderElection#startLeaderElection(LeaderContender)
+     */
+    @Nullable private LeaderContender contender = null;
+
+    @Nullable private CompletableFuture<LeaderInformation> confirmationFuture 
= null;

Review Comment:
   In addition to what I mentioned in [my previous 
comment](https://github.com/apache/flink/pull/22384#discussion_r1202637964): 
This is a slight code change (comparing it to the old 
`TestingLeaderElectionService` where we didn't cancel the `confirmationFuture` 
in `TestingLeaderElectionService.stop()`. Now, we do cancel the future. But 
this change makes sense for the aformentioned reasons. I'm going to add a 
comment to document that as well



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

Reply via email to