Interface GracefulShutdownCapable

All Known Subinterfaces:
NettyEmbeddedServer
All Known Implementing Classes:
ExecutorFactory, NettyHttpServer, PipeliningServerHandler

public interface GracefulShutdownCapable
Interface implemented by beans that support graceful shutdown.
Since:
4.9.0
Author:
Jonas Konrad
  • Method Details

    • shutdownGracefully

      @NonNull CompletionStage<?> shutdownGracefully()
      Trigger a graceful shutdown. The returned CompletionStage will complete when the shutdown is complete.

      Note that the completion of the returned future may be user-dependent. If a user does not close their connection, the future may never terminate. Always add a timeout for a hard shutdown.

      This method should not throw an exception, nor should the returned stage complete exceptionally. Just log an error instead.

      Returns:
      A future that completes when this bean is fully shut down
    • reportActiveTasks

      default OptionalLong reportActiveTasks()
      After a call to shutdownGracefully() report the state of the shutdown. If shutdownGracefully() has not been called the behavior of this method is undefined.
      Returns:
      The current number of still-active tasks before the shutdown completes, or Optional.empty() if no state can be reported
    • allOf

      static @NonNull CompletionStage<?> allOf(@NonNull Stream<CompletionStage<?>> stages)
      Combine the given futures.
      Parameters:
      stages - The input futures
      Returns:
      A future that completes when all inputs have completed
    • shutdownAll

      static @NonNull CompletionStage<?> shutdownAll(@NonNull Stream<? extends GracefulShutdownCapable> stages)
      Shutdown all the given lifecycles.
      Parameters:
      stages - The input lifecycles
      Returns:
      A future that completes when all inputs have completed shutdown
    • combineActiveTasks

      static @NonNull OptionalLong combineActiveTasks(@NonNull Iterable<? extends GracefulShutdownCapable> delegates)