Top Description Fields Constructors Methods
reactor.netty5.udp

public Class UdpResources

extends Object
implements LoopResources
Class Inheritance
All Implemented Interfaces
reactor.netty5.resources.LoopResources, reactor.core.Disposable
Imports
java.net.ProtocolFamily, java.time.Duration, java.util.concurrent.atomic.AtomicReference, java.util.function.Function, io.netty5.channel.Channel, .EventLoop, .EventLoopGroup, io.netty5.resolver.AddressResolverGroup, reactor.core.publisher.Mono, reactor.core.scheduler.Schedulers, reactor.netty5.ReactorNetty, reactor.netty5.resources.LoopResources, reactor.netty5.transport.NameResolverProvider, reactor.util.Logger, .Loggers, reactor.util.annotation.Nullable

Hold the default UDP resources
Author
Violeta Georgieva

Field Summary

Modifier and TypeField and Description
pack-priv static final NameResolverProvider
pack-priv static final int
DEFAULT_UDP_THREAD_COUNT

Default worker thread count, fallback to available processor (but with a minimum value of 4)

pack-priv final LoopResources
pack-priv final AtomicReference<AddressResolverGroup<?>>
pack-priv static final Logger
pack-priv static final Function<LoopResources, UdpResources>
pack-priv static final AtomicReference<UdpResources>

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected void
_dispose()

Dispose underlying resources

protected Mono<Void>

Returns:

the Mono that represents the end of disposal
_disposeLater
(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
)

Dispose underlying resources in a listenable fashion.

pack-priv void
pack-priv Mono<Void>
pack-priv static <T extends UdpResources> T
create(T previous, LoopResources loops, String name, Function<LoopResources, T> onNew)

public boolean
daemon()

Overrides default reactor.netty5.resources.LoopResources.daemon.

return true if EventLoopGroup should not be shutdown
public void
dispose()

Overrides default reactor.netty5.resources.LoopResources.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.
public Mono<Void>
disposeLater()

Overrides default reactor.netty5.resources.LoopResources.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.
public Mono<Void>
disposeLater(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
)

Overrides default reactor.netty5.resources.LoopResources.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.
public static UdpResources

Returns:

the global UDP resources for pooling
get
()

Return the global UDP resources for pooling

protected static UdpResources

Returns:

an existing or new UdpResources
getOrCreate
(LoopResources
the eventual new LoopResources
loops
,
Function<LoopResources, UdpResources>
a UdpResources factory
onNew
,
String
a name for resources
name
)

Safely check if existing resource exist and proceed to update/cleanup if new resources references are passed.

pack-priv AddressResolverGroup<?>

Returns:

an existing or new AddressResolverGroup
getOrCreateDefaultResolver
()

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

public boolean
isDisposed()

Overrides default reactor.core.Disposable.isDisposed.

Optionally return true when the resource or task is disposed.
public <CHANNEL extends Channel> CHANNEL
onChannel(Class<CHANNEL>
the channel type
channelType
,
EventLoop
the EventLoop to assign
eventLoop
,
ProtocolFamily
the configured ProtocolFamily to run with
protocolFamily
)

Overrides default reactor.netty5.resources.LoopResources.onChannel.

Callback for a Channel selection.
public EventLoopGroup
onClient(boolean
should use native group if current environment supports it
useNative
)

Overrides default reactor.netty5.resources.LoopResources.onClient.

Callback for client EventLoopGroup creation.
public EventLoopGroup
onServer(boolean
should use native group if current environment supports it
useNative
)

Implements reactor.netty5.resources.LoopResources.onServer.

Callback for server EventLoopGroup creation, this is the EventLoopGroup for the child channel.
public EventLoopGroup
onServerSelect(boolean
should use native group if current environment supports it
useNative
)

Overrides default reactor.netty5.resources.LoopResources.onServerSelect.

Callback for server select EventLoopGroup creation, this is the EventLoopGroup for the acceptor channel.
public static UdpResources

Returns:

the global UDP resources
reset
()

Reset UDP resources to default and return its instance

public static UdpResources

Returns:

the global UDP resources
set
(LoopResources
a new LoopResources to replace the current
loops
)

Update event loops resources and return the global UDP resources.

public static void
shutdown()

Shutdown the global UdpResources without resetting them, effectively cleaning up associated resources without creating new ones.

public static Mono<Void>

Returns:

a Mono triggering the shutdown() when subscribed to.
shutdownLater
()

Prepare to shutdown the global UdpResources without resetting them, effectively cleaning up associated resources without creating new ones.

public static Mono<Void>

Returns:

a Mono triggering the shutdown() when subscribed to.
shutdownLater
(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
)

Prepare to shutdown the global UdpResources without resetting them, effectively cleaning up associated resources without creating new ones.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_NAME_RESOLVER_PROVIDERback to summary
pack-priv static final NameResolverProvider DEFAULT_NAME_RESOLVER_PROVIDER
DEFAULT_UDP_THREAD_COUNTback to summary
pack-priv static final int DEFAULT_UDP_THREAD_COUNT

Default worker thread count, fallback to available processor (but with a minimum value of 4)

defaultLoopsback to summary
pack-priv final LoopResources defaultLoops
defaultResolverback to summary
pack-priv final AtomicReference<AddressResolverGroup<?>> defaultResolver
logback to summary
pack-priv static final Logger log
ON_UDP_NEWback to summary
pack-priv static final Function<LoopResources, UdpResources> ON_UDP_NEW
udpResourcesback to summary
pack-priv static final AtomicReference<UdpResources> udpResources

Constructor Detail

UdpResourcesback to summary
protected UdpResources(LoopResources defaultLoops)

Method Detail

