Top Description Inners Methods
org.eclipse.jetty.util.component

public Interface Graceful

Known Direct Implementers
org.eclipse.jetty.util.component.Graceful.Shutdown
Imports
java.util.ArrayList, .Collections, .List, java.util.concurrent.CompletableFuture, .Future, java.util.concurrent.atomic.AtomicReference, org.slf4j.Logger, .LoggerFactory

Jetty components that wish to be part of a Graceful shutdown implement this interface so that the Graceful#shutdown() method will be called to initiate a shutdown. Shutdown operations can fall into the following categories:

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 and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
Graceful.Shutdown

A utility class to assist implementing the Graceful interface.

public static interface

Method Summary

Modifier and TypeMethod and Description
public boolean
isShutdown()

Returns: True if shutdown() has been called.

public CompletableFuture<Void>

Returns:

A future that is completed once all load on the component is completed
shutdown
()

Shutdown the component.

public static CompletableFuture<Void>

Returns:

A CompletableFuture that is complete once all returns from Graceful#shutdown() of the contained Gracefuls are complete.
shutdown
(Container
The container in which to look for Gracefuls
component
)

Utility method to shutdown all Gracefuls within a container.

public static CompletableFuture<Void>

Returns:

the CompletableFuture to be notified when the runnable either completes or fails.
shutdown
(Graceful.ThrowingRunnable
the ThrowingRunnable to run.
runnable
)

Utility method to execute a ThrowingRunnable in a new daemon thread and be notified of the result in a CompletableFuture.

Method Detail

isShutdownback to summary
public boolean isShutdown()
Returns:boolean

True if shutdown() has been called.

shutdownback to summary
public CompletableFuture<Void> shutdown()

Shutdown the component. When this method returns, the component should not accept any new load.

Returns:CompletableFuture<Void>

A future that is completed once all load on the component is completed

shutdownback to summary
public static CompletableFuture<Void> shutdown(Container component)

Utility method to shutdown all Gracefuls within a container.

Parameters
component:Container

The container in which to look for Gracefuls

Returns:CompletableFuture<Void>

A CompletableFuture that is complete once all returns from Graceful#shutdown() of the contained Gracefuls are complete.

shutdownback to summary
public static CompletableFuture<Void> shutdown(Graceful.ThrowingRunnable runnable)

Utility method to execute a ThrowingRunnable in a new daemon thread and be notified of the result in a CompletableFuture.

Parameters
runnable:Graceful.ThrowingRunnable

the ThrowingRunnable to run.

Returns:CompletableFuture<Void>

the CompletableFuture to be notified when the runnable either completes or fails.

org.eclipse.jetty.util.component back to summary

public abstract Class Graceful.Shutdown

extends Object
implements Graceful
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.component.Graceful

A utility class to assist implementing the Graceful interface. The isShutdownDone() method should be implemented to check if the CompletableFuture returned by shutdown() should be completed or not. The check() method should be called when any state is changed which may complete the shutdown.

Field Summary

Modifier and TypeField and Description
pack-priv final Object
pack-priv final AtomicReference<CompletableFuture<Void>>

Constructor Summary

AccessConstructor and Description
protected
Shutdown(Object component)

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

This method can be called after shutdown() has been called, but before check() has been called with isShutdownDone() having returned true to cancel the effects of the shutdown() call.

public void
check()

This method should be called whenever the components state has been updated.

public boolean
public abstract boolean
isShutdownDone()

Returns: True if the component is shutdown and has no remaining load.

public CompletableFuture<Void>
shutdown()

Implements org.eclipse.jetty.util.component.Graceful.shutdown.

Shutdown the component.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_componentback to summary
pack-priv final Object _component
_doneback to summary
pack-priv final AtomicReference<CompletableFuture<Void>> _done

Constructor Detail

Shutdownback to summary
protected Shutdown(Object component)

Method Detail

cancelback to summary
public void cancel()

This method can be called after shutdown() has been called, but before check() has been called with isShutdownDone() having returned true to cancel the effects of the shutdown() call.

checkback to summary
public void check()

This method should be called whenever the components state has been updated. If shutdown() has been called, then isShutdownDone() is called by this method and if it returns true then the Future returned by shutdown() is completed.

isShutdownback to summary
public boolean isShutdown()

Implements org.eclipse.jetty.util.component.Graceful.isShutdown.

Returns:boolean

Doc from org.eclipse.jetty.util.component.Graceful.isShutdown.

True if shutdown() has been called.

Annotations
@Override
isShutdownDoneback to summary
public abstract boolean isShutdownDone()
Returns:boolean

True if the component is shutdown and has no remaining load.

shutdownback to summary
public CompletableFuture<Void> shutdown()

Implements org.eclipse.jetty.util.component.Graceful.shutdown.

Doc from org.eclipse.jetty.util.component.Graceful.shutdown.

Shutdown the component. When this method returns, the component should not accept any new load.

Returns:CompletableFuture<Void>

A future that is completed once all load on the component is completed

Annotations
@Override
org.eclipse.jetty.util.component back to summary

public Interface Graceful.ThrowingRunnable

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public void
run()

Method Detail

runback to summary
public void run() throws Exception