Class ApplicationShutdownHook

java.lang.Object
io.sbk.utils.ApplicationShutdownHook

public final class ApplicationShutdownHook extends Object
Registers a bounded JVM shutdown hook for an SBK application.

The actual application cleanup runs on a separate daemon thread. The JVM hook waits for it only for a bounded interval, ensuring that a blocked storage driver, SSH operation, logger, or network server cannot prevent the process from terminating after SIGINT or SIGTERM.

  • Method Details

    • register

      public static Thread register(String applicationName, Runnable cleanup)
      Registers a shutdown hook for an application benchmark.
      Parameters:
      applicationName - application name used in lifecycle messages
      cleanup - cleanup operation, normally benchmark.stop()
      Returns:
      the registered hook, which can be removed after normal completion
    • remove

      public static void remove(Thread hook)
      Removes a previously registered hook after normal application shutdown.

      If JVM shutdown has already started, hook removal is no longer legal; this method deliberately ignores that race because the hook is already performing the requested cleanup.

      Parameters:
      hook - hook returned by register(String, Runnable)