java.lang.Object
net.i2p.router.tasks.GracefulShutdown
All Implemented Interfaces:
Runnable

public class GracefulShutdownextends Object implements Runnable
GracefulShutdown manages the router's graceful shutdown/restart lifecycle. Uses configurable timings to control when to re-check state and how long to wait before finalizing a restart/shutdown after signaling.
  • Field Details

    • _context

      private final RouterContext _context
      The router being shut down.
    • running

      private volatile boolean running
      Cleared to let the loop finish.
    • _wakeLock

      private final Object _wakeLock
      Held while waiting between passes.
    • RESTART_DELAY_MS

      private static final int RESTART_DELAY_MS
      Delay before finalizing a restart/shutdown after a signaling condition is met (ms).
      See Also:
    • CHECK_STATUS_INTERVAL_MS

      private static final int CHECK_STATUS_INTERVAL_MS
      Interval between status checks while a restart/shutdown is in progress (ms).
      See Also:
  • Constructor Details

    • GracefulShutdown

      public GracefulShutdown(RouterContext ctx)
      Create a new graceful shutdown handler.
      Parameters:
      ctx - the router context for accessing router state and services
  • Method Details

    • getWakeLock

      public Object getWakeLock()
      The lock object for wake/sleep coordination with the shutdown detector.
      Returns:
      the shared lock object
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • wakeUp

      public void wakeUp()
      Wake up the shutdown thread when a relevant state change occurs. This method should be called when the router's shutdown state changes to prompt the graceful shutdown thread to re-evaluate the current situation.
    • stop

      public void stop()
      Stop the shutdown thread gracefully. Sets the running flag to false and wakes up the thread to allow it to exit cleanly. This should be called during router shutdown to properly terminate the graceful shutdown monitor.