public class FixedNettyChannelPool extends SimpleNettyChannelPool
FixedChannelPool| Modifier and Type | Class and Description |
|---|---|
static class |
FixedNettyChannelPool.AcquireTimeoutAction |
NettyChannelPool.ReleaseStrategyCHANNEL_POOL, DISCONNECT_ON_RELEASE, NONE| Constructor and Description |
|---|
FixedNettyChannelPool(NettyChannelFactory channelFactory,
io.netty.channel.pool.ChannelPoolHandler handler,
ChannelHealthChecker healthCheck,
FixedNettyChannelPool.AcquireTimeoutAction action,
long acquireTimeoutMillis,
int maxConnections,
int maxPendingAcquires)
Creates a new instance.
|
FixedNettyChannelPool(NettyChannelFactory channelFactory,
io.netty.channel.pool.ChannelPoolHandler handler,
ChannelHealthChecker healthCheck,
FixedNettyChannelPool.AcquireTimeoutAction action,
long acquireTimeoutMillis,
int maxConnections,
int maxPendingAcquires,
boolean releaseHealthCheck,
boolean lastRecentUsed,
NettyChannelPool.ReleaseStrategy releaseStrategy)
Creates a new instance.
|
FixedNettyChannelPool(NettyChannelFactory channelFactory,
io.netty.channel.pool.ChannelPoolHandler handler,
ChannelHealthChecker healthCheck,
FixedNettyChannelPool.AcquireTimeoutAction action,
long acquireTimeoutMillis,
int maxConnections,
int maxPendingAcquires,
boolean releaseHealthCheck,
NettyChannelPool.ReleaseStrategy releaseStrategy)
Creates a new instance.
|
FixedNettyChannelPool(NettyChannelFactory channelFactory,
io.netty.channel.pool.ChannelPoolHandler handler,
int maxConnections)
Creates a new instance using the
ChannelHealthChecker.ACTIVE. |
FixedNettyChannelPool(NettyChannelFactory channelFactory,
io.netty.channel.pool.ChannelPoolHandler handler,
int maxConnections,
int maxPendingAcquires)
Creates a new instance using the
ChannelHealthChecker.ACTIVE. |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<io.netty.channel.Channel> |
acquire(InetSocketAddress remoteAddress,
CompletableFuture<io.netty.channel.Channel> promise)
Acquire a
Channel from this NettyChannelPool. |
void |
close() |
CompletableFuture<Void> |
closeAsync()
Closes the pool in an async manner.
|
int |
getTotalAcquiredChannels()
Returns the number of acquired channels that this pool thinks it has.
|
CompletableFuture<Void> |
release(io.netty.channel.Channel channel,
CompletableFuture<Void> promise)
Release a
Channel back to this NettyChannelPool. |
acquire, getChannelFactory, getChannelHealthChecker, getChannelPoolHandler, getSize, newChannel, offerChannel, pollChannel, release, releaseHealthCheckclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetPool, isPooled, tryReleasepublic FixedNettyChannelPool(NettyChannelFactory channelFactory, io.netty.channel.pool.ChannelPoolHandler handler, int maxConnections)
ChannelHealthChecker.ACTIVE.channelFactory - callback which returns a CompletableFuture, when transitions to a complete state, the future returns a new connected Channelhandler - the ChannelPoolHandler that will be notified for the different pool actionsmaxConnections - the number of maximal active connections, once this is reached new tries to acquire
a Channel will be delayed until a connection is returned to the pool again.public FixedNettyChannelPool(NettyChannelFactory channelFactory, io.netty.channel.pool.ChannelPoolHandler handler, int maxConnections, int maxPendingAcquires)
ChannelHealthChecker.ACTIVE.channelFactory - callback which returns a CompletableFuture, when transitions to a complete state, the future returns a new connected Channelhandler - the ChannelPoolHandler that will be notified for the different pool actionsmaxConnections - the number of maximal active connections, once this is reached new tries to
acquire a Channel will be delayed until a connection is returned to the
pool again.maxPendingAcquires - the maximum number of pending acquires. Once this is exceed acquire tries will
be failed.public FixedNettyChannelPool(NettyChannelFactory channelFactory, io.netty.channel.pool.ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedNettyChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires)
channelFactory - callback which returns a CompletableFuture, when transitions to a complete state, the future returns a new connected Channelhandler - the ChannelPoolHandler that will be notified for the different pool actionshealthCheck - the ChannelHealthChecker that will be used to check if a Channel is
still healthy when obtain from the NettyChannelPoolaction - the FixedNettyChannelPool.AcquireTimeoutAction to use or null if non should be used.
In this case acquireTimeoutMillis must be -1.acquireTimeoutMillis - the time (in milliseconds) after which an pending acquire must complete or
the FixedNettyChannelPool.AcquireTimeoutAction takes place.maxConnections - the number of maximal active connections, once this is reached new tries to
acquire a Channel will be delayed until a connection is returned to the
pool again.maxPendingAcquires - the maximum number of pending acquires. Once this is exceed acquire tries will
be failed.public FixedNettyChannelPool(NettyChannelFactory channelFactory, io.netty.channel.pool.ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedNettyChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, NettyChannelPool.ReleaseStrategy releaseStrategy)
channelFactory - callback which returns a CompletableFuture, when transitions to a complete state, the future returns a new connected Channelhandler - the ChannelPoolHandler that will be notified for the different pool actionshealthCheck - the ChannelHealthChecker that will be used to check if a Channel is
still healthy when obtain from the NettyChannelPoolaction - the FixedNettyChannelPool.AcquireTimeoutAction to use or null if non should be used.
In this case acquireTimeoutMillis must be -1.acquireTimeoutMillis - the time (in milliseconds) after which an pending acquire must complete or
the FixedNettyChannelPool.AcquireTimeoutAction takes place.maxConnections - the number of maximal active connections, once this is reached new tries to
acquire a Channel will be delayed until a connection is returned to the
pool again.maxPendingAcquires - the maximum number of pending acquires. Once this is exceed acquire tries will
be failed.releaseHealthCheck - will check channel health before offering back if this parameter set to
true.releaseStrategy - a ReleaseStrategy objectpublic FixedNettyChannelPool(NettyChannelFactory channelFactory, io.netty.channel.pool.ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedNettyChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed, NettyChannelPool.ReleaseStrategy releaseStrategy)
channelFactory - callback which returns a CompletableFuture, when transitions to a complete state, the future returns a new connected Channelhandler - the ChannelPoolHandler that will be notified for the different pool actionshealthCheck - the ChannelHealthChecker that will be used to check if a Channel is
still healthy when obtain from the NettyChannelPoolaction - the FixedNettyChannelPool.AcquireTimeoutAction to use or null if non should be used.
In this case acquireTimeoutMillis must be -1.acquireTimeoutMillis - the time (in milliseconds) after which an pending acquire must complete or
the FixedNettyChannelPool.AcquireTimeoutAction takes place.maxConnections - the number of maximal active connections, once this is reached new tries to
acquire a Channel will be delayed until a connection is returned to the
pool again.maxPendingAcquires - the maximum number of pending acquires. Once this is exceed acquire tries will
be failed.releaseHealthCheck - will check channel health before offering back if this parameter set to
true.lastRecentUsed - true Channel selection will be LIFO, if false FIFO.releaseStrategy - a ReleaseStrategy objectpublic int getTotalAcquiredChannels()
public CompletableFuture<io.netty.channel.Channel> acquire(InetSocketAddress remoteAddress, CompletableFuture<io.netty.channel.Channel> promise)
Channel from this NettyChannelPool. The returned CompletableFuture is notified once
the acquire is successful and failed otherwise.
Its important that an acquired is always released to the pool again, even if the Channel
is explicitly closed..acquire in interface NettyChannelPoolacquire in class SimpleNettyChannelPoolremoteAddress - The remote address to connect topromise - The CompletableFuture that is notified once the acquire operation is complete.CompletableFuture objectpublic CompletableFuture<Void> release(io.netty.channel.Channel channel, CompletableFuture<Void> promise)
Channel back to this NettyChannelPool. The given Promise is notified once
the release is successful and failed otherwise. When failed the Channel will automatically closed.release in interface NettyChannelPoolrelease in class SimpleNettyChannelPoolchannel - a Channel objectpromise - a CompletableFuture objectCompletableFuture objectpublic void close()
close in interface NettyChannelPoolclose in interface Closeableclose in interface AutoCloseableclose in class SimpleNettyChannelPoolpublic CompletableFuture<Void> closeAsync()
Closes the pool in an async manner.
closeAsync in class SimpleNettyChannelPoolCopyright © 2016–2024. All rights reserved.