Class FlinkUtils
- java.lang.Object
-
- org.apache.flink.kubernetes.operator.utils.FlinkUtils
-
public class FlinkUtils extends java.lang.Object
Flink Utility methods used by the operator.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CR_GENERATION_LABEL
-
Constructor Summary
Constructors Constructor Description FlinkUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addStartupProbe(io.fabric8.kubernetes.api.model.Pod pod)
static java.lang.Double
calculateClusterCpuUsage(org.apache.flink.configuration.Configuration conf, int taskManagerReplicas)
static java.lang.Long
calculateClusterMemoryUsage(org.apache.flink.configuration.Configuration conf, int taskManagerReplicas)
static void
deleteJobGraphInKubernetesHA(java.lang.String clusterId, java.lang.String namespace, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)
static void
deleteJobGraphInZookeeperHA(org.apache.flink.configuration.Configuration conf)
static void
deleteKubernetesHAMetadata(java.lang.String clusterId, java.lang.String namespace, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)
static void
deleteZookeeperHAMetadata(org.apache.flink.configuration.Configuration conf)
static org.apache.flink.api.common.JobID
generateSessionJobFixedJobID(io.fabric8.kubernetes.api.model.ObjectMeta meta)
The jobID's lower part is the resource uid, the higher part is the resource generation.static org.apache.flink.api.common.JobID
generateSessionJobFixedJobID(java.lang.String uid, java.lang.Long generation)
The jobID's lower part is the resource uid, the higher part is the resource generation.static int
getNumTaskManagers(org.apache.flink.configuration.Configuration conf)
static int
getNumTaskManagers(org.apache.flink.configuration.Configuration conf, int parallelism)
static boolean
isKubernetesHAActivated(org.apache.flink.configuration.Configuration configuration)
static boolean
isKubernetesHaMetadataAvailable(org.apache.flink.configuration.Configuration conf, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)
static boolean
isZookeeperHAActivated(org.apache.flink.configuration.Configuration configuration)
static boolean
isZookeeperHaMetadataAvailable(org.apache.flink.configuration.Configuration conf)
static boolean
jmPodNeverStarted(io.javaoperatorsdk.operator.api.reconciler.Context<?> context)
Check if the jobmanager pod has never successfully started.static io.fabric8.kubernetes.api.model.Pod
mergePodTemplates(io.fabric8.kubernetes.api.model.Pod toPod, io.fabric8.kubernetes.api.model.Pod fromPod, boolean mergeArraysByName)
static void
setGenerationAnnotation(org.apache.flink.configuration.Configuration conf, java.lang.Long generation)
-
-
-
Field Detail
-
CR_GENERATION_LABEL
public static final java.lang.String CR_GENERATION_LABEL
- See Also:
- Constant Field Values
-
-
Method Detail
-
mergePodTemplates
public static io.fabric8.kubernetes.api.model.Pod mergePodTemplates(io.fabric8.kubernetes.api.model.Pod toPod, io.fabric8.kubernetes.api.model.Pod fromPod, boolean mergeArraysByName)
-
addStartupProbe
public static void addStartupProbe(io.fabric8.kubernetes.api.model.Pod pod)
-
deleteZookeeperHAMetadata
public static void deleteZookeeperHAMetadata(org.apache.flink.configuration.Configuration conf)
-
deleteKubernetesHAMetadata
public static void deleteKubernetesHAMetadata(java.lang.String clusterId, java.lang.String namespace, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)
-
deleteJobGraphInZookeeperHA
public static void deleteJobGraphInZookeeperHA(org.apache.flink.configuration.Configuration conf) throws java.lang.Exception
- Throws:
java.lang.Exception
-
deleteJobGraphInKubernetesHA
public static void deleteJobGraphInKubernetesHA(java.lang.String clusterId, java.lang.String namespace, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)
-
isZookeeperHaMetadataAvailable
public static boolean isZookeeperHaMetadataAvailable(org.apache.flink.configuration.Configuration conf)
-
isKubernetesHaMetadataAvailable
public static boolean isKubernetesHaMetadataAvailable(org.apache.flink.configuration.Configuration conf, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)
-
isZookeeperHAActivated
public static boolean isZookeeperHAActivated(org.apache.flink.configuration.Configuration configuration)
-
isKubernetesHAActivated
public static boolean isKubernetesHAActivated(org.apache.flink.configuration.Configuration configuration)
-
getNumTaskManagers
public static int getNumTaskManagers(org.apache.flink.configuration.Configuration conf)
-
getNumTaskManagers
public static int getNumTaskManagers(org.apache.flink.configuration.Configuration conf, int parallelism)
-
calculateClusterCpuUsage
public static java.lang.Double calculateClusterCpuUsage(org.apache.flink.configuration.Configuration conf, int taskManagerReplicas)
-
calculateClusterMemoryUsage
public static java.lang.Long calculateClusterMemoryUsage(org.apache.flink.configuration.Configuration conf, int taskManagerReplicas)
-
setGenerationAnnotation
public static void setGenerationAnnotation(org.apache.flink.configuration.Configuration conf, java.lang.Long generation)
-
generateSessionJobFixedJobID
public static org.apache.flink.api.common.JobID generateSessionJobFixedJobID(io.fabric8.kubernetes.api.model.ObjectMeta meta)
The jobID's lower part is the resource uid, the higher part is the resource generation.- Parameters:
meta
- the meta of the resource.- Returns:
- the generated jobID.
-
generateSessionJobFixedJobID
public static org.apache.flink.api.common.JobID generateSessionJobFixedJobID(java.lang.String uid, java.lang.Long generation)
The jobID's lower part is the resource uid, the higher part is the resource generation.- Parameters:
uid
- the uid of the resource.generation
- the generation of the resource.- Returns:
- the generated jobID.
-
jmPodNeverStarted
public static boolean jmPodNeverStarted(io.javaoperatorsdk.operator.api.reconciler.Context<?> context)
Check if the jobmanager pod has never successfully started. This is an important check to determine whether it is possible that the job has started and taken any checkpoints that we are unaware of.The way we check this is by using the availability condition transition timestamp. If the deployment never transitioned out of the unavailable state, we can assume that the JM never started.
- Parameters:
context
- Resource context- Returns:
- True only if we are sure that the jobmanager pod never started
-
-