Package reactor.netty.udp
Class UdpResources
java.lang.Object
reactor.netty.udp.UdpResources
- All Implemented Interfaces:
Disposable
,LoopResources
Hold the default UDP resources.
- Author:
- Violeta Georgieva
-
Nested Class Summary
Nested classes/interfaces inherited from interface reactor.core.Disposable
Disposable.Composite, Disposable.Swap
-
Field Summary
Fields inherited from interface reactor.netty.resources.LoopResources
DEFAULT_IO_SELECT_COUNT, DEFAULT_IO_WORKER_COUNT, DEFAULT_NATIVE, DEFAULT_SHUTDOWN_QUIET_PERIOD, DEFAULT_SHUTDOWN_TIMEOUT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
_dispose()
Dispose underlying resources._disposeLater
(Duration quietPeriod, Duration timeout) Dispose underlying resources in a listenable fashion.boolean
daemon()
return true ifEventLoopGroup
should not be shutdown.void
dispose()
This has aNOOP
implementation by default in order to prevent unintended disposal of the global UDP resources which has a longer lifecycle than regularLoopResources
.This has aNOOP
implementation by default in order to prevent unintended disposal of the global UDP resources which has a longer lifecycle than regularLoopResources
.disposeLater
(Duration quietPeriod, Duration timeout) This has aNOOP
implementation by default in order to prevent unintended disposal of the global UDP resources which has a longer lifecycle than regularLoopResources
.static UdpResources
get()
Return the global UDP resources for pooling.protected static UdpResources
getOrCreate
(@Nullable 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
<CHANNEL extends Channel>
CHANNELonChannel
(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannel
selection.onChannelClass
(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannel
class selection.onClient
(boolean useNative) Callback for clientEventLoopGroup
creation.onServer
(boolean useNative) Callback for serverEventLoopGroup
creation, this is theEventLoopGroup
for the child channel.onServerSelect
(boolean useNative) Callback for server selectEventLoopGroup
creation, this is theEventLoopGroup
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 globalUdpResources
without resetting them, effectively cleaning up associated resources without creating new ones.Prepare to shutdown the globalUdpResources
without resetting them, effectively cleaning up associated resources without creating new ones.shutdownLater
(Duration quietPeriod, Duration timeout) Prepare to shutdown the globalUdpResources
without resetting them, effectively cleaning up associated resources without creating new ones.
-
Constructor Details
-
UdpResources
-
-
Method Details
-
get
Return the global UDP resources for pooling.- Returns:
- the global UDP resources for pooling
-
reset
Reset UDP resources to default and return its instance.- Returns:
- the global UDP resources
-
set
Update event loops resources and return the global UDP resources. Note: The previousLoopResources
will be disposed.- Parameters:
loops
- a newLoopResources
to replace the current- Returns:
- the global UDP resources
-
shutdown
public static void shutdown()Shutdown the globalUdpResources
without resetting them, effectively cleaning up associated resources without creating new ones. This method is NOT blocking. It is implemented as fire-and-forget. UseshutdownLater()
when you need to observe the final status of the operation, combined withMono.block()
if you need to synchronously wait for the underlying resources to be disposed. -
shutdownLater
Prepare to shutdown the globalUdpResources
without resetting them, effectively cleaning up associated resources without creating new ones. This only occurs when the returnedMono
is subscribed to. The quiet period will be2s
and the timeout will be15s
- Returns:
- a
Mono
triggering theshutdown()
when subscribed to.
-
shutdownLater
Prepare to shutdown the globalUdpResources
without resetting them, effectively cleaning up associated resources without creating new ones. This only occurs when the returnedMono
is subscribed to. It is guaranteed that the disposal of the underlying LoopResources will not happen beforequietPeriod
is over. If a task is submitted during thequietPeriod
, it is guaranteed to be accepted and thequietPeriod
will start over.- Parameters:
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 period- Returns:
- a
Mono
triggering theshutdown()
when subscribed to. - Since:
- 0.9.3
-
daemon
public boolean daemon()Description copied from interface:LoopResources
return true ifEventLoopGroup
should not be shutdown.- Specified by:
daemon
in interfaceLoopResources
- Returns:
- true if
EventLoopGroup
should not be shutdown
-
dispose
public void dispose()This has aNOOP
implementation by default in order to prevent unintended disposal of the global UDP resources which has a longer lifecycle than regularLoopResources
. If a disposal of the global UDP resources is needed,shutdown()
should be used instead.- Specified by:
dispose
in interfaceDisposable
- Specified by:
dispose
in interfaceLoopResources
-
disposeLater
This has aNOOP
implementation by default in order to prevent unintended disposal of the global UDP resources which has a longer lifecycle than regularLoopResources
. If a disposal of the global UDP resources is needed,shutdownLater()
should be used instead.- Specified by:
disposeLater
in interfaceLoopResources
- Returns:
- a Mono representing the completion of the LoopResources disposal.
-
disposeLater
This has aNOOP
implementation by default in order to prevent unintended disposal of the global UDP resources which has a longer lifecycle than regularLoopResources
. If a disposal of the global UDP resources is needed,shutdownLater(Duration, Duration)
should be used instead.- Specified by:
disposeLater
in interfaceLoopResources
- Parameters:
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 period- Returns:
- a Mono representing the completion of the LoopResources disposal.
-
isDisposed
public boolean isDisposed()- Specified by:
isDisposed
in interfaceDisposable
-
onChannel
public <CHANNEL extends Channel> CHANNEL onChannel(Class<CHANNEL> channelType, EventLoopGroup group) Description copied from interface:LoopResources
Callback for aChannel
selection.- Specified by:
onChannel
in interfaceLoopResources
- Type Parameters:
CHANNEL
- theChannel
implementation- Parameters:
channelType
- the channel typegroup
- the sourceEventLoopGroup
to assign a loop from- Returns:
- a
Channel
instance
-
onChannelClass
public <CHANNEL extends Channel> Class<? extends CHANNEL> onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group) Description copied from interface:LoopResources
Callback for aChannel
class selection.- Specified by:
onChannelClass
in interfaceLoopResources
- Type Parameters:
CHANNEL
- theChannel
implementation- Parameters:
channelType
- the channel typegroup
- the sourceEventLoopGroup
to assign a loop from- Returns:
- a
Channel
class
-
onClient
Description copied from interface:LoopResources
Callback for clientEventLoopGroup
creation.- Specified by:
onClient
in interfaceLoopResources
- Parameters:
useNative
- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
onServer
Description copied from interface:LoopResources
Callback for serverEventLoopGroup
creation, this is theEventLoopGroup
for the child channel.- Specified by:
onServer
in interfaceLoopResources
- Parameters:
useNative
- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
onServerSelect
Description copied from interface:LoopResources
Callback for server selectEventLoopGroup
creation, this is theEventLoopGroup
for the acceptor channel.- Specified by:
onServerSelect
in interfaceLoopResources
- Parameters:
useNative
- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
_dispose
protected void _dispose()Dispose underlying resources. -
_disposeLater
Dispose underlying resources in a listenable fashion. It is guaranteed that the disposal of the underlying LoopResources will not happen beforequietPeriod
is over. If a task is submitted during thequietPeriod
, it is guaranteed to be accepted and thequietPeriod
will start over.- Parameters:
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 period- Returns:
- the Mono that represents the end of disposal
-
getOrCreate
protected static UdpResources getOrCreate(@Nullable 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.- Parameters:
loops
- the eventual newLoopResources
onNew
- aUdpResources
factoryname
- a name for resources- Returns:
- an existing or new
UdpResources
-