public class TcpResources extends Object implements PoolResources, LoopResources
DEFAULT_POOL_ACQUIRE_TIMEOUT, DEFAULT_POOL_MAX_CONNECTIONDEFAULT_IO_SELECT_COUNT, DEFAULT_IO_WORKER_COUNT| Modifier | Constructor and Description |
|---|---|
protected |
TcpResources(LoopResources defaultLoops,
PoolResources defaultPools) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_dispose()
Dispose underlying resources
|
boolean |
daemon()
return true if
EventLoopGroup should not be shutdown |
void |
dispose() |
static TcpResources |
get()
Return the global HTTP resources for event loops and pooling
|
protected static <T extends TcpResources> |
getOrCreate(AtomicReference<T> ref,
LoopResources loops,
PoolResources pools,
java.util.function.BiFunction<LoopResources,PoolResources,T> onNew,
String name)
Safely check if existing resource exist and proceed to update/cleanup if new
resources references are passed.
|
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()
Rreturn true if should default to native
EventLoopGroup and Channel |
static TcpResources |
reset()
Reset http resources to default and return its instance
|
ChannelPool |
selectOrCreate(SocketAddress address,
java.util.function.Supplier<? extends Bootstrap> bootstrap,
java.util.function.Consumer<? super Channel> onChannelCreate,
EventLoopGroup group)
Return an existing or new
ChannelPool. |
static TcpResources |
set(LoopResources loops)
Update pooling resources and return the global HTTP resources
|
static TcpResources |
set(PoolResources pools)
Update event loops resources and return the global HTTP resources
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitelastic, fixed, fixed, fixedcolocate, create, create, createisDisposedprotected TcpResources(LoopResources defaultLoops, PoolResources defaultPools)
public static TcpResources get()
public static TcpResources set(PoolResources pools)
public static TcpResources set(LoopResources loops)
public static TcpResources reset()
public void dispose()
dispose in interface Cancellationdispose in interface Disposabledispose in interface LoopResourcesdispose in interface PoolResourcesprotected void _dispose()
public ChannelPool selectOrCreate(SocketAddress address, java.util.function.Supplier<? extends Bootstrap> bootstrap, java.util.function.Consumer<? super Channel> onChannelCreate, EventLoopGroup group)
PoolResourcesChannelPool. The implementation will take care
of pulling Bootstrap lazily when a ChannelPool creation is actually
needed.selectOrCreate in interface PoolResourcesaddress - the remote address to resolve for existing or
new ChannelPoolbootstrap - the Bootstrap supplier if a ChannelPool must be
createdonChannelCreate - callback only when new connection is madeChannelPoolpublic 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, LoopResources loops, PoolResources pools, java.util.function.BiFunction<LoopResources,PoolResources,T> onNew, String name)
T - the reified type of TcpResourcesref - the resources atomic referenceloops - the eventual new LoopResourcespools - the eventual new PoolResourcesonNew - a TcpResources factoryname - a name for resourcesTcpResources