Class MultiEndpointPool.Builder<E>
java.lang.Object
org.glassfish.grizzly.connectionpool.MultiEndpointPool.Builder<E>
- Type Parameters:
E- endpoint address type, for exampleSocketAddressfor TCP and UDP transports
- Enclosing class:
- MultiEndpointPool<E>
The Builder class responsible for constructing
SingleEndpointPool.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasyncPollTimeout(long asyncPollTimeout, TimeUnit timeunit) Sets the max time consumer will wait for aConnectionto become available.build()ConstructsMultiEndpointPool.connectionTTL(long connectionTTL, TimeUnit timeunit) Sets the max amount of time aConnectioncould be associated with the pool.connectorHandler(org.glassfish.grizzly.ConnectorHandler<E> defaultConnectorHandler) Deprecated.connectTimeout(long connectTimeout, TimeUnit timeunit) Sets the max timeConnectionconnect operation may take.delayExecutor(org.glassfish.grizzly.utils.DelayedExecutor delayedExecutor) Sets the customDelayedExecutorto be used for keep-alive and reconnect mechanisms.endpointPoolCustomizer(MultiEndpointPool.EndpointPoolCustomizer<E> endpointPoolCustomizer) Set the customizer, which will be used to modify a specific endpoint pool settings and overwrite the default settings assigned by this MultiEndpointPool.failFastWhenMaxSizeReached(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.keepAliveCheckInterval(long keepAliveCheckInterval, TimeUnit timeunit) Sets the interval, which specifies how often the pool will perform idleConnections check.keepAliveTimeout(long keepAliveTimeout, TimeUnit timeunit) Sets the maximum number of milliseconds an idleConnectionwill be kept in the pool.maxConnectionsPerEndpoint(int maxConnectionsPerEndpoint) Sets the maximum number ofConnections to a single endpoint the pool is allowed to have.maxConnectionsTotal(int maxConnectionsTotal) Sets the maximum number ofConnections the pool is allowed to have.maxReconnectAttempts(int maxReconnectAttempts) If the reconnect mechanism is enabled, then this property will affect how many times a reconnection attempt can be made consecutively before a failure is flagged.reconnectDelay(long reconnectDelay, TimeUnit timeunit) Sets the delay to be used before the pool will repeat the attempt to connect to the endpoint after previous connect operation had failed.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
connectorHandler
public MultiEndpointPool.Builder<E> connectorHandler(org.glassfish.grizzly.ConnectorHandler<E> defaultConnectorHandler) Deprecated.Endpointmust always know how to establish the connectionSets the defaultConnectorHandlerto be used to establish newConnections if none is specified byEndpoint.- Parameters:
defaultConnectorHandler-ConnectorHandler- Returns:
- this
MultiEndpointPool.Builder
-
maxConnectionsPerEndpoint
Sets the maximum number ofConnections to a single endpoint the pool is allowed to have. Default value is 2.- Parameters:
maxConnectionsPerEndpoint-- Returns:
- this
MultiEndpointPool.Builder
-
maxConnectionsTotal
Sets the maximum number ofConnections the pool is allowed to have. Default value is 16.- Parameters:
maxConnectionsTotal-- Returns:
- this
MultiEndpointPool.Builder
-
delayExecutor
public MultiEndpointPool.Builder<E> delayExecutor(org.glassfish.grizzly.utils.DelayedExecutor delayedExecutor) Sets the customDelayedExecutorto be used for keep-alive and reconnect mechanisms. If none is set - theSingleEndpointPoolwill create its ownDelayedExecutor.- Parameters:
delayedExecutor-- Returns:
- this
MultiEndpointPool.Builder
-
connectTimeout
Sets the max timeConnectionconnect operation may take. If timeout expires - the connect operation is considered failed. If connectTimeout < 0 - the connect timeout mechanism will be disabled. By default the connect timeout mechanism is disabled.- Parameters:
connectTimeout- the max timeConnectionconnect operation may take. If timeout expires - the connect operation is considered failed. The negative value disables the connect timeout mechanism.timeunit- a TimeUnit determining how to interpret the timeout parameter- Returns:
- this
MultiEndpointPool.Builder
-
reconnectDelay
Sets the delay to be used before the pool will repeat the attempt to connect to the endpoint after previous connect operation had failed. If reconnectDelay < 0 - the reconnect mechanism will be disabled. By default the reconnect mechanism is disabled.- Parameters:
reconnectDelay- the delay to be used before the pool will repeat the attempt to connect to the endpoint after previous connect operation had failed. The negative value disables the reconnect mechanism.timeunit- a TimeUnit determining how to interpret the timeout parameter- Returns:
- this
MultiEndpointPool.Builder
-
maxReconnectAttempts
If the reconnect mechanism is enabled, then this property will affect how many times a reconnection attempt can be made consecutively before a failure is flagged.- Parameters:
maxReconnectAttempts- the maximum number of reconnect attempts. If the reconnect mechanism isn't enabled, this property is ignored.- Returns:
- this
MultiEndpointPool.Builder
-
asyncPollTimeout
Sets the max time consumer will wait for aConnectionto become available. When timeout expires the consumer will be notified about the failure (TimeoutException) viaCompletionHandlerorFuture. If asyncPollTimeout < 0 - timeout will not be set. By default the timeout is not set and consumer may wait forever for aConnection.- Parameters:
asyncPollTimeout- the maximum time, the async poll operation could wait for a connection to become availabletimeunit- a TimeUnit determining how to interpret the timeout parameter- Returns:
- this
MultiEndpointPool.Builder
-
connectionTTL
Sets the max amount of time aConnectioncould be associated with the pool. Once timeout expired theConnectionwill be either closed, if it's idle, or detached from the pool, if it's being used. If connectionTTL < 0 - theConnectiontime to live will not be set and theConnectioncan be associated with a pool forever, if no other limit is hit (like keep-alive). By default the connectionTTL is not set.- Parameters:
connectionTTL- the max amount of time aConnectioncould be associated with the pooltimeunit- a TimeUnit determining how to interpret the connectionTTL parameter- Returns:
- this
MultiEndpointPool.Builder
-
failFastWhenMaxSizeReached
if true, the "take" method will fail fast if there is no free connection in the pool and max pool size is reached. Otherwise the pool will queue up the take request and wait for aConnectionto become available- Parameters:
failFastWhenMaxSizeReached-- Returns:
- this
MultiEndpointPool.Builder
-
keepAliveTimeout
Sets the maximum number of milliseconds an idleConnectionwill be kept in the pool. The idleConnections will be closed till the pool size is greater than corePoolSize. If keepAliveTimeout < 0 - the keep-alive mechanism will be disabled. By default the keep-alive timeout is set to 30 seconds.- Parameters:
keepAliveTimeout- the maximum number of milliseconds an idleConnectionwill be kept in the pool. The negative value disables the keep-alive mechanism.timeunit- a TimeUnit determining how to interpret the timeout parameter- Returns:
- this
MultiEndpointPool.Builder
-
keepAliveCheckInterval
public MultiEndpointPool.Builder<E> keepAliveCheckInterval(long keepAliveCheckInterval, TimeUnit timeunit) Sets the interval, which specifies how often the pool will perform idleConnections check.- Parameters:
keepAliveCheckInterval- the interval, which specifies how often the pool will perform idleConnections checktimeunit- a TimeUnit determining how to interpret the timeout parameter- Returns:
- this
MultiEndpointPool.Builder
-
endpointPoolCustomizer
public MultiEndpointPool.Builder<E> endpointPoolCustomizer(MultiEndpointPool.EndpointPoolCustomizer<E> endpointPoolCustomizer) Set the customizer, which will be used to modify a specific endpoint pool settings and overwrite the default settings assigned by this MultiEndpointPool.- Parameters:
endpointPoolCustomizer-MultiEndpointPool.EndpointPoolCustomizer- Returns:
- this
MultiEndpointPool.Builder
-
build
ConstructsMultiEndpointPool.- Returns:
MultiEndpointPool
-
Endpointmust always know how to establish the connection