Class AbstractJobReconciler<CR extends AbstractFlinkResource<SPEC,STATUS>,SPEC extends AbstractFlinkSpec,STATUS extends CommonStatus<SPEC>>
- java.lang.Object
-
- org.apache.flink.kubernetes.operator.reconciler.deployment.AbstractFlinkResourceReconciler<CR,SPEC,STATUS>
-
- org.apache.flink.kubernetes.operator.reconciler.deployment.AbstractJobReconciler<CR,SPEC,STATUS>
-
- All Implemented Interfaces:
Reconciler<CR>
- Direct Known Subclasses:
ApplicationReconciler
,SessionJobReconciler
public abstract class AbstractJobReconciler<CR extends AbstractFlinkResource<SPEC,STATUS>,SPEC extends AbstractFlinkSpec,STATUS extends CommonStatus<SPEC>> extends AbstractFlinkResourceReconciler<CR,SPEC,STATUS>
Reconciler responsible for handling the job lifecycle according to the desired and current states.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractJobReconciler.JobUpgrade
Object to capture available upgrade mode.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LAST_STATE_DUMMY_SP_PATH
-
Fields inherited from class org.apache.flink.kubernetes.operator.reconciler.deployment.AbstractFlinkResourceReconciler
autoscaler, clock, eventRecorder, MSG_ROLLBACK, MSG_SPEC_CHANGED, MSG_SUBMIT, MSG_SUSPENDED, statusRecorder
-
-
Constructor Summary
Constructors Constructor Description AbstractJobReconciler(EventRecorder eventRecorder, StatusRecorder<CR,STATUS> statusRecorder, JobAutoScaler<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext> autoscaler)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
cancelJob(FlinkResourceContext<CR> ctx, SuspendMode suspendMode)
Cancel the job for the given resource using the specified upgrade mode.protected abstract void
cleanupAfterFailedJob(FlinkResourceContext<CR> ctx)
Removes a failed job.protected AbstractJobReconciler.JobUpgrade
getJobUpgrade(FlinkResourceContext<CR> ctx, org.apache.flink.configuration.Configuration deployConfig)
protected AbstractJobReconciler.JobUpgrade
getUpgradeModeBasedOnStateAge(FlinkResourceContext<CR> ctx, org.apache.flink.configuration.Configuration deployConfig, boolean cancellable)
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.boolean
reconcileOtherChanges(FlinkResourceContext<CR> ctx)
Triggers any pending manual or periodic snapshots and updates the status accordingly.protected boolean
reconcileSpecChange(DiffType diffType, FlinkResourceContext<CR> ctx, org.apache.flink.configuration.Configuration deployConfig, SPEC lastReconciledSpec)
Reconcile spec upgrade on the currently deployed/suspended Flink resource and update the status accordingly.protected void
restoreJob(FlinkResourceContext<CR> ctx, SPEC spec, org.apache.flink.configuration.Configuration deployConfig, boolean requireHaMetadata)
protected void
resubmitJob(FlinkResourceContext<CR> ctx, boolean requireHaMetadata)
protected void
setUpgradeSavepointPath(FlinkResourceContext<?> ctx, java.lang.String savepointLocation)
Updates the upgrade savepoint field in the JobSpec of the current Flink resource and if snapshot resources are enabled, a new FlinkStateSnapshot will be created.-
Methods inherited from class org.apache.flink.kubernetes.operator.reconciler.deployment.AbstractFlinkResourceReconciler
cleanup, cleanupInternal, deploy, flinkVersionChanged, reconcile, setClock, setOwnerReference, shouldRecoverDeployment
-
-
-
-
Field Detail
-
LAST_STATE_DUMMY_SP_PATH
public static final java.lang.String LAST_STATE_DUMMY_SP_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractJobReconciler
public AbstractJobReconciler(EventRecorder eventRecorder, StatusRecorder<CR,STATUS> statusRecorder, JobAutoScaler<io.javaoperatorsdk.operator.processing.event.ResourceID,KubernetesJobAutoScalerContext> autoscaler)
-
-
Method Detail
-
readyToReconcile
public boolean readyToReconcile(FlinkResourceContext<CR> ctx)
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 classAbstractFlinkResourceReconciler<CR extends AbstractFlinkResource<SPEC,STATUS>,SPEC extends AbstractFlinkSpec,STATUS extends CommonStatus<SPEC>>
- Parameters:
ctx
- Reconciliation context.- Returns:
- True if the resource is ready to be reconciled.
-
reconcileSpecChange
protected boolean reconcileSpecChange(DiffType diffType, FlinkResourceContext<CR> ctx, org.apache.flink.configuration.Configuration deployConfig, SPEC lastReconciledSpec) 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 classAbstractFlinkResourceReconciler<CR extends AbstractFlinkResource<SPEC,STATUS>,SPEC extends AbstractFlinkSpec,STATUS extends CommonStatus<SPEC>>
- Parameters:
diffType
- SpecChange diff type.ctx
- Reconciliation context.deployConfig
- Deployment configuration.lastReconciledSpec
- Last reconciled spec- Returns:
- True if spec change reconciliation was executed
- Throws:
java.lang.Exception
- Error during spec upgrade.
-
getJobUpgrade
protected AbstractJobReconciler.JobUpgrade getJobUpgrade(FlinkResourceContext<CR> ctx, org.apache.flink.configuration.Configuration deployConfig) throws java.lang.Exception
- Throws:
java.lang.Exception
-
getUpgradeModeBasedOnStateAge
@VisibleForTesting protected AbstractJobReconciler.JobUpgrade getUpgradeModeBasedOnStateAge(FlinkResourceContext<CR> ctx, org.apache.flink.configuration.Configuration deployConfig, boolean cancellable) throws java.lang.Exception
- Throws:
java.lang.Exception
-
restoreJob
protected void restoreJob(FlinkResourceContext<CR> ctx, SPEC spec, org.apache.flink.configuration.Configuration deployConfig, boolean requireHaMetadata) throws java.lang.Exception
- Throws:
java.lang.Exception
-
setUpgradeSavepointPath
protected void setUpgradeSavepointPath(FlinkResourceContext<?> ctx, java.lang.String savepointLocation)
Updates the upgrade savepoint field in the JobSpec of the current Flink resource and if snapshot resources are enabled, a new FlinkStateSnapshot will be created.- Parameters:
ctx
- contextsavepointLocation
- location of savepoint taken
-
reconcileOtherChanges
public boolean reconcileOtherChanges(FlinkResourceContext<CR> ctx) throws java.lang.Exception
Triggers any pending manual or periodic snapshots and updates the status accordingly.- Specified by:
reconcileOtherChanges
in classAbstractFlinkResourceReconciler<CR extends AbstractFlinkResource<SPEC,STATUS>,SPEC extends AbstractFlinkSpec,STATUS extends CommonStatus<SPEC>>
- Parameters:
ctx
- Reconciliation context.- Returns:
- True if a snapshot was triggered.
- Throws:
java.lang.Exception
- An error during snapshot triggering.
-
resubmitJob
protected void resubmitJob(FlinkResourceContext<CR> ctx, boolean requireHaMetadata) throws java.lang.Exception
- Throws:
java.lang.Exception
-
cancelJob
protected abstract boolean cancelJob(FlinkResourceContext<CR> ctx, SuspendMode suspendMode) throws java.lang.Exception
Cancel the job for the given resource using the specified upgrade mode.- Parameters:
ctx
- Reconciler context.suspendMode
- Suspend mode used during cancel.- Returns:
- True if this is an async cancellation
- Throws:
java.lang.Exception
- Error during cancellation.
-
cleanupAfterFailedJob
protected abstract void cleanupAfterFailedJob(FlinkResourceContext<CR> ctx) throws java.lang.Exception
Removes a failed job.- Parameters:
ctx
- Reconciler context.- Throws:
java.lang.Exception
- Error during cancellation.
-
-