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 TypeMethodDescriptionvoid
close()
void
initializeState
(org.apache.flink.runtime.state.FunctionInitializationContext context) void
onTimer
(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) void
open
(org.apache.flink.configuration.Configuration parameters) void
processElement
(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) void
snapshotState
(org.apache.flink.runtime.state.FunctionSnapshotContext context) Methods inherited from class org.apache.flink.api.common.functions.AbstractRichFunction
getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.flink.api.common.functions.RichFunction
open
-
Constructor Details
-
TriggerManager
public TriggerManager(TableLoader tableLoader, TriggerLockFactory lockFactory, List<String> maintenanceTaskNames, List<TriggerEvaluator> evaluators, long minFireDelayMs, long lockCheckDelayMs)
-
-
Method Details
-
open
- Specified by:
open
in interfaceorg.apache.flink.api.common.functions.RichFunction
- Overrides:
open
in classorg.apache.flink.api.common.functions.AbstractRichFunction
- Throws:
Exception
-
snapshotState
public void snapshotState(org.apache.flink.runtime.state.FunctionSnapshotContext context) throws Exception - Specified by:
snapshotState
in interfaceorg.apache.flink.streaming.api.checkpoint.CheckpointedFunction
- Throws:
Exception
-
initializeState
public void initializeState(org.apache.flink.runtime.state.FunctionInitializationContext context) throws Exception - Specified by:
initializeState
in 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:
processElement
in 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:
onTimer
in classorg.apache.flink.streaming.api.functions.KeyedProcessFunction<Boolean,
TableChange, Trigger> - Throws:
Exception
-
close
- Specified by:
close
in interfaceorg.apache.flink.api.common.functions.RichFunction
- Overrides:
close
in classorg.apache.flink.api.common.functions.AbstractRichFunction
- Throws:
IOException
-