Class AbstractFlinkResourceReconciler<CR extends AbstractFlinkResource<SPEC,​STATUS>,​SPEC extends AbstractFlinkSpec,​STATUS extends CommonStatus<SPEC>>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      io.javaoperatorsdk.operator.api.reconciler.DeleteControl cleanup​(CR resource, io.javaoperatorsdk.operator.api.reconciler.Context context)
      This is called when receiving the delete event of custom resource.
      protected abstract io.javaoperatorsdk.operator.api.reconciler.DeleteControl cleanupInternal​(CR resource, io.javaoperatorsdk.operator.api.reconciler.Context context)
      Shut down and clean up all Flink job/cluster resources.
      protected abstract void deploy​(CR relatedResource, SPEC spec, STATUS status, org.apache.flink.configuration.Configuration deployConfig, java.util.Optional<java.lang.String> savepoint, boolean requireHaMetadata)
      Deploys the target resource spec to Kubernetes.
      protected boolean flinkVersionChanged​(SPEC oldSpec, SPEC newSpec)  
      protected abstract org.apache.flink.configuration.Configuration getDeployConfig​(io.fabric8.kubernetes.api.model.ObjectMeta meta, SPEC spec, io.javaoperatorsdk.operator.api.reconciler.Context ctx)
      protected abstract org.apache.flink.configuration.Configuration getObserveConfig​(CR resource, io.javaoperatorsdk.operator.api.reconciler.Context context)
      Get Flink configuration for client interactions with the running Flink deployment/session job.
      protected abstract boolean readyToReconcile​(CR cr, 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.
      void reconcile​(CR cr, io.javaoperatorsdk.operator.api.reconciler.Context ctx)
      This is called when receiving the create or update event of the custom resource.
      protected abstract boolean reconcileOtherChanges​(CR cr, org.apache.flink.configuration.Configuration observeConfig)
      Reconcile any other changes required for this resource that are specific to the reconciler implementation.
      protected abstract void reconcileSpecChange​(CR cr, org.apache.flink.configuration.Configuration observeConfig, org.apache.flink.configuration.Configuration deployConfig)
      Reconcile spec upgrade on the currently deployed/suspended Flink resource and update the status accordingly.
      protected abstract void rollback​(CR cr, io.javaoperatorsdk.operator.api.reconciler.Context ctx, org.apache.flink.configuration.Configuration observeConfig)
      Rollback deployed resource to the last stable spec.
      protected static boolean shouldRecoverDeployment​(org.apache.flink.configuration.Configuration conf, FlinkDeployment deployment)
      Checks whether the JobManager Kubernetes Deployment recovery logic should be initiated.
      • Methods inherited from class java.lang.Object

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

      • reconcile

        public final void reconcile​(CR cr,
                                    io.javaoperatorsdk.operator.api.reconciler.Context ctx)
                             throws java.lang.Exception
        Description copied from interface: Reconciler
        This is called when receiving the create or update event of the custom resource.
        Specified by:
        reconcile in interface Reconciler<CR extends AbstractFlinkResource<SPEC,​STATUS>>
        Parameters:
        cr - the custom resource that has been created or updated
        ctx - the context with which the operation is executed
        Throws:
        java.lang.Exception - Error during reconciliation.
      • getObserveConfig

        protected abstract org.apache.flink.configuration.Configuration getObserveConfig​(CR resource,
                                                                                         io.javaoperatorsdk.operator.api.reconciler.Context context)
        Get Flink configuration for client interactions with the running Flink deployment/session job.
        Parameters:
        resource - Related Flink resource.
        context - Reconciliation context.
        Returns:
        Observe configuration.
      • readyToReconcile

        protected abstract boolean readyToReconcile​(CR cr,
                                                    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.
        Parameters:
        cr - Related Flink resource.
        ctx - Reconciliation context.
        deployConfig - Deployment configuration.
        Returns:
        True if the resource is ready to be reconciled.
      • reconcileSpecChange

        protected abstract void reconcileSpecChange​(CR cr,
                                                    org.apache.flink.configuration.Configuration observeConfig,
                                                    org.apache.flink.configuration.Configuration deployConfig)
                                             throws java.lang.Exception
        Reconcile spec upgrade on the currently deployed/suspended Flink resource and update the status accordingly.
        Parameters:
        cr - Related Flink resource.
        observeConfig - Observe configuration.
        deployConfig - Deployment configuration.
        Throws:
        java.lang.Exception - Error during spec upgrade.
      • rollback

        protected abstract void rollback​(CR cr,
                                         io.javaoperatorsdk.operator.api.reconciler.Context ctx,
                                         org.apache.flink.configuration.Configuration observeConfig)
                                  throws java.lang.Exception
        Rollback deployed resource to the last stable spec.
        Parameters:
        cr - Related Flink resource.
        ctx - Reconciliation context.
        observeConfig - Observe configuration.
        Throws:
        java.lang.Exception - Error during rollback.
      • reconcileOtherChanges

        protected abstract boolean reconcileOtherChanges​(CR cr,
                                                         org.apache.flink.configuration.Configuration observeConfig)
                                                  throws java.lang.Exception
        Reconcile any other changes required for this resource that are specific to the reconciler implementation.
        Parameters:
        cr - Related Flink resource.
        observeConfig - Observe configuration.
        Returns:
        True if any further reconciliation action was taken.
        Throws:
        java.lang.Exception - Error during reconciliation.
      • cleanup

        public final io.javaoperatorsdk.operator.api.reconciler.DeleteControl cleanup​(CR resource,
                                                                                      io.javaoperatorsdk.operator.api.reconciler.Context context)
        Description copied from interface: Reconciler
        This is called when receiving the delete event of custom resource. This method is meant to cleanup the associated components like the Flink job components.
        Specified by:
        cleanup in interface Reconciler<CR extends AbstractFlinkResource<SPEC,​STATUS>>
        Parameters:
        resource - the custom resource that has been deleted
        context - the context with which the operation is executed
        Returns:
        DeleteControl to manage the deletion behavior
      • deploy

        protected abstract void deploy​(CR relatedResource,
                                       SPEC spec,
                                       STATUS status,
                                       org.apache.flink.configuration.Configuration deployConfig,
                                       java.util.Optional<java.lang.String> savepoint,
                                       boolean requireHaMetadata)
                                throws java.lang.Exception
        Deploys the target resource spec to Kubernetes.
        Parameters:
        relatedResource - Related resource.
        spec - Spec that should be deployed to Kubernetes.
        status - Status object of the resource
        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.
      • cleanupInternal

        protected abstract io.javaoperatorsdk.operator.api.reconciler.DeleteControl cleanupInternal​(CR resource,
                                                                                                    io.javaoperatorsdk.operator.api.reconciler.Context context)
        Shut down and clean up all Flink job/cluster resources.
        Parameters:
        resource - Resource being reconciled.
        context - Current context.
        Returns:
        DeleteControl object.
      • shouldRecoverDeployment

        protected static boolean shouldRecoverDeployment​(org.apache.flink.configuration.Configuration conf,
                                                         FlinkDeployment deployment)
        Checks whether the JobManager Kubernetes Deployment recovery logic should be initiated. This is triggered only if, jm deployment missing, recovery config and HA enabled. This logic is only used by the Session and Application reconcilers.
        Parameters:
        conf - Flink cluster configuration.
        deployment - FlinkDeployment object.
        Returns:
        True if recovery should be executed.
      • flinkVersionChanged

        protected boolean flinkVersionChanged​(SPEC oldSpec,
                                              SPEC newSpec)