public interface NettyChannelPool extends Closeable
ChannelPool
interface with CompletableFuture
support.Modifier and Type | Interface and Description |
---|---|
static interface |
NettyChannelPool.ReleaseStrategy |
Modifier and Type | Field and Description |
---|---|
static io.netty.util.AttributeKey<NettyChannelPool> |
CHANNEL_POOL
The default
Channel attribute for NettyChannelPool |
static NettyChannelPool.ReleaseStrategy |
DISCONNECT_ON_RELEASE
Constant
DISCONNECT_ON_RELEASE |
static NettyChannelPool.ReleaseStrategy |
NONE
Constant
NONE |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<io.netty.channel.Channel> |
acquire(InetSocketAddress remoteAddress)
Acquire a
Channel from this NettyChannelPool . |
CompletableFuture<io.netty.channel.Channel> |
acquire(InetSocketAddress remoteAddress,
CompletableFuture<io.netty.channel.Channel> promise)
Acquire a
Channel from this NettyChannelPool . |
void |
close() |
static NettyChannelPool |
getPool(io.netty.channel.Channel channel)
Retrieve the
NettyChannelPool which was used to acquire the specified Channel |
int |
getSize()
getSize.
|
static boolean |
isPooled(io.netty.channel.Channel channel)
Checks if the
Channel is currectly pooled |
CompletableFuture<Void> |
release(io.netty.channel.Channel channel)
Release a
Channel back to this NettyChannelPool . |
CompletableFuture<Void> |
release(io.netty.channel.Channel channel,
CompletableFuture<Void> promise)
Release a
Channel back to this NettyChannelPool . |
static CompletableFuture<Boolean> |
tryRelease(io.netty.channel.Channel channel)
Attempts to release the
Channel if it is pooleed. |
static final NettyChannelPool.ReleaseStrategy NONE
NONE
static final NettyChannelPool.ReleaseStrategy DISCONNECT_ON_RELEASE
DISCONNECT_ON_RELEASE
static final io.netty.util.AttributeKey<NettyChannelPool> CHANNEL_POOL
Channel
attribute for NettyChannelPool
static CompletableFuture<Boolean> tryRelease(io.netty.channel.Channel channel)
Channel
if it is pooleed.channel
- The Channel
to releaseCompletableFuture
which is notified once the operation is marked as completed. A value of true
will be returned if the Channel
was released, otherwise false
if the Channel
is not pooled or if the release operation was unsuccessful. The returned future will never complete exceptionally.static NettyChannelPool getPool(io.netty.channel.Channel channel)
NettyChannelPool
which was used to acquire the specified Channel
channel
- The Channel
to be used as lookupNettyChannelPool
or null
if the Channel
was not acquired from a NettyChannelPool
CompletableFuture<Void> release(io.netty.channel.Channel channel)
Channel
back to this NettyChannelPool
. The returned Future
is notified once
the release is successful and failed otherwise. When failed the Channel
will automatically closed.channel
- a Channel
objectCompletableFuture
objectstatic boolean isPooled(io.netty.channel.Channel channel)
Channel
is currectly pooledchannel
- The Channel
to be used as lookuptrue
if the Channel
has been acquired from a NettyChannelPool
CompletableFuture<io.netty.channel.Channel> acquire(InetSocketAddress remoteAddress)
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..remoteAddress
- The remote address to connect toCompletableFuture
objectCompletableFuture<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..remoteAddress
- The remote address to connect topromise
- The CompletableFuture
that is notified once the acquire operation is complete.CompletableFuture
objectCompletableFuture<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.channel
- a Channel
objectpromise
- a CompletableFuture
objectCompletableFuture
objectint getSize()
getSize.
void close()
close
in interface AutoCloseable
close
in interface Closeable
Copyright © 2016–2024. All rights reserved.