wangyang0918 commented on a change in pull request #13644: URL: https://github.com/apache/flink/pull/13644#discussion_r508989034
########## File path: flink-kubernetes/src/main/java/org/apache/flink/kubernetes/highavailability/KubernetesHaServices.java ########## @@ -0,0 +1,137 @@ +/* + * 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.kubernetes.highavailability; + +import org.apache.flink.api.common.JobID; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.kubernetes.configuration.KubernetesConfigOptions; +import org.apache.flink.kubernetes.kubeclient.FlinkKubeClient; +import org.apache.flink.kubernetes.kubeclient.KubernetesLeaderElectionConfiguration; +import org.apache.flink.kubernetes.utils.KubernetesUtils; +import org.apache.flink.runtime.blob.BlobStoreService; +import org.apache.flink.runtime.checkpoint.CheckpointRecoveryFactory; +import org.apache.flink.runtime.checkpoint.StandaloneCheckpointRecoveryFactory; +import org.apache.flink.runtime.highavailability.AbstractHaServices; +import org.apache.flink.runtime.highavailability.RunningJobsRegistry; +import org.apache.flink.runtime.highavailability.nonha.standalone.StandaloneRunningJobsRegistry; +import org.apache.flink.runtime.jobmanager.JobGraphStore; +import org.apache.flink.runtime.jobmanager.StandaloneJobGraphStore; +import org.apache.flink.runtime.leaderelection.LeaderElectionService; +import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService; + +import java.util.concurrent.Executor; + +import static org.apache.flink.kubernetes.utils.Constants.LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY; +import static org.apache.flink.kubernetes.utils.Constants.NAME_SEPARATOR; +import static org.apache.flink.util.Preconditions.checkNotNull; + +/** + * High availability service for Kubernetes. + */ +public class KubernetesHaServices extends AbstractHaServices { + + private final String clusterId; + + /** Kubernetes client. */ + private final FlinkKubeClient kubeClient; + + private static final String RESOURCE_MANAGER_NAME = "resourcemanager"; + + private static final String DISPATCHER_NAME = "dispatcher"; + + private static final String JOB_MANAGER_NAME = "jobmanager"; + + private static final String REST_SERVER_NAME = "restserver"; + + private static final String LEADER_SUFFIX = "leader"; + + KubernetesHaServices( + FlinkKubeClient kubeClient, + Executor executor, + Configuration config, + BlobStoreService blobStoreService) { + + super(executor, config, blobStoreService); + this.kubeClient = checkNotNull(kubeClient); + this.clusterId = checkNotNull(config.get(KubernetesConfigOptions.CLUSTER_ID)); + } + + @Override + public CheckpointRecoveryFactory getCheckpointRecoveryFactory() { + return new StandaloneCheckpointRecoveryFactory(); + } + + @Override + public JobGraphStore getJobGraphStore() { + return new StandaloneJobGraphStore(); + } + + @Override + public RunningJobsRegistry getRunningJobsRegistry() { + return new StandaloneRunningJobsRegistry(); + } + + @Override + public LeaderElectionService createLeaderElectionService(String leaderName) { + return new KubernetesLeaderElectionService( + kubeClient, + executor, + KubernetesLeaderElectionConfiguration.fromConfiguration(leaderName, configuration)); + } + + @Override + public LeaderRetrievalService createLeaderRetrievalService(String leaderName) { + return new KubernetesLeaderRetrievalService(kubeClient, leaderName); + } + + @Override + public void internalClose() throws Exception { + kubeClient.close(); Review comment: Yes. You are right. So I will keep two separate `flinkKubeClient` for `KubernetesHaService` and `KubernetesResourceDriver`. ---------------------------------------------------------------- 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