Class TriggerManager
java.lang.Object
org.apache.flink.api.common.functions.AbstractRichFunction
org.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean,TableChange,Trigger>
org.apache.iceberg.flink.maintenance.operator.TriggerManager
- All Implemented Interfaces:
Serializable,org.apache.flink.api.common.functions.Function,org.apache.flink.api.common.functions.RichFunction,org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
@Internal
public class TriggerManager
extends org.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean,TableChange,Trigger>
implements org.apache.flink.streaming.api.checkpoint.CheckpointedFunction
TriggerManager starts the Maintenance Tasks by emitting
Trigger messages which are
calculated based on the incoming TableChange messages. The TriggerManager keeps track of
the changes since the last run of the Maintenance Tasks and triggers a new run based on the
result of the TriggerEvaluator.
The TriggerManager prevents overlapping Maintenance Task runs using TriggerLockFactory.Lock. The current implementation only handles conflicts within a single job.
Users should avoid scheduling maintenance for the same table in different Flink jobs.
The TriggerManager should run as a global operator. KeyedProcessFunction is used, so
the timer functions are available, but the key is not used.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.flink.streaming.api.functions.KeyedProcessFunction
org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context, org.apache.flink.streaming.api.functions.KeyedProcessFunction.OnTimerContext -
Constructor Summary
ConstructorsConstructorDescriptionTriggerManager(TableLoader tableLoader, TriggerLockFactory lockFactory, List<String> maintenanceTaskNames, List<TriggerEvaluator> evaluators, long minFireDelayMs, long lockCheckDelayMs) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidinitializeState(org.apache.flink.runtime.state.FunctionInitializationContext context) voidonTimer(long timestamp, org.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean, TableChange, Trigger>.org.apache.flink.streaming.api.functions.KeyedProcessFunction.OnTimerContext ctx, org.apache.flink.util.Collector<Trigger> out) voidopen(org.apache.flink.api.common.functions.OpenContext parameters) voidprocessElement(TableChange change, org.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean, TableChange, Trigger>.org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context ctx, org.apache.flink.util.Collector<Trigger> out) voidsnapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context) Methods inherited from class org.apache.flink.api.common.functions.AbstractRichFunction
getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
-
Constructor Details
-
TriggerManager
public TriggerManager(TableLoader tableLoader, TriggerLockFactory lockFactory, List<String> maintenanceTaskNames, List<TriggerEvaluator> evaluators, long minFireDelayMs, long lockCheckDelayMs)
-
-
Method Details
-
open
- Specified by:
openin interfaceorg.apache.flink.api.common.functions.RichFunction- Overrides:
openin classorg.apache.flink.api.common.functions.AbstractRichFunction- Throws:
Exception
-
snapshotState
public void snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context) throws Exception - Specified by:
snapshotStatein interfaceorg.apache.flink.streaming.api.checkpoint.CheckpointedFunction- Throws:
Exception
-
initializeState
public void initializeState(org.apache.flink.runtime.state.FunctionInitializationContext context) throws Exception - Specified by:
initializeStatein interfaceorg.apache.flink.streaming.api.checkpoint.CheckpointedFunction- Throws:
Exception
-
processElement
public void processElement(TableChange change, org.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean, TableChange, throws ExceptionTrigger>.org.apache.flink.streaming.api.functions.KeyedProcessFunction.Context ctx, org.apache.flink.util.Collector<Trigger> out) - Specified by:
processElementin classorg.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean,TableChange, Trigger> - Throws:
Exception
-
onTimer
public void onTimer(long timestamp, org.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean, TableChange, throws ExceptionTrigger>.org.apache.flink.streaming.api.functions.KeyedProcessFunction.OnTimerContext ctx, org.apache.flink.util.Collector<Trigger> out) - Overrides:
onTimerin classorg.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean,TableChange, Trigger> - Throws:
Exception
-
close
- Specified by:
closein interfaceorg.apache.flink.api.common.functions.RichFunction- Overrides:
closein classorg.apache.flink.api.common.functions.AbstractRichFunction- Throws:
IOException
-