SocketAddress
Connection pool implementation where each endpoint sub-pool is represented by
SingleEndpointPool and referenced by an Endpoint.
There are number of configuration options supported by the MultiEndpointPool: -
maxConnectionsPerEndpoint: the maximum number of Connections each SingleEndpointPool
sub-pool is allowed to have; - maxConnectionsTotal: the total 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 until the pool size is greater than the
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 |
|---|---|
| public static class | MultiEndpointPool.
endpoint address type, for example E>java. for TCP and UDP transportsThe Builder class responsible for constructing |
| public static class | |
| public static interface | MultiEndpointPool.
the address type, for example for TCP transport it's E>SocketAddressThe customizer, which could be used to modify an endpoint pool setting before it will be created. |
| private class | MultiEndpointPool.
|
| Modifier and Type | Field and Description |
|---|---|
| private final long | asyncPollTimeoutMillis
Async poll timeout, after which, the async connection poll operation will be failed with a timeout exception |
| private DelayedExecutor. | asyncPollTimeoutQueue
DelayQueue for async poll timeout mechanism |
| private final Map | connectionToSubPoolMap
Maps Connection -to- ConnectionInfo |
| private final long | connectionTTLMillis
the maximum amount of time, a |
| private 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 DelayedExecutor. | connectTimeoutQueue
DelayQueue for connect timeout mechanism |
| private final Object | countersSync
The pool's counters sync (poolSize, totalPendingConnections etc) |
| private final ConnectorHandler | defaultConnectorHandler
The default |
| private final DelayedExecutor | delayedExecutor
The |
| private final MultiEndpointPool. | endpointPoolCustomizer
The customizer, which will be used to modify a specific endpoint pool settings and overwrite the default settings assigned by this MultiEndpointPool. |
| protected final Map | endpointToPoolMap
Maps endpoint -to- SingleEndpointPool |
| 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 DelayedExecutor. | keepAliveCleanerQueue
DelayQueue for keep-alive mechanism |
| private final long | keepAliveTimeoutMillis
the maximum number of milliseconds an idle |
| private static final Logger | |
| private final int | maxConnectionsPerEndpoint
the maximum number of |
| private final int | maxConnectionsTotal
the total maximum number of |
| private final Chain | maxPoolSizeHitsChain
Priority queue, that helps to distribute connections fairly in situation when the max number of connections is reached |
| 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 |
| private int | poolSize
current pool size |
| protected final Object | poolSync
Sync for endpointToPoolMap updates |
| 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 DelayedExecutor. | reconnectQueue
DelayQueue for reconnect mechanism |
| private int | totalPendingConnections
Number of connections we're currently trying to establish and waiting for the result |
| Access | Constructor and Description |
|---|---|
| protected | MultiEndpointPool(final ConnectorHandler<E>
the default defaultConnectorHandler, final int ConnectorHandler to be used to establish new Connectionsthe maximum number of maxConnectionsPerEndpoint, final int Connections single endpoint sub-pool is allowed to
havethe total maximum number of maxConnectionsTotal, DelayedExecutor Connections the pool is allowed to havecustom 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, final MultiEndpointPool.the customizer, which will be used to modify a specific endpoint pool settings and
overwrite the default settings assigned by this MultiEndpointPool endpointPoolCustomizer
Deprecated
defaultConnectorHandler is deprecated
Constructs MultiEndpointPool instance. |
| protected | MultiEndpointPool(final int
the maximum number of maxConnectionsPerEndpoint, final int Connections single endpoint sub-pool is allowed to
havethe total maximum number of maxConnectionsTotal, final DelayedExecutor Connections the pool is allowed to havecustom 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, final MultiEndpointPool.the customizer, which will be used to modify a specific endpoint pool settings and
overwrite the default settings assigned by this MultiEndpointPool endpointPoolCustomizerConstructs MultiEndpointPool instance. |
| Modifier and Type | Method and Description |
|---|---|
| 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.Endpoint, that represents an endpoint to which the the Connection will be attachedAttaches "foreign" |
| public static < endpoint type T> MultiEndpointPool. | Returns: Builderendpoint address type, for example endpointType)java. for TCP and UDP transportsReturns single endpoint pool |
| private void | |
| private void | |
| private void | |
| private void | |
| protected void | |
| private void | |
| private Endpoint | checkWithDefaultConnectorHandler(Endpoint<E> endpoint)
For backwards compatibility reasons (defaultConnectorHandler is deprecated in the builder), the method checks if the
|
| public void | |
| public void | |
| protected SingleEndpointPool | Returns: SingleEndpointPoolthe endpoint key endpoint)Creates |
| public boolean | |
| 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 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 | getMaxConnectionsPerEndpoint()
Returns: the maximum number of |
| public int | |
| public int | |
| public int | |
| private MultiEndpointPool | |
| 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 |
| 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 |
| 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 |
| 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 |
| protected SingleEndpointPool | Returns: SingleEndpointPoolEndpoint, that represents an endpointObtains |
| public Connection | poll(final Endpoint<E>
Endpoint, that represents an endpointReturns: 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 |
| public int | |
| public GrizzlyFuture | Returns: GrizzlyFutureEndpoint, that represents an endpointObtains a |
| public void | take(final Endpoint<E>
Endpoint, that represents an endpointObtains a |
| public String |