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

    • Method Detail

      • reconcile

        public void reconcile​(FlinkResourceContext<CR> 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:
        ctx - the context with which the operation is executed
        Throws:
        java.lang.Exception - Error during reconciliation.
      • readyToReconcile

        protected abstract boolean readyToReconcile​(FlinkResourceContext<CR> ctx)
        Check whether the given Flink resource is ready to be reconciled or we are still waiting for any pending operation or condition first.
        Parameters:
        ctx - Reconciliation context.
        Returns:
        True if the resource is ready to be reconciled.
      • reconcileSpecChange

        protected abstract boolean reconcileSpecChange​(FlinkResourceContext<CR> ctx,
                                                       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:
        ctx - Reconciliation context.
        deployConfig - Deployment configuration.
        Returns:
        True if spec change reconciliation was executed
        Throws:
        java.lang.Exception - Error during spec upgrade.
      • rollback

        protected abstract void rollback​(FlinkResourceContext<CR> ctx)
                                  throws java.lang.Exception
        Rollback deployed resource to the last stable spec.
        Parameters:
        ctx - Reconciliation context.
        Throws:
        java.lang.Exception - Error during rollback.
      • reconcileOtherChanges

        protected abstract boolean reconcileOtherChanges​(FlinkResourceContext<CR> ctx)
                                                  throws java.lang.Exception
        Reconcile any other changes required for this resource that are specific to the reconciler implementation.
        Parameters:
        ctx - Reconciliation context.
        Returns:
        True if any further reconciliation action was taken.
        Throws:
        java.lang.Exception - Error during reconciliation.
      • cleanup

        public io.javaoperatorsdk.operator.api.reconciler.DeleteControl cleanup​(FlinkResourceContext<CR> ctx)
        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:
        ctx - the context with which the operation is executed
        Returns:
        DeleteControl to manage the deletion behavior
      • deploy

        @VisibleForTesting
        public abstract void deploy​(FlinkResourceContext<CR> ctx,
                                    SPEC spec,
                                    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:
        ctx - Reconciliation context.
        spec - Spec that should be deployed to Kubernetes.
        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​(FlinkResourceContext<CR> ctx)
        Shut down and clean up all Flink job/cluster resources.
        Parameters:
        ctx - Current context.
        Returns:
        DeleteControl object.
      • shouldRecoverDeployment

        protected 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)
      • setOwnerReference

        protected void setOwnerReference​(CR owner,
                                         org.apache.flink.configuration.Configuration deployConfig)
      • setClock

        @VisibleForTesting
        public void setClock​(java.time.Clock clock)