Package org.eclipse.jetty.util.component
Interface Graceful
-
- All Known Subinterfaces:
Connector
,NetworkConnector
- All Known Implementing Classes:
AbstractConnector
,AbstractHTTP2ServerConnectionFactory.HTTP2SessionContainer
,AbstractNetworkConnector
,AntWebAppContext
,ContextHandler
,Graceful.Shutdown
,HTTP3ServerConnector
,HttpSpiContextHandler
,LocalConnector
,MavenServerConnector
,MavenWebAppContext
,MovedContextHandler
,NetworkTrafficServerConnector
,QuicServerConnector
,QuicSessionContainer
,ServerConnector
,ServletContextHandler
,SessionTracker
,SessionTracker
,StatisticsHandler
,UnixSocketConnector
,WebAppContext
public interface Graceful
Jetty components that wish to be part of a Graceful shutdown implement this interface so that the
shutdown()
method will be called to initiate a shutdown. Shutdown operations can fall into the following categories:- Preventing new load from being accepted (eg connectors stop accepting connections)
- Preventing existing load expanding (eg stopping existing connections accepting new requests)
- Waiting for existing load to complete (eg waiting for active request count to reduce to 0)
- Performing cleanup operations that may take time (eg closing an SSL connection)
The
CompletableFuture
returned by the the shutdown call will be completed to indicate the shutdown operation is completed. Some shutdown operations may be instantaneous and always return a completed future.Graceful shutdown is typically orchestrated by the doStop methods of Server or ContextHandler (for a full or partial shutdown respectively).
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Graceful.Shutdown
A utility class to assist implementing the Graceful interface.static interface
Graceful.ThrowingRunnable
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
isShutdown()
java.util.concurrent.CompletableFuture<java.lang.Void>
shutdown()
Shutdown the component.static java.util.concurrent.CompletableFuture<java.lang.Void>
shutdown(Container component)
Utility method to shutdown all Gracefuls within a container.static java.util.concurrent.CompletableFuture<java.lang.Void>
shutdown(Graceful.ThrowingRunnable runnable)
Utility method to execute aGraceful.ThrowingRunnable
in a new daemon thread and be notified of the result in aCompletableFuture
.
-
-
-
Method Detail
-
shutdown
java.util.concurrent.CompletableFuture<java.lang.Void> shutdown()
Shutdown the component. When this method returns, the component should not accept any new load.- Returns:
- A future that is completed once all load on the component is completed
-
isShutdown
boolean isShutdown()
- Returns:
- True if
shutdown()
has been called.
-
shutdown
static java.util.concurrent.CompletableFuture<java.lang.Void> shutdown(Container component)
Utility method to shutdown all Gracefuls within a container.- Parameters:
component
- The container in which to look forGraceful
s- Returns:
- A
CompletableFuture
that is complete once all returns fromshutdown()
of the containedGraceful
s are complete.
-
shutdown
static java.util.concurrent.CompletableFuture<java.lang.Void> shutdown(Graceful.ThrowingRunnable runnable)
Utility method to execute aGraceful.ThrowingRunnable
in a new daemon thread and be notified of the result in aCompletableFuture
.- Parameters:
runnable
- the ThrowingRunnable to run.- Returns:
- the CompletableFuture to be notified when the runnable either completes or fails.
-
-