public interface FlinkKubeClient extends AutoCloseable
createTaskManagerPod(KubernetesPod)
, stopPod(String)
should be
implemented asynchronously.Modifier and Type | Interface and Description |
---|---|
static interface |
FlinkKubeClient.WatchCallbackHandler<T>
Callback handler for kubernetes resources.
|
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Boolean> |
checkAndUpdateConfigMap(String configMapName,
java.util.function.Function<KubernetesConfigMap,Optional<KubernetesConfigMap>> updateFunction)
Update an existing ConfigMap with the data.
|
void |
close()
Close the Kubernetes client with no exception.
|
CompletableFuture<Void> |
createConfigMap(KubernetesConfigMap configMap)
Create the ConfigMap with specified content.
|
void |
createJobManagerComponent(KubernetesJobManagerSpecification kubernetesJMSpec)
Create the Master components, this can include the Deployment, the ConfigMap(s), and the
Service(s).
|
KubernetesLeaderElector |
createLeaderElector(KubernetesLeaderElectionConfiguration leaderElectionConfiguration,
KubernetesLeaderElector.LeaderCallbackHandler leaderCallbackHandler)
Create a leader elector service based on Kubernetes api.
|
CompletableFuture<Void> |
createTaskManagerPod(KubernetesPod kubernetesPod)
Create task manager pod.
|
CompletableFuture<Void> |
deleteConfigMap(String configMapName)
Delete a Kubernetes ConfigMap by name.
|
CompletableFuture<Void> |
deleteConfigMapsByLabels(Map<String,String> labels)
Delete the Kubernetes ConfigMaps by labels.
|
Optional<KubernetesConfigMap> |
getConfigMap(String name)
Get the ConfigMap with specified name.
|
List<KubernetesPod> |
getPodsWithLabels(Map<String,String> labels)
List the pods with specified labels.
|
Optional<Endpoint> |
getRestEndpoint(String clusterId)
Get the rest endpoint for access outside cluster.
|
Optional<KubernetesService> |
getRestService(String clusterId)
Get the kubernetes rest service of the given flink clusterId.
|
void |
handleException(Exception e)
Log exceptions.
|
void |
stopAndCleanupCluster(String clusterId)
Stop cluster and clean up all resources, include services, auxiliary services and all running
pods.
|
CompletableFuture<Void> |
stopPod(String podName)
Stop a specified pod by name.
|
KubernetesWatch |
watchConfigMaps(String name,
FlinkKubeClient.WatchCallbackHandler<KubernetesConfigMap> callbackHandler)
Watch the ConfigMaps with specified name and do the
FlinkKubeClient.WatchCallbackHandler . |
KubernetesWatch |
watchPodsAndDoCallback(Map<String,String> labels,
FlinkKubeClient.WatchCallbackHandler<KubernetesPod> podCallbackHandler)
Watch the pods selected by labels and do the
FlinkKubeClient.WatchCallbackHandler . |
void createJobManagerComponent(KubernetesJobManagerSpecification kubernetesJMSpec)
kubernetesJMSpec
- jobmanager specificationCompletableFuture<Void> createTaskManagerPod(KubernetesPod kubernetesPod)
kubernetesPod
- taskmanager podCompletableFuture<Void> stopPod(String podName)
podName
- pod namevoid stopAndCleanupCluster(String clusterId)
clusterId
- cluster idOptional<KubernetesService> getRestService(String clusterId)
clusterId
- cluster idOptional<Endpoint> getRestEndpoint(String clusterId)
clusterId
- cluster idList<KubernetesPod> getPodsWithLabels(Map<String,String> labels)
labels
- labels to filter the podsvoid handleException(Exception e)
KubernetesWatch watchPodsAndDoCallback(Map<String,String> labels, FlinkKubeClient.WatchCallbackHandler<KubernetesPod> podCallbackHandler)
FlinkKubeClient.WatchCallbackHandler
.labels
- labels to filter the pods to watchpodCallbackHandler
- podCallbackHandler which reacts to pod eventsKubernetesLeaderElector createLeaderElector(KubernetesLeaderElectionConfiguration leaderElectionConfiguration, KubernetesLeaderElector.LeaderCallbackHandler leaderCallbackHandler)
leaderElectionConfiguration
- election configurationleaderCallbackHandler
- Callback when the current instance is leader or not.KubernetesLeaderElector#run
.CompletableFuture<Void> createConfigMap(KubernetesConfigMap configMap)
KubernetesException
will be thrown.configMap
- ConfigMap to be created.Optional<KubernetesConfigMap> getConfigMap(String name)
name
- name of the ConfigMap to retrieve.CompletableFuture<Boolean> checkAndUpdateConfigMap(String configMapName, java.util.function.Function<KubernetesConfigMap,Optional<KubernetesConfigMap>> updateFunction)
getConfigMap(String)
, we could perform a
get-check-and-update transactional operation. Since concurrent modification could happen on a
same ConfigMap, the update operation may fail. We need to retry internally in the
implementation.configMapName
- configMapName specifies the name of the ConfigMap which shall be
updated.updateFunction
- Function to be applied to the obtained ConfigMap and get a new updated
one. If the returned optional is empty, we will not do the update.PossibleInconsistentStateException
indicating that no clear
decision can be made on whether the update was successful or not. The PossibleInconsistentStateException
not being present indicates that the failure happened
before writing the updated ConfigMap to Kubernetes. For the latter case, it can be
assumed that the ConfigMap was not updated.KubernetesWatch watchConfigMaps(String name, FlinkKubeClient.WatchCallbackHandler<KubernetesConfigMap> callbackHandler)
FlinkKubeClient.WatchCallbackHandler
.name
- name to filter the ConfigMaps to watchcallbackHandler
- callbackHandler which reacts to ConfigMap eventsCompletableFuture<Void> deleteConfigMapsByLabels(Map<String,String> labels)
KubernetesHaServices
to clean up all data.labels
- labels to filter the resources. e.g. type: high-availabilityCompletableFuture<Void> deleteConfigMap(String configMapName)
configMapName
- ConfigMap namevoid close()
close
in interface AutoCloseable
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.