public class FixedChannelPool extends SimpleChannelPool
ChannelPool
implementation that takes another ChannelPool
implementation and enforce a maximum
number of concurrent connections.Modifier and Type | Class and Description |
---|---|
static class |
FixedChannelPool.AcquireTimeoutAction |
Constructor and Description |
---|
FixedChannelPool(Bootstrap bootstrap,
ChannelPoolHandler handler,
ChannelHealthChecker healthCheck,
FixedChannelPool.AcquireTimeoutAction action,
long acquireTimeoutMillis,
int maxConnections,
int maxPendingAcquires)
Creates a new instance.
|
FixedChannelPool(Bootstrap bootstrap,
ChannelPoolHandler handler,
ChannelHealthChecker healthCheck,
FixedChannelPool.AcquireTimeoutAction action,
long acquireTimeoutMillis,
int maxConnections,
int maxPendingAcquires,
boolean releaseHealthCheck)
Creates a new instance.
|
FixedChannelPool(Bootstrap bootstrap,
ChannelPoolHandler handler,
ChannelHealthChecker healthCheck,
FixedChannelPool.AcquireTimeoutAction action,
long acquireTimeoutMillis,
int maxConnections,
int maxPendingAcquires,
boolean releaseHealthCheck,
boolean lastRecentUsed)
Creates a new instance.
|
FixedChannelPool(Bootstrap bootstrap,
ChannelPoolHandler handler,
int maxConnections)
Creates a new instance using the
ChannelHealthChecker.ACTIVE . |
FixedChannelPool(Bootstrap bootstrap,
ChannelPoolHandler handler,
int maxConnections,
int maxPendingAcquires)
Creates a new instance using the
ChannelHealthChecker.ACTIVE . |
Modifier and Type | Method and Description |
---|---|
Future<Channel> |
acquire(Promise<Channel> promise)
Acquire a
Channel from this ChannelPool . |
void |
close() |
Future<java.lang.Void> |
release(Channel channel,
Promise<java.lang.Void> promise)
Release a
Channel back to this ChannelPool . |
acquire, bootstrap, connectChannel, handler, healthChecker, offerChannel, pollChannel, release, releaseHealthCheck
public FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, int maxConnections)
ChannelHealthChecker.ACTIVE
.bootstrap
- the Bootstrap
that is used for connectionshandler
- 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 FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, int maxConnections, int maxPendingAcquires)
ChannelHealthChecker.ACTIVE
.bootstrap
- the Bootstrap
that is used for connectionshandler
- 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 FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires)
bootstrap
- the Bootstrap
that is used for connectionshandler
- 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 ChannelPool
action
- the FixedChannelPool.AcquireTimeoutAction
to use or null
if non should be used.
In this case must be -1
.acquireTimeoutMillis
- the time (in milliseconds) after which an pending acquire must complete or
the FixedChannelPool.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 FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck)
bootstrap
- the Bootstrap
that is used for connectionshandler
- 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 ChannelPool
action
- the FixedChannelPool.AcquireTimeoutAction
to use or null
if non should be used.
In this case must be -1
.acquireTimeoutMillis
- the time (in milliseconds) after which an pending acquire must complete or
the FixedChannelPool.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
.public FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed)
bootstrap
- the Bootstrap
that is used for connectionshandler
- 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 ChannelPool
action
- the FixedChannelPool.AcquireTimeoutAction
to use or null
if non should be used.
In this case must be -1
.acquireTimeoutMillis
- the time (in milliseconds) after which an pending acquire must complete or
the FixedChannelPool.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.public Future<Channel> acquire(Promise<Channel> promise)
ChannelPool
Channel
from this ChannelPool
. The given Promise
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 ChannelPool
acquire
in class SimpleChannelPool
public Future<java.lang.Void> release(Channel channel, Promise<java.lang.Void> promise)
ChannelPool
Channel
back to this ChannelPool
. The given Promise
is notified once
the release is successful and failed otherwise. When failed the Channel
will automatically closed.release
in interface ChannelPool
release
in class SimpleChannelPool
public void close()
close
in interface ChannelPool
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class SimpleChannelPool
Copyright © 2008–2018 The Netty Project. All rights reserved.