public class TcpResources extends Object implements ConnectionProvider, LoopResources
Disposable.Composite, Disposable.SwapDEFAULT_POOL_ACQUIRE_TIMEOUT, DEFAULT_POOL_MAX_CONNECTIONSDEFAULT_IO_SELECT_COUNT, DEFAULT_IO_WORKER_COUNT, DEFAULT_NATIVE| Modifier | Constructor and Description |
|---|---|
protected |
TcpResources(LoopResources defaultLoops,
ConnectionProvider defaultProvider) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_dispose()
Dispose underlying resources
|
protected Mono<Void> |
_disposeLater()
Dispose underlying resources in a listenable fashion.
|
Mono<? extends Connection> |
acquire(Bootstrap bootstrap)
Return an existing or new
Connection on subscribe. |
boolean |
daemon()
return true if
EventLoopGroup should not be shutdown |
void |
dispose() |
Mono<Void> |
disposeLater()
Returns a Mono that triggers the disposal of underlying resources when subscribed to.
|
static void |
disposeLoopsAndConnections()
Shutdown the global
TcpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
static Mono<Void> |
disposeLoopsAndConnectionsLater()
Prepare to shutdown the global
TcpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
void |
disposeWhen(SocketAddress address) |
static TcpResources |
get()
Return the global HTTP resources for event loops and pooling
|
protected static <T extends TcpResources> |
getOrCreate(AtomicReference<T> ref,
LoopResources loops,
ConnectionProvider provider,
java.util.function.BiFunction<LoopResources,ConnectionProvider,T> onNew,
String name)
Safely check if existing resource exist and proceed to update/cleanup if new
resources references are passed.
|
boolean |
isDisposed() |
Class<? extends Channel> |
onChannel(EventLoopGroup group)
Callback for client or generic channel factory selection.
|
EventLoopGroup |
onClient(boolean useNative)
Callback for client
EventLoopGroup creation. |
Class<? extends DatagramChannel> |
onDatagramChannel(EventLoopGroup group)
Callback for UDP channel factory selection.
|
EventLoopGroup |
onServer(boolean useNative)
Callback for server
EventLoopGroup creation. |
Class<? extends ServerChannel> |
onServerChannel(EventLoopGroup group)
Callback for server channel factory selection.
|
EventLoopGroup |
onServerSelect(boolean useNative)
Create a server select
EventLoopGroup for servers to be used |
boolean |
preferNative()
Return true if should default to native
EventLoopGroup and Channel |
static TcpResources |
reset()
Reset http resources to default and return its instance
|
static TcpResources |
set(ConnectionProvider provider)
Update provider resources and return the global HTTP resources
|
static TcpResources |
set(LoopResources loops)
Update pooling resources and return the global HTTP resources
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitelastic, fixed, fixed, fixed, maxConnections, newConnectioncolocate, create, create, createprotected TcpResources(LoopResources defaultLoops, ConnectionProvider defaultProvider)
public static TcpResources get()
public static TcpResources set(ConnectionProvider provider)
public static TcpResources set(LoopResources loops)
public static TcpResources reset()
public static void disposeLoopsAndConnections()
TcpResources without resetting them,
effectively cleaning up associated resources without creating new ones.public static Mono<Void> disposeLoopsAndConnectionsLater()
TcpResources without resetting them,
effectively cleaning up associated resources without creating new ones. This only
occurs when the returned Mono is subscribed to.Mono triggering the disposeLoopsAndConnections() when subscribed to.public void dispose()
dispose in interface Disposabledispose in interface ConnectionProviderdispose in interface LoopResourcespublic Mono<Void> disposeLater()
ConnectionProviderdisposeLater in interface ConnectionProviderdisposeLater in interface LoopResourcesprotected void _dispose()
protected Mono<Void> _disposeLater()
public boolean isDisposed()
isDisposed in interface Disposablepublic void disposeWhen(@NonNull SocketAddress address)
disposeWhen in interface ConnectionProviderpublic Mono<? extends Connection> acquire(Bootstrap bootstrap)
ConnectionProviderConnection on subscribe.acquire in interface ConnectionProviderbootstrap - the client connection BootstrapMono of Connectionpublic Class<? extends Channel> onChannel(EventLoopGroup group)
LoopResourcesonChannel in interface LoopResourcesgroup - the source EventLoopGroup to assign a loop fromClass target for the underlying Channel factorypublic EventLoopGroup onClient(boolean useNative)
LoopResourcesEventLoopGroup creation.onClient in interface LoopResourcesuseNative - should use native group if current LoopResources.preferNative() is also
trueEventLoopGrouppublic Class<? extends DatagramChannel> onDatagramChannel(EventLoopGroup group)
LoopResourcesonDatagramChannel in interface LoopResourcesgroup - the source EventLoopGroup to assign a loop fromClass target for the underlying Channel factorypublic EventLoopGroup onServer(boolean useNative)
LoopResourcesEventLoopGroup creation.onServer in interface LoopResourcesuseNative - should use native group if current LoopResources.preferNative() is also
trueEventLoopGrouppublic Class<? extends ServerChannel> onServerChannel(EventLoopGroup group)
LoopResourcesonServerChannel in interface LoopResourcesgroup - the source EventLoopGroup to assign a loop fromClass target for the underlying ServerChannel factorypublic EventLoopGroup onServerSelect(boolean useNative)
LoopResourcesEventLoopGroup for servers to be usedonServerSelect in interface LoopResourcesuseNative - should use native group if current LoopResources.preferNative() is also
trueEventLoopGrouppublic boolean preferNative()
LoopResourcesEventLoopGroup and ChannelpreferNative in interface LoopResourcesEventLoopGroup and Channelpublic boolean daemon()
LoopResourcesEventLoopGroup should not be shutdowndaemon in interface LoopResourcesEventLoopGroup should not be shutdownprotected static <T extends TcpResources> T getOrCreate(AtomicReference<T> ref, @Nullable LoopResources loops, @Nullable ConnectionProvider provider, java.util.function.BiFunction<LoopResources,ConnectionProvider,T> onNew, String name)
T - the reified type of TcpResourcesref - the resources atomic referenceloops - the eventual new LoopResourcesprovider - the eventual new ConnectionProvideronNew - a TcpResources factoryname - a name for resourcesTcpResources