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 Details

    • 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 given
      checkpointId - The checkpoint ID of the triggering checkpoint
      timestamp - The (informational) timestamp for the triggering checkpoint
      executor - 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 on
      states - The state to pass to the hooks
      checkpointId - The checkpoint ID of the restored checkpoint
      allowUnmatchedState - 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 wrap
      userClassLoader - the classloader to use