SocketAddress
Connection pool implementation, in other words this pool manages Connections to
one specific endpoint.
The endpoint address has to be represented by an objected understandable by a ConnectorHandler passed to the
constructor. For example the endpoint address has to be represented by SocketAddress for
TCPNIOConnectorHandler and UDPNIOConnectorHandler.
There are number of configuration options supported by the SingleEndpointPool: - corePoolSize: the
number of Connections to be kept in the pool and never timed out because of keep-alive setting; -
maxPoolSize: the maximum number of Connections to be kept by the pool; -
keepAliveTimeoutMillis: the maximum number of milliseconds an idle Connection will be kept in the
pool. The idle Connections will be closed till the pool size is greater than corePoolSize; -
keepAliveCheckIntervalMillis: the interval, which specifies how often the pool will perform idle
Connections check; - reconnectDelayMillis: the delay to be used before the pool will repeat the
attempt to connect to the endpoint after previous connect had failed. - asyncPollTimeoutMillis: maximum
amount of time, after which the async connection poll operation will be failed with a timeout exception -
connectionTTLMillis: the maximum amount of time, a Connection could be associated with the pool
| Modifier and Type | Class and Description |
|---|---|
| protected static class | |
| pack-priv static class | |
| pack-priv static class | SingleEndpointPool.
Async poll timeout mechanism classes related to DelayedExecutor. |
| public static class | SingleEndpointPool.
endpoint address type, for example E>SocketAddress for TCP and UDP transportsThe Builder class responsible for constructing |
| private class | SingleEndpointPool.
|
| protected static class | |
| protected static class | SingleEndpointPool.
Connect timeout mechanism classes related to DelayedExecutor. |
| protected static class | |
| protected static class | |
| protected static class | SingleEndpointPool.
Connect timeout mechanism classes related to DelayedExecutor. |
| protected static class | SingleEndpointPool.
Keep-alive mechanism classes related to DelayedExecutor. |
| protected static class | |
| protected static class | |
| private class | SingleEndpointPool.
The |
| protected static class | SingleEndpointPool.
Reconnect mechanism classes related to DelayedExecutor. |
| protected static class | |
| protected static class |
| Modifier and Type | Field and Description |
|---|---|
| private final long | asyncPollTimeoutMillis
Async poll timeout, after which, the async connection poll operation will fail with a timeout exception |
| private final DelayedExecutor. | asyncPollTimeoutQueue
DelayQueue for async poll timeout mechanism |
| private final Chain | asyncWaitingList
The waiting list of asynchronous polling clients |
| private final SingleEndpointPool | closeListener
|
| private final Map | connectionsMap
The |
| private final long | connectionTTLMillis
the maximum amount of time, a |
| private final DelayedExecutor. | connectionTTLQueue
DelayQueue for connection time to live mechanism |
| private final long | connectTimeoutMillis
Connect timeout, after which, if a connection is not established, it is considered failed |
| private final DelayedExecutor. | connectTimeoutQueue
DelayQueue for connect timeout mechanism |
| private final int | corePoolSize
The number of |
| private final SingleEndpointPool | defaultConnectionCompletionHandler
|
| private final Endpoint | endpoint
The endpoint description |
| private int | failedConnectAttempts
Number of failed connect attempts. |
| private final boolean | failFastWhenMaxSizeReached
if true, the "take" method will fail fast if there is no free connection in the pool and max pool size is reached. |
| private boolean | isClosed
close flag |
| private final long | keepAliveCheckIntervalMillis
the interval, which specifies how often the pool will perform idle |
| private final DelayedExecutor. | keepAliveCleanerQueue
DelayQueue for keep-alive mechanism |
| private final long | keepAliveTimeoutMillis
the maximum number of milliseconds an idle |
| private static final Logger | |
| protected final int | maxPoolSize
The max number of |
| private final int | maxReconnectAttempts
Maximum number of reconnect attempts. |
| private final DelayedExecutor | ownDelayedExecutor
Own/internal |
| private final ExecutorService | ownDelayedExecutorThreadPool
The thread-pool used by theownDelayedExecutor |
| protected int | pendingConnections
Number of connections we're currently trying to establish and waiting for the result |
| private int | poolSize
current pool size |
| pack-priv final Object | poolSync
Sync object |
| private final Chain | readyConnections
The |
| private final long | reconnectDelayMillis
the delay to be used before the pool will repeat the attempt to connect to the endpoint after previous connect had failed |
| private final DelayedExecutor. | reconnectQueue
DelayQueue for reconnect mechanism |
| Access | Constructor and Description |
|---|---|
| protected | SingleEndpointPool(final Endpoint<E>
Endpoint to be used to establish new Connectionsthe number of corePoolSize, final int Connections, kept in the pool, that are immune to keep-alive mechanismthe max number of maxPoolSize, DelayedExecutor Connections kept by this poolcustom delayedExecutor, final long DelayedExecutor to be used by keep-alive and reconnect mechanismstimeout, after which, if a connection is not established, it is considered failed connectTimeoutMillis, final long the maximum number of milliseconds an idle keepAliveTimeoutMillis, final long Connection will be kept in the poolthe interval, which specifies how often the pool will perform idle
keepAliveCheckIntervalMillis, final long Connections checkthe delay to be used before the pool will repeat the attempt to connect to the endpoint
after previous connect had failed reconnectDelayMillis, final int the maximum number of reconnect attempts that may be made before failure notification. maxReconnectAttempts, final long the maximum time, the async poll operation could wait for a connection to become
available asyncPollTimeoutMillis, final long the maximum time, a connection could stay registered with the pool connectionTTLMillis, final boolean true if the "take" method should fail fast if there is no free connection
in the pool and max pool size is reached failFastWhenMaxSizeReached)Constructs SingleEndpointPool instance. |
| protected | SingleEndpointPool(final Endpoint<E>
Endpoint to be used to establish new Connectionsthe number of corePoolSize, final int Connections, kept in the pool, that are immune to keep-alive mechanismthe max number of maxPoolSize, final DelayedExecutor.Connections kept by this poolthe connectTimeoutQueue,DelayQueue used by connect timeout mechanismthe reconnectQueue,DelayQueue used by reconnect mechanismthe keepAliveCleanerQueue,DelayQueue used by keep-alive mechanismthe asyncPollTimeoutQueue,DelayQueue used by async connection poll mechanismthe connectionTTLQueue,DelayQueue used by connection TTL mechanismtimeout, after which, if a connection is not established, it is considered failed connectTimeoutMillis, final long the maximum number of milliseconds an idle keepAliveTimeoutMillis, final long Connection will be kept in the poolthe interval, which specifies how often the pool will perform idle
keepAliveCheckIntervalMillis, final long Connections checkthe delay to be used before the pool will repeat the attempt to connect to the endpoint
after previous connect had failed reconnectDelayMillis, final int the maximum number of reconnect attempts that may be made before failure notification. maxReconnectAttempts, final long the maximum time, the async poll operation could wait for a connection to become
available asyncPollTimeoutMillis, final long the maximum time, a connection could stay registered with the pool connectionTTLMillis, final boolean true if the "take" method should fail fast if there is no free connection
in the pool and max pool size is reached failFastWhenMaxSizeReached)Constructs SingleEndpointPool instance. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public boolean | Returns: true if theConnection has been successfully attached, or false otherwise. If the
Connection had been already registered in the pool - the method call doesn't have any effect and
true will be returned.Attaches "foreign" |
| pack-priv ConnectionInfo | |
| public static < endpoint type T> SingleEndpointPool. | Returns: Builderendpoint address type, for example endpointType)SocketAddress for TCP and UDP transportsReturns single endpoint pool |
| protected boolean | Returns: true if new connection could be created, or false otherwiseThe method is called before the pool will try to establish new client connection. |
| pack-priv boolean | cleanupIdleConnections(final SingleEndpointPool.
Perform keep-alive check on the ready connections and close connections, that keep-alive timeout has been expired. |
| public void | |
| private void | |
| protected boolean | Returns: true if a newConnection could be open, or false otherwiseChecks if it's possible to create a new |
| private boolean | Returns: true if a newConnection could be open, or false otherwiseChecks if it's possible to create a new |
| private void | |
| public boolean | Returns: true if the connection was successfully detached from this pool, otherwise returns
falsethe connection)Connection to detachDetaches a |
| private SingleEndpointPool. | |
| public long | getAsyncPollTimeout(final TimeUnit timeUnit)
Returns: the timeout, after which, the async connection poll operation will fail with a timeout exception |
| public ConnectionInfo | Returns: pooledConnectionInfo, that might be used for monitoring reasons, or null if the
Connection does not belong to this poolReturns pooled |
| public long | Returns: the maximum amount of time, aConnection could be associated with the poolReturn the maximum amount of time, a |
| public long | getConnectTimeout(final TimeUnit timeUnit)
Returns: the connection timeout, after which, if a connection is not established, it is considered failed |
| public int | getCorePoolSize()
Returns: the number of |
| public Endpoint | |
| public long | getKeepAliveCheckInterval(final TimeUnit timeUnit)
Returns: the interval, which specifies how often the pool will perform idle |
| public long | Returns: the maximum amount of time an idleConnection will be kept in the poolReturns the maximum amount of time an idle |
| public int | |
| public int | |
| public int | |
| public int | |
| public long | getReconnectDelay(final TimeUnit timeUnit)
Returns: the delay to be used before the pool will repeat the attempt to connect to the endpoint after previous attempt fail |
| protected int | |
| public boolean | Returns: true only if theConnection is registered in the pool and is currently in busy state (used
by a user), otherwise returns falseReturns true only if the |
| pack-priv boolean | |
| public boolean | isFailFastWhenMaxSizeReached()
Returns: true, if the "take" method will fail fast if there is no free connection in the pool and max pool size is reached |
| public boolean | isMaxCapacityReached()
Returns: true is maximum number of |
| pack-priv boolean | |
| public boolean | Returns: true if theConnection is registered in the pool no matter if it's currently in busy or
ready state, or false if the Connection is not registered in the poolReturns true if the |
| private void | |
| private SingleEndpointPool. | |
| pack-priv void | onCloseConnection(final ConnectionInfo<E> info)
The method will be called to notify about connection termination. |
| pack-priv void | onConnected(final Connection<L> connection)
The method will be called to notify about newly open connection (not attached yet) |
| pack-priv void | onFailedConnection()
The method will be called to notify about error occurred during new connection opening. |
| public Connection | poll()
Returns: a |
| public boolean | Returns: true if the connection was successfully released. If the connection cannot be released, the
connection will be closed and false will be returned.the connection)Connection to returnReturns the |
| pack-priv boolean | release0(final ConnectionInfo<E> info)
Same as |
| private boolean | |
| public int | |
| public GrizzlyFuture | Returns: GrizzlyFutureObtains a |
| public void | take(final CompletionHandler<Connection<L>>
to be notified once completionHandler)Connection is available or an error occurredObtains a |
| public String |