Class SessionReconciler

  • All Implemented Interfaces:
    Reconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment>

    public class SessionReconciler
    extends AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
    Reconciler responsible for handling the session cluster lifecycle according to the desired and current states.
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionReconciler​(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, FlinkService flinkService, FlinkConfigManager configManager, EventRecorder eventRecorder, StatusRecorder<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus> statusRecorder)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.javaoperatorsdk.operator.api.reconciler.DeleteControl cleanupInternal​(org.apache.flink.kubernetes.operator.api.FlinkDeployment deployment, io.javaoperatorsdk.operator.api.reconciler.Context<?> context)
      Shut down and clean up all Flink job/cluster resources.
      protected void deploy​(org.apache.flink.kubernetes.operator.api.FlinkDeployment cr, org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec spec, org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus status, io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx, org.apache.flink.configuration.Configuration deployConfig, java.util.Optional<java.lang.String> savepoint, boolean requireHaMetadata)
      Deploys the target resource spec to Kubernetes.
      protected org.apache.flink.configuration.Configuration getDeployConfig​(io.fabric8.kubernetes.api.model.ObjectMeta meta, org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec spec, io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx)
      protected FlinkService getFlinkService​(org.apache.flink.kubernetes.operator.api.FlinkDeployment resource, io.javaoperatorsdk.operator.api.reconciler.Context<?> context)
      Get the Flink service related to the resource and context.
      protected org.apache.flink.configuration.Configuration getObserveConfig​(org.apache.flink.kubernetes.operator.api.FlinkDeployment resource, io.javaoperatorsdk.operator.api.reconciler.Context<?> context)
      Get Flink configuration for client interactions with the running Flink deployment/session job.
      protected boolean readyToReconcile​(org.apache.flink.kubernetes.operator.api.FlinkDeployment deployment, io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx, org.apache.flink.configuration.Configuration deployConfig)
      Check whether the given Flink resource is ready to be reconciled or we are still waiting for any pending operation or condition first.
      boolean reconcileOtherChanges​(org.apache.flink.kubernetes.operator.api.FlinkDeployment flinkApp, io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx, org.apache.flink.configuration.Configuration observeConfig)
      Reconcile any other changes required for this resource that are specific to the reconciler implementation.
      protected void reconcileSpecChange​(org.apache.flink.kubernetes.operator.api.FlinkDeployment deployment, io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx, org.apache.flink.configuration.Configuration observeConfig, org.apache.flink.configuration.Configuration deployConfig, org.apache.flink.kubernetes.operator.api.diff.DiffType type)
      Reconcile spec upgrade on the currently deployed/suspended Flink resource and update the status accordingly.
      protected void rollback​(org.apache.flink.kubernetes.operator.api.FlinkDeployment deployment, io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx, org.apache.flink.configuration.Configuration observeConfig)
      Rollback deployed resource to the last stable spec.
      • Methods inherited from class java.lang.Object

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

    • Constructor Detail

      • SessionReconciler

        public SessionReconciler​(io.fabric8.kubernetes.client.KubernetesClient kubernetesClient,
                                 FlinkService flinkService,
                                 FlinkConfigManager configManager,
                                 EventRecorder eventRecorder,
                                 StatusRecorder<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus> statusRecorder)
    • Method Detail

      • getFlinkService

        protected FlinkService getFlinkService​(org.apache.flink.kubernetes.operator.api.FlinkDeployment resource,
                                               io.javaoperatorsdk.operator.api.reconciler.Context<?> context)
        Description copied from class: AbstractFlinkResourceReconciler
        Get the Flink service related to the resource and context.
        Specified by:
        getFlinkService in class AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
        Parameters:
        resource - Resource being reconciled.
        context - Current context.
        Returns:
        Flink service implementation.
      • getObserveConfig

        protected org.apache.flink.configuration.Configuration getObserveConfig​(org.apache.flink.kubernetes.operator.api.FlinkDeployment resource,
                                                                                io.javaoperatorsdk.operator.api.reconciler.Context<?> context)
        Description copied from class: AbstractFlinkResourceReconciler
        Get Flink configuration for client interactions with the running Flink deployment/session job.
        Specified by:
        getObserveConfig in class AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
        Parameters:
        resource - Related Flink resource.
        context - Reconciliation context.
        Returns:
        Observe configuration.
      • readyToReconcile

        protected boolean readyToReconcile​(org.apache.flink.kubernetes.operator.api.FlinkDeployment deployment,
                                           io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx,
                                           org.apache.flink.configuration.Configuration deployConfig)
        Description copied from class: AbstractFlinkResourceReconciler
        Check whether the given Flink resource is ready to be reconciled or we are still waiting for any pending operation or condition first.
        Specified by:
        readyToReconcile in class AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
        Parameters:
        deployment - Related Flink resource.
        ctx - Reconciliation context.
        deployConfig - Deployment configuration.
        Returns:
        True if the resource is ready to be reconciled.
      • reconcileSpecChange

        protected void reconcileSpecChange​(org.apache.flink.kubernetes.operator.api.FlinkDeployment deployment,
                                           io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx,
                                           org.apache.flink.configuration.Configuration observeConfig,
                                           org.apache.flink.configuration.Configuration deployConfig,
                                           org.apache.flink.kubernetes.operator.api.diff.DiffType type)
                                    throws java.lang.Exception
        Description copied from class: AbstractFlinkResourceReconciler
        Reconcile spec upgrade on the currently deployed/suspended Flink resource and update the status accordingly.
        Specified by:
        reconcileSpecChange in class AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
        Parameters:
        deployment - Related Flink resource.
        observeConfig - Observe configuration.
        deployConfig - Deployment configuration.
        Throws:
        java.lang.Exception - Error during spec upgrade.
      • deploy

        protected void deploy​(org.apache.flink.kubernetes.operator.api.FlinkDeployment cr,
                              org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec spec,
                              org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus status,
                              io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx,
                              org.apache.flink.configuration.Configuration deployConfig,
                              java.util.Optional<java.lang.String> savepoint,
                              boolean requireHaMetadata)
                       throws java.lang.Exception
        Description copied from class: AbstractFlinkResourceReconciler
        Deploys the target resource spec to Kubernetes.
        Specified by:
        deploy in class AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
        Parameters:
        cr - Related resource.
        spec - Spec that should be deployed to Kubernetes.
        status - Status object of the resource
        ctx - Reconciliation context.
        deployConfig - Flink conf for the deployment.
        savepoint - Optional savepoint path for applications and session jobs.
        requireHaMetadata - Flag used by application deployments to validate HA metadata
        Throws:
        java.lang.Exception - Error during deployment.
      • rollback

        protected void rollback​(org.apache.flink.kubernetes.operator.api.FlinkDeployment deployment,
                                io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx,
                                org.apache.flink.configuration.Configuration observeConfig)
                         throws java.lang.Exception
        Description copied from class: AbstractFlinkResourceReconciler
        Rollback deployed resource to the last stable spec.
        Specified by:
        rollback in class AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
        Parameters:
        deployment - Related Flink resource.
        ctx - Reconciliation context.
        observeConfig - Observe configuration.
        Throws:
        java.lang.Exception - Error during rollback.
      • reconcileOtherChanges

        public boolean reconcileOtherChanges​(org.apache.flink.kubernetes.operator.api.FlinkDeployment flinkApp,
                                             io.javaoperatorsdk.operator.api.reconciler.Context<?> ctx,
                                             org.apache.flink.configuration.Configuration observeConfig)
                                      throws java.lang.Exception
        Description copied from class: AbstractFlinkResourceReconciler
        Reconcile any other changes required for this resource that are specific to the reconciler implementation.
        Specified by:
        reconcileOtherChanges in class AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
        Parameters:
        flinkApp - Related Flink resource.
        observeConfig - Observe configuration.
        Returns:
        True if any further reconciliation action was taken.
        Throws:
        java.lang.Exception - Error during reconciliation.
      • cleanupInternal

        public io.javaoperatorsdk.operator.api.reconciler.DeleteControl cleanupInternal​(org.apache.flink.kubernetes.operator.api.FlinkDeployment deployment,
                                                                                        io.javaoperatorsdk.operator.api.reconciler.Context<?> context)
        Description copied from class: AbstractFlinkResourceReconciler
        Shut down and clean up all Flink job/cluster resources.
        Specified by:
        cleanupInternal in class AbstractFlinkResourceReconciler<org.apache.flink.kubernetes.operator.api.FlinkDeployment,​org.apache.flink.kubernetes.operator.api.spec.FlinkDeploymentSpec,​org.apache.flink.kubernetes.operator.api.status.FlinkDeploymentStatus>
        Parameters:
        deployment - Resource being reconciled.
        context - Current context.
        Returns:
        DeleteControl object.