Top Description Fields Constructors Methods
reactor.netty.http

public final Class HttpResources

extends TcpResources
Class Inheritance
Imports
java.net.SocketAddress, java.time.Duration, java.util.concurrent.atomic.AtomicReference, java.util.function.BiFunction, .Function, io.netty.resolver.AddressResolverGroup, reactor.core.publisher.Mono, reactor.netty.resources.ConnectionProvider, .LoopResources, reactor.netty.tcp.TcpResources

Hold the default HTTP/1.x resources.
Author
Stephane Maldini
Since
0.6

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicReference<ConnectionProvider>
pack-priv static final AtomicReference<HttpResources>
pack-priv static final BiFunction<LoopResources, ConnectionProvider, HttpResources>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static void
disposeLoopsAndConnections()

Hides reactor.netty.tcp.TcpResources.disposeLoopsAndConnections.

Shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones.
public static Mono<Void>

Returns:

a Mono triggering the disposeLoopsAndConnections() when subscribed to.
disposeLoopsAndConnectionsLater
()

Hides reactor.netty.tcp.TcpResources.disposeLoopsAndConnectionsLater.

Prepare to shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones.
public static Mono<Void>

Returns:

a Mono triggering the disposeLoopsAndConnections() when subscribed to.
disposeLoopsAndConnectionsLater
(Duration
the quiet period as described above
quietPeriod
,
Duration
the maximum amount of time to wait until the disposal of the underlying LoopResources regardless if a task was submitted during the quiet period
timeout
)

Hides reactor.netty.tcp.TcpResources.disposeLoopsAndConnectionsLater.

Prepare to shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones.
public void
disposeWhen(SocketAddress
the remote address
remoteAddress
)

Overrides reactor.netty.tcp.TcpResources.disposeWhen.

Overrides default reactor.netty.resources.ConnectionProvider.disposeWhen.

Dispose all connection pools for the specified remote address.
public static HttpResources

Returns:

the global HTTP resources for event loops and pooling
get
()

Hides reactor.netty.tcp.TcpResources.get.

Return the global HTTP resources for event loops and pooling.
public AddressResolverGroup<?>
getOrCreateDefaultResolver()

Overrides reactor.netty.tcp.TcpResources.getOrCreateDefaultResolver.

Safely checks whether a name resolver exists and proceed with a creation if it does not exist.
public ConnectionProvider

Returns:

an existing or new ConnectionProvider for HTTP/2 traffic
getOrCreateHttp2ConnectionProvider
(Function<ConnectionProvider, ConnectionProvider>
the create function provides the current ConnectionProvider for HTTP/1.1 traffic in case some ConnectionProvider configuration is needed.
create
)

Safely checks whether a ConnectionProvider for HTTP/2 traffic exists and proceed with a creation if it does not exist.

public static HttpResources

Returns:

the global HTTP resources
reset
()

Hides reactor.netty.tcp.TcpResources.reset.

Reset http resources to default and return its instance.
public static HttpResources

Returns:

the global HTTP/1.x resources
set
(ConnectionProvider
a new ConnectionProvider to replace the current
provider
)

Hides reactor.netty.tcp.TcpResources.set.

Update pooling resources and return the global HTTP/1.x resources.
public static HttpResources

Returns:

the global HTTP/1.x resources
set
(LoopResources
a new LoopResources to replace the current
loops
)

Hides reactor.netty.tcp.TcpResources.set.

Update event loops resources and return the global HTTP/1.x resources.
Inherited from reactor.netty.tcp.TcpResources:
_dispose_disposeLateracquiredaemondisposedisposeLaterdisposeLatergetOrCreateisDisposedmaxConnectionsmaxConnectionsPerHostmutatenameonChannelonChannelClassonClientonServeronServerSelect

Field Detail

http2ConnectionProviderback to summary
pack-priv final AtomicReference<ConnectionProvider> http2ConnectionProvider
httpResourcesback to summary
pack-priv static final AtomicReference<HttpResources> httpResources
ON_HTTP_NEWback to summary
pack-priv static final BiFunction<LoopResources, ConnectionProvider, HttpResources> ON_HTTP_NEW

Constructor Detail

HttpResourcesback to summary
pack-priv HttpResources(LoopResources loops, ConnectionProvider provider)

Method Detail

disposeLoopsAndConnectionsback to summary
public static void disposeLoopsAndConnections()

Hides reactor.netty.tcp.TcpResources.disposeLoopsAndConnections.

Shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones. This method is NOT blocking. It is implemented as fire-and-forget. Use disposeLoopsAndConnectionsLater() when you need to observe the final status of the operation, combined with Mono#block() if you need to synchronously wait for the underlying resources to be disposed.

disposeLoopsAndConnectionsLaterback to summary
public static Mono<Void> disposeLoopsAndConnectionsLater()

Hides reactor.netty.tcp.TcpResources.disposeLoopsAndConnectionsLater.

Prepare to shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones. This only occurs when the returned Mono is subscribed to. The quiet period will be 2s and the timeout will be 15s

Returns:Mono<Void>

a Mono triggering the disposeLoopsAndConnections() when subscribed to.

disposeLoopsAndConnectionsLaterback to summary
public static Mono<Void> disposeLoopsAndConnectionsLater(Duration quietPeriod, Duration timeout)

Hides reactor.netty.tcp.TcpResources.disposeLoopsAndConnectionsLater.

Prepare to shutdown the global HttpResources without resetting them, effectively cleaning up associated resources without creating new ones. This only occurs when the returned Mono is subscribed to. It is guaranteed that the disposal of the underlying LoopResources will not happen before quietPeriod is over. If a task is submitted during the quietPeriod, it is guaranteed to be accepted and the quietPeriod will start over.

Parameters
quietPeriod:Duration

the quiet period as described above

timeout:Duration

the maximum amount of time to wait until the disposal of the underlying LoopResources regardless if a task was submitted during the quiet period

Returns:Mono<Void>

a Mono triggering the disposeLoopsAndConnections() when subscribed to.

Since
0.9.3
disposeWhenback to summary
public void disposeWhen(SocketAddress remoteAddress)

Overrides reactor.netty.tcp.TcpResources.disposeWhen.

Overrides default reactor.netty.resources.ConnectionProvider.disposeWhen.

Doc from reactor.netty.tcp.TcpResources.disposeWhen.

Dispose all connection pools for the specified remote address.

As opposed to dispose(), this method delegates to the underlying connection provider. It has a global effect and removes all connection pools for this remote address from the global TCP resources (making it closer to disposeLoopsAndConnections() than to dispose()).

Parameters
remoteAddress:SocketAddress

the remote address

Annotations
@Override
getback to summary
public static HttpResources get()

Hides reactor.netty.tcp.TcpResources.get.

Return the global HTTP resources for event loops and pooling.

Returns:HttpResources

the global HTTP resources for event loops and pooling

getOrCreateDefaultResolverback to summary
public AddressResolverGroup<?> getOrCreateDefaultResolver()

Overrides reactor.netty.tcp.TcpResources.getOrCreateDefaultResolver.

Doc from reactor.netty.tcp.TcpResources.getOrCreateDefaultResolver.

Safely checks whether a name resolver exists and proceed with a creation if it does not exist. The name resolver uses as an event loop group the LoopResources that are configured. Guarantees that always one and the same instance is returned for a given LoopResources and if the LoopResources is updated the name resolver is also updated.

Returns:AddressResolverGroup<?>

an existing or new AddressResolverGroup

Annotations
@Override
getOrCreateHttp2ConnectionProviderback to summary
public ConnectionProvider getOrCreateHttp2ConnectionProvider(Function<ConnectionProvider, ConnectionProvider> create)

Safely checks whether a ConnectionProvider for HTTP/2 traffic exists and proceed with a creation if it does not exist.

Parameters
create:Function<ConnectionProvider, ConnectionProvider>

the create function provides the current ConnectionProvider for HTTP/1.1 traffic in case some ConnectionProvider configuration is needed.

Returns:ConnectionProvider

an existing or new ConnectionProvider for HTTP/2 traffic

Since
1.0.16
resetback to summary
public static HttpResources reset()

Hides reactor.netty.tcp.TcpResources.reset.

Reset http resources to default and return its instance.

Returns:HttpResources

the global HTTP resources

setback to summary
public static HttpResources set(ConnectionProvider provider)

Hides reactor.netty.tcp.TcpResources.set.

Update pooling resources and return the global HTTP/1.x resources.

Note

The previous ConnectionProvider will be disposed.

Parameters
provider:ConnectionProvider

a new ConnectionProvider to replace the current

Returns:HttpResources

the global HTTP/1.x resources

setback to summary
public static HttpResources set(LoopResources loops)

Hides reactor.netty.tcp.TcpResources.set.

Update event loops resources and return the global HTTP/1.x resources.

Note

The previous LoopResources will be disposed.

Parameters
loops:LoopResources

a new LoopResources to replace the current

Returns:HttpResources

the global HTTP/1.x resources