tillrohrmann commented on a change in pull request #17485: URL: https://github.com/apache/flink/pull/17485#discussion_r791053696
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/leaderelection/DefaultMultipleComponentLeaderElectionService.java ########## @@ -0,0 +1,285 @@ +/* + * 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.annotation.VisibleForTesting; +import org.apache.flink.runtime.rpc.FatalErrorHandler; +import org.apache.flink.util.ExceptionUtils; +import org.apache.flink.util.ExecutorUtils; +import org.apache.flink.util.FlinkException; +import org.apache.flink.util.Preconditions; +import org.apache.flink.util.concurrent.ExecutorThreadFactory; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nullable; +import javax.annotation.concurrent.GuardedBy; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +/** + * Default implementation of a {@link MultipleComponentLeaderElectionService} that allows to + * register multiple {@link LeaderElectionEventHandler}. + */ +public class DefaultMultipleComponentLeaderElectionService + implements MultipleComponentLeaderElectionService, + MultipleComponentLeaderElectionDriver.Listener { + private static final Logger LOG = + LoggerFactory.getLogger(DefaultMultipleComponentLeaderElectionService.class); + + private final Object lock = new Object(); + + private final MultipleComponentLeaderElectionDriver multipleComponentLeaderElectionDriver; + + private final FatalErrorHandler fatalErrorHandler; + + @GuardedBy("lock") + private final ExecutorService leadershipOperationExecutor; + + @GuardedBy("lock") + private final Map<String, LeaderElectionEventHandler> leaderElectionEventHandlers; + + private boolean running = true; Review comment: Good catch. Will change it. -- 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