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 deleteCluster​(FlinkDeploymentStatus status, io.fabric8.kubernetes.api.model.ObjectMeta meta, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, boolean deleteHaConfigmaps, long shutdownTimeout)
      Delete Flink kubernetes cluster by deleting the kubernetes resources directly.
      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 io.fabric8.kubernetes.api.model.PodList getJmPodList​(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, java.lang.String namespace, java.lang.String clusterId)  
      static int getNumTaskManagers​(org.apache.flink.configuration.Configuration conf)  
      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 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)  
      static void waitForClusterShutdown​(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, java.lang.String namespace, java.lang.String clusterId, long shutdownTimeout)
      Wait until the FLink cluster has completely shut down.
      static void waitForClusterShutdown​(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, org.apache.flink.configuration.Configuration conf, long shutdownTimeout)
      Wait until the FLink cluster has completely shut down.
      • 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)
      • deleteCluster

        public static void deleteCluster​(FlinkDeploymentStatus status,
                                         io.fabric8.kubernetes.api.model.ObjectMeta meta,
                                         io.fabric8.kubernetes.client.KubernetesClient kubernetesClient,
                                         boolean deleteHaConfigmaps,
                                         long shutdownTimeout)
        Delete Flink kubernetes cluster by deleting the kubernetes resources directly. Optionally allows deleting the native kubernetes HA resources as well.
        Parameters:
        status - Deployment status object
        meta - ObjectMeta of the deployment
        kubernetesClient - Kubernetes client
        deleteHaConfigmaps - Flag to indicate whether k8s HA metadata should be removed as well
        shutdownTimeout - maximum time allowed for cluster shutdown
      • waitForClusterShutdown

        public static void waitForClusterShutdown​(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient,
                                                  java.lang.String namespace,
                                                  java.lang.String clusterId,
                                                  long shutdownTimeout)
        Wait until the FLink cluster has completely shut down.
        Parameters:
        kubernetesClient - Kubernetes client.
        namespace - Resource namespace.
        clusterId - Flink clusterId.
        shutdownTimeout - Max time allowed for shutdown.
      • waitForClusterShutdown

        public static void waitForClusterShutdown​(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient,
                                                  org.apache.flink.configuration.Configuration conf,
                                                  long shutdownTimeout)
        Wait until the FLink cluster has completely shut down.
        Parameters:
        kubernetesClient - Kubernetes client.
        conf - Flink configuration.
        shutdownTimeout - Max time allowed for shutdown.
      • getJmPodList

        public static io.fabric8.kubernetes.api.model.PodList getJmPodList​(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient,
                                                                           java.lang.String namespace,
                                                                           java.lang.String clusterId)
      • 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)
      • 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.