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.booleandaemon()return true ifEventLoopGroupshould not be shutdown.voiddispose()This has aNOOPimplementation by default in order to prevent unintended disposal of the global UDP resources which has a longer lifecycle than regularLoopResources.This has aNOOPimplementation 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 aNOOPimplementation by default in order to prevent unintended disposal of the global UDP resources which has a longer lifecycle than regularLoopResources.static UdpResourcesget()Return the global UDP resources for pooling.protected static UdpResourcesgetOrCreate(@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 aChannelselection.onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group) Callback for aChannelclass selection.onClient(boolean useNative) Callback for clientEventLoopGroupcreation.onServer(boolean useNative) Callback for serverEventLoopGroupcreation, this is theEventLoopGroupfor the child channel.onServerSelect(boolean useNative) Callback for server selectEventLoopGroupcreation, this is theEventLoopGroupfor the acceptor channel.static UdpResourcesreset()Reset UDP resources to default and return its instance.static UdpResourcesset(LoopResources loops) Update event loops resources and return the global UDP resources.static voidshutdown()Shutdown the globalUdpResourceswithout resetting them, effectively cleaning up associated resources without creating new ones.Prepare to shutdown the globalUdpResourceswithout resetting them, effectively cleaning up associated resources without creating new ones.shutdownLater(Duration quietPeriod, Duration timeout) Prepare to shutdown the globalUdpResourceswithout 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 previousLoopResourceswill be disposed.- Parameters:
loops- a newLoopResourcesto replace the current- Returns:
- the global UDP resources
-
shutdown
public static void shutdown()Shutdown the globalUdpResourceswithout 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 globalUdpResourceswithout resetting them, effectively cleaning up associated resources without creating new ones. This only occurs when the returnedMonois subscribed to. The quiet period will be2sand the timeout will be15s- Returns:
- a
Monotriggering theshutdown()when subscribed to.
-
shutdownLater
Prepare to shutdown the globalUdpResourceswithout resetting them, effectively cleaning up associated resources without creating new ones. This only occurs when the returnedMonois subscribed to. It is guaranteed that the disposal of the underlying LoopResources will not happen beforequietPeriodis over. If a task is submitted during thequietPeriod, it is guaranteed to be accepted and thequietPeriodwill 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
Monotriggering theshutdown()when subscribed to. - Since:
- 0.9.3
-
daemon
public boolean daemon()Description copied from interface:LoopResourcesreturn true ifEventLoopGroupshould not be shutdown.- Specified by:
daemonin interfaceLoopResources- Returns:
- true if
EventLoopGroupshould not be shutdown
-
dispose
public void dispose()This has aNOOPimplementation 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:
disposein interfaceDisposable- Specified by:
disposein interfaceLoopResources
-
disposeLater
This has aNOOPimplementation 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:
disposeLaterin interfaceLoopResources- Returns:
- a Mono representing the completion of the LoopResources disposal.
-
disposeLater
This has aNOOPimplementation 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:
disposeLaterin 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:
isDisposedin interfaceDisposable
-
onChannel
public <CHANNEL extends Channel> CHANNEL onChannel(Class<CHANNEL> channelType, EventLoopGroup group) Description copied from interface:LoopResourcesCallback for aChannelselection.- Specified by:
onChannelin interfaceLoopResources- Type Parameters:
CHANNEL- theChannelimplementation- Parameters:
channelType- the channel typegroup- the sourceEventLoopGroupto assign a loop from- Returns:
- a
Channelinstance
-
onChannelClass
public <CHANNEL extends Channel> Class<? extends CHANNEL> onChannelClass(Class<CHANNEL> channelType, EventLoopGroup group) Description copied from interface:LoopResourcesCallback for aChannelclass selection.- Specified by:
onChannelClassin interfaceLoopResources- Type Parameters:
CHANNEL- theChannelimplementation- Parameters:
channelType- the channel typegroup- the sourceEventLoopGroupto assign a loop from- Returns:
- a
Channelclass
-
onClient
Description copied from interface:LoopResourcesCallback for clientEventLoopGroupcreation.- Specified by:
onClientin interfaceLoopResources- Parameters:
useNative- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
onServer
Description copied from interface:LoopResourcesCallback for serverEventLoopGroupcreation, this is theEventLoopGroupfor the child channel.- Specified by:
onServerin interfaceLoopResources- Parameters:
useNative- should use native group if current environment supports it- Returns:
- a new
EventLoopGroup
-
onServerSelect
Description copied from interface:LoopResourcesCallback for server selectEventLoopGroupcreation, this is theEventLoopGroupfor the acceptor channel.- Specified by:
onServerSelectin 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 beforequietPeriodis over. If a task is submitted during thequietPeriod, it is guaranteed to be accepted and thequietPeriodwill 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 newLoopResourcesonNew- aUdpResourcesfactoryname- a name for resources- Returns:
- an existing or new
UdpResources
-