Class MasterHooks
- java.lang.Object
-
- org.apache.flink.runtime.checkpoint.hooks.MasterHooks
-
public class MasterHooks extends Object
Collection of methods to deal with checkpoint master hooks.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
close(Collection<MasterTriggerRestoreHook<?>> hooks, org.slf4j.Logger log)
Closes the master hooks.static void
reset(Collection<MasterTriggerRestoreHook<?>> hooks, org.slf4j.Logger log)
Resets the master hooks.static void
restoreMasterHooks(Map<String,MasterTriggerRestoreHook<?>> masterHooks, Collection<MasterState> states, long checkpointId, boolean allowUnmatchedState, org.slf4j.Logger log)
Calls the restore method given checkpoint master hooks and passes the given master state to them where state with a matching name is found.static <T> CompletableFuture<MasterState>
triggerHook(MasterTriggerRestoreHook<T> hook, long checkpointId, long timestamp, Executor executor)
Trigger master hook and return a completable future with state.static <T> MasterTriggerRestoreHook<T>
wrapHook(MasterTriggerRestoreHook<T> hook, ClassLoader userClassLoader)
Wraps a hook such that the user-code classloader is applied when the hook is invoked.
-
-
-
Method Detail
-
reset
public static void reset(Collection<MasterTriggerRestoreHook<?>> hooks, org.slf4j.Logger log) throws org.apache.flink.util.FlinkException
Resets the master hooks.- Parameters:
hooks
- The hooks to reset- Throws:
org.apache.flink.util.FlinkException
- Thrown, if the hooks throw an exception.
-
close
public static void close(Collection<MasterTriggerRestoreHook<?>> hooks, org.slf4j.Logger log)
Closes the master hooks.- Parameters:
hooks
- The hooks to close
-
triggerHook
public static <T> CompletableFuture<MasterState> triggerHook(MasterTriggerRestoreHook<T> hook, long checkpointId, long timestamp, Executor executor)
Trigger master hook and return a completable future with state.- Type Parameters:
T
- The type of data produced by the hook- Parameters:
hook
- The master hook givencheckpointId
- The checkpoint ID of the triggering checkpointtimestamp
- The (informational) timestamp for the triggering checkpointexecutor
- An executor that can be used for asynchronous I/O calls- Returns:
- the completable future with state
-
restoreMasterHooks
public static void restoreMasterHooks(Map<String,MasterTriggerRestoreHook<?>> masterHooks, Collection<MasterState> states, long checkpointId, boolean allowUnmatchedState, org.slf4j.Logger log) throws org.apache.flink.util.FlinkException
Calls the restore method given checkpoint master hooks and passes the given master state to them where state with a matching name is found.If state is found and no hook with the same name is found, the method throws an exception, unless the
allowUnmatchedState
flag is set.- Parameters:
masterHooks
- The hooks to call restore onstates
- The state to pass to the hookscheckpointId
- The checkpoint ID of the restored checkpointallowUnmatchedState
- If true, the method fails if not all states are picked up by a hook.log
- The logger for log messages- Throws:
org.apache.flink.util.FlinkException
- Thrown, if the hooks throw an exception, or the state+ deserialization fails.
-
wrapHook
public static <T> MasterTriggerRestoreHook<T> wrapHook(MasterTriggerRestoreHook<T> hook, ClassLoader userClassLoader)
Wraps a hook such that the user-code classloader is applied when the hook is invoked.- Parameters:
hook
- the hook to wrapuserClassLoader
- the classloader to use
-
-