_disposeback to summary
protected void _dispose()

Dispose underlying resources

_disposeLaterback to summary
protected Mono<Void> _disposeLater(Duration quietPeriod, Duration timeout)

Dispose underlying resources in a listenable fashion. 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>

the Mono that represents the end of disposal

_disposeResolverback to summary
pack-priv void _disposeResolver()
_disposeResolverLaterback to summary
pack-priv Mono<Void> _disposeResolverLater()
createback to summary
pack-priv static <T extends UdpResources> T create(T previous, LoopResources loops, String name, Function<LoopResources, T> onNew)
daemonback to summary
public boolean daemon()

Overrides default reactor.netty5.resources.LoopResources.daemon.

Doc from reactor.netty5.resources.LoopResources.daemon.

return true if EventLoopGroup should not be shutdown

Returns:boolean

true if EventLoopGroup should not be shutdown

Annotations
@Override
disposeback to summary
public void dispose()

Overrides default reactor.netty5.resources.LoopResources.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. If a disposal of the global UDP resources is needed, shutdown() should be used instead.

Annotations
@Override
disposeLaterback to summary
public Mono<Void> disposeLater()

Overrides default reactor.netty5.resources.LoopResources.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. If a disposal of the global UDP resources is needed, shutdownLater() should be used instead.

Returns:Mono<Void>

Doc from reactor.netty5.resources.LoopResources.disposeLater.

a Mono representing the completion of the LoopResources disposal.

Annotations
@Override
disposeLaterback to summary
public Mono<Void> disposeLater(Duration quietPeriod, Duration timeout)

Overrides default reactor.netty5.resources.LoopResources.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. If a disposal of the global UDP resources is needed, shutdownLater(Duration, Duration) should be used instead.

Parameters
quietPeriod:Duration

Doc from reactor.netty5.resources.LoopResources.disposeLater.

the quiet period as described above

timeout:Duration

Doc from reactor.netty5.resources.LoopResources.disposeLater.

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>

Doc from reactor.netty5.resources.LoopResources.disposeLater.

a Mono representing the completion of the LoopResources disposal.

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

Return the global UDP resources for pooling

Returns:UdpResources

the global UDP resources for pooling

getOrCreateback to summary
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.

Parameters
loops:LoopResources

the eventual new LoopResources

onNew:Function<LoopResources, UdpResources>

a UdpResources factory

name:String

a name for resources

Returns:UdpResources

an existing or new UdpResources

getOrCreateDefaultResolverback to summary
pack-priv AddressResolverGroup<?> 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

isDisposedback to summary
public boolean isDisposed()

Overrides default reactor.core.Disposable.isDisposed.

Doc from reactor.core.Disposable.isDisposed.

Optionally return true when the resource or task is disposed.

Implementations are not required to track disposition and as such may never return true even when disposed. However, they MUST only return true when there's a guarantee the resource or task is disposed.

Returns:boolean

true when there's a guarantee the resource or task is disposed.

Annotations
@Override
onChannelback to summary
public <CHANNEL extends Channel> CHANNEL onChannel(Class<CHANNEL> channelType, EventLoop eventLoop, ProtocolFamily protocolFamily)

Overrides default reactor.netty5.resources.LoopResources.onChannel.

Doc from reactor.netty5.resources.LoopResources.onChannel.

Callback for a Channel selection.

Parameters
<CHANNEL>
the Channel implementation
channelType:Class<CHANNEL>

the channel type

eventLoop:EventLoop

the EventLoop to assign

protocolFamily:ProtocolFamily

the configured ProtocolFamily to run with

Returns:CHANNEL

a Channel instance

Annotations
@Override
onClientback to summary
public EventLoopGroup onClient(boolean useNative)

Overrides default reactor.netty5.resources.LoopResources.onClient.

Doc from reactor.netty5.resources.LoopResources.onClient.

Callback for client EventLoopGroup creation.

Parameters
useNative:boolean

should use native group if current environment supports it

Returns:EventLoopGroup

a new EventLoopGroup

Annotations
@Override
onServerback to summary
public EventLoopGroup onServer(boolean useNative)

Implements reactor.netty5.resources.LoopResources.onServer.

Doc from reactor.netty5.resources.LoopResources.onServer.

Callback for server EventLoopGroup creation, this is the EventLoopGroup for the child channel.

Parameters
useNative:boolean

should use native group if current environment supports it

Returns:EventLoopGroup

a new EventLoopGroup

Annotations
@Override
onServerSelectback to summary
public EventLoopGroup onServerSelect(boolean useNative)

Overrides default reactor.netty5.resources.LoopResources.onServerSelect.

Doc from reactor.netty5.resources.LoopResources.onServerSelect.

Callback for server select EventLoopGroup creation, this is the EventLoopGroup for the acceptor channel.

Parameters
useNative:boolean

should use native group if current environment supports it

Returns:EventLoopGroup

a new EventLoopGroup

Annotations
@Override
resetback to summary
public static UdpResources reset()

Reset UDP resources to default and return its instance

Returns:UdpResources

the global UDP resources

setback to summary
public static UdpResources set(LoopResources loops)

Update event loops resources and return the global UDP resources.

Note

The previous LoopResources will be disposed.

Parameters
loops:LoopResources

a new LoopResources to replace the current

Returns:UdpResources

the global UDP resources

shutdownback to summary
public static void shutdown()

Shutdown the global 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.

shutdownLaterback to summary
public static Mono<Void> shutdownLater()

Prepare to shutdown the global 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

Returns:Mono<Void>

a Mono triggering the shutdown() when subscribed to.

shutdownLaterback to summary
public 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. 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 shutdown() when subscribed to.

Since
0.9.3