Class ShutdownManager

java.lang.Object
org.keycloak.connections.infinispan.shutdown.ShutdownManager

public class ShutdownManager extends Object
Manages an ordered list of ShutdownListener instances that are notified sequentially when the server shuts down.

Listeners are invoked in registration order. Each listener may block the calling thread to delay shutdown until its condition is met (e.g. waiting for a stable cache topology). All listeners share the same deadline, so the total shutdown time is bounded regardless of how many listeners are registered. It is recommended to respect it.

If onShutdownStarted(Instant) is called before onShutdown() (e.g. from a shutdown delay event), the deadline is anchored to that earlier timestamp. Otherwise, it falls back to the current time when onShutdown() is invoked.

This class is thread-safe: listeners can be added or removed concurrently.

  • Constructor Details

    • ShutdownManager

      public ShutdownManager(long shutdownDelay, long shutdownTimeout)
  • Method Details

    • addListener

      public void addListener(ShutdownListener listener)
    • removeListener

      public void removeListener(ShutdownListener listener)
    • onShutdown

      public void onShutdown()
    • onShutdownStarted

      public void onShutdownStarted(Instant shutdownStartTime)
      Records the instant the shutdown sequence began (e.g. when the shutdown delay was initiated by Quarkus).
      Parameters:
      shutdownStartTime - The instant the shutdown was initiated.