public class UdpResources extends Object implements LoopResources
Disposable.Composite, Disposable.Swap
DEFAULT_IO_SELECT_COUNT, DEFAULT_IO_WORKER_COUNT, DEFAULT_NATIVE, DEFAULT_SHUTDOWN_QUIET_PERIOD, DEFAULT_SHUTDOWN_TIMEOUT
Modifier | Constructor and Description |
---|---|
protected |
UdpResources(LoopResources defaultLoops) |
Modifier and Type | Method and Description |
---|---|
protected void |
_dispose()
Dispose underlying resources
|
protected Mono<Void> |
_disposeLater(Duration quietPeriod,
Duration timeout)
Dispose underlying resources in a listenable fashion.
|
boolean |
daemon()
return true if
EventLoopGroup should not be shutdown |
void |
dispose()
This has a
NOOP implementation by default in order to prevent unintended disposal of
the global UDP resources which has a longer lifecycle than regular LoopResources . |
Mono<Void> |
disposeLater()
This has a
NOOP implementation by default in order to prevent unintended disposal of
the global UDP resources which has a longer lifecycle than regular LoopResources . |
Mono<Void> |
disposeLater(Duration quietPeriod,
Duration timeout)
This has a
NOOP implementation by default in order to prevent unintended disposal of
the global UDP resources which has a longer lifecycle than regular LoopResources . |
static UdpResources |
get()
Return the global UDP resources for pooling
|
protected static UdpResources |
getOrCreate(LoopResources loops,
Function<LoopResources,UdpResources> onNew,
String name)
Safely check if existing resource exist and proceed to update/cleanup if new
resources references are passed.
|
boolean |
isDisposed() |
<CHANNEL extends Channel> |
onChannel(Class<CHANNEL> channelType,
EventLoopGroup group)
Callback for a
Channel selection. |
<CHANNEL extends Channel> |
onChannelClass(Class<CHANNEL> channelType,
EventLoopGroup group)
Callback for a
Channel class selection. |
EventLoopGroup |
onClient(boolean useNative)
Callback for client
EventLoopGroup creation. |
EventLoopGroup |
onServer(boolean useNative)
Callback for server
EventLoopGroup creation,
this is the EventLoopGroup for the child channel. |
EventLoopGroup |
onServerSelect(boolean useNative)
Callback for server select
EventLoopGroup creation,
this is the EventLoopGroup for the acceptor channel. |
static UdpResources |
reset()
Reset UDP resources to default and return its instance
|
static UdpResources |
set(LoopResources loops)
Update event loops resources and return the global UDP resources.
|
static void |
shutdown()
Shutdown the global
UdpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
static Mono<Void> |
shutdownLater()
Prepare to shutdown the global
UdpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
static Mono<Void> |
shutdownLater(Duration quietPeriod,
Duration timeout)
Prepare to shutdown the global
UdpResources without resetting them,
effectively cleaning up associated resources without creating new ones. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
colocate, create, create, create, create, hasNativeSupport
protected UdpResources(LoopResources defaultLoops)
public static UdpResources get()
public static UdpResources reset()
public static UdpResources set(LoopResources loops)
LoopResources
will be disposed.loops
- a new LoopResources
to replace the currentpublic static void shutdown()
UdpResources
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 shutdownLater()
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.public static Mono<Void> shutdownLater()
UdpResources
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
Mono
triggering the shutdown()
when subscribed to.public static Mono<Void> shutdownLater(Duration quietPeriod, Duration timeout)
UdpResources
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.quietPeriod
- the quiet period as described abovetimeout
- the maximum amount of time to wait until the disposal of the underlying
LoopResources regardless if a task was submitted during the quiet periodMono
triggering the shutdown()
when subscribed to.public boolean daemon()
LoopResources
EventLoopGroup
should not be shutdowndaemon
in interface LoopResources
EventLoopGroup
should not be shutdownpublic void dispose()
NOOP
implementation by default in order to prevent unintended disposal of
the global UDP resources which has a longer lifecycle than regular LoopResources
.
If a disposal of the global UDP resources is needed, shutdown()
should be used instead.dispose
in interface Disposable
dispose
in interface LoopResources
public Mono<Void> disposeLater()
NOOP
implementation by default in order to prevent unintended disposal of
the global UDP resources which has a longer lifecycle than regular LoopResources
.
If a disposal of the global UDP resources is needed, shutdownLater()
should be used instead.disposeLater
in interface LoopResources
public Mono<Void> disposeLater(Duration quietPeriod, Duration timeout)
NOOP
implementation by default in order to prevent unintended disposal of
the global UDP resources which has a longer lifecycle than regular LoopResources
.
If a disposal of the global UDP resources is needed, shutdownLater(Duration, Duration)
should be used instead.disposeLater
in interface LoopResources
quietPeriod
- the quiet period as described abovetimeout
- the maximum amount of time to wait until the disposal of the underlying
LoopResources regardless if a task was submitted during the quiet periodpublic boolean isDisposed()
isDisposed
in interface Disposable
public <CHANNEL extends Channel> CHANNEL onChannel(Class<CHANNEL> channelType, EventLoopGroup group)
LoopResources
Channel
selection.onChannel
in interface LoopResources
CHANNEL
- the Channel
implementationchannelType
- the channel typegroup
- the source EventLoopGroup
to assign a loop fromChannel
instancepublic <CHANNEL extends Channel> Class<? extends CHANNEL> onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group)
LoopResources
Channel
class selection.onChannelClass
in interface LoopResources
CHANNEL
- the Channel
implementationchannelType
- the channel typegroup
- the source EventLoopGroup
to assign a loop fromChannel
classpublic EventLoopGroup onClient(boolean useNative)
LoopResources
EventLoopGroup
creation.onClient
in interface LoopResources
useNative
- should use native group if current environment supports itEventLoopGroup
public EventLoopGroup onServer(boolean useNative)
LoopResources
EventLoopGroup
creation,
this is the EventLoopGroup
for the child channel.onServer
in interface LoopResources
useNative
- should use native group if current environment supports itEventLoopGroup
public EventLoopGroup onServerSelect(boolean useNative)
LoopResources
EventLoopGroup
creation,
this is the EventLoopGroup
for the acceptor channel.onServerSelect
in interface LoopResources
useNative
- should use native group if current environment supports itEventLoopGroup
protected void _dispose()
protected Mono<Void> _disposeLater(Duration quietPeriod, Duration timeout)
quietPeriod
is over. If a task is submitted during the quietPeriod
,
it is guaranteed to be accepted and the quietPeriod
will start over.quietPeriod
- the quiet period as described abovetimeout
- the maximum amount of time to wait until the disposal of the underlying
LoopResources regardless if a task was submitted during the quiet periodprotected static UdpResources getOrCreate(@Nullable LoopResources loops, Function<LoopResources,UdpResources> onNew, String name)
loops
- the eventual new LoopResources
onNew
- a UdpResources
factoryname
- a name for resourcesUdpResources