Class 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 boolean clusterShutdownDisabled​(FlinkDeploymentSpec spec)  
      static void deleteJobGraphInKubernetesHA​(java.lang.String clusterId, java.lang.String namespace, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)  
      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 isHaMetadataAvailable​(org.apache.flink.configuration.Configuration conf, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)  
      static boolean isKubernetesHAActivated​(org.apache.flink.configuration.Configuration configuration)  
      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)  
      static void setGenerationAnnotation​(org.apache.flink.configuration.Configuration conf, java.lang.Long generation)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CR_GENERATION_LABEL

        public static final java.lang.String CR_GENERATION_LABEL
        See Also:
        Constant Field Values
    • Constructor Detail

      • FlinkUtils

        public FlinkUtils()
    • 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)
      • deleteJobGraphInKubernetesHA

        public static void deleteJobGraphInKubernetesHA​(java.lang.String clusterId,
                                                        java.lang.String namespace,
                                                        io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)
      • isHaMetadataAvailable

        public static boolean isHaMetadataAvailable​(org.apache.flink.configuration.Configuration conf,
                                                    io.fabric8.kubernetes.client.KubernetesClient kubernetesClient)
      • isKubernetesHAActivated

        public static boolean isKubernetesHAActivated​(org.apache.flink.configuration.Configuration configuration)
      • clusterShutdownDisabled

        public static boolean clusterShutdownDisabled​(FlinkDeploymentSpec spec)
      • getNumTaskManagers

        public static int getNumTaskManagers​(org.apache.flink.configuration.Configuration conf)
      • getNumTaskManagers

        public static int getNumTaskManagers​(org.apache.flink.configuration.Configuration conf,
                                             int parallelism)
      • 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