Package org.apache.hc.core5.pool
Class LaxConnPool<T,C extends ModalCloseable>
java.lang.Object
org.apache.hc.core5.pool.LaxConnPool<T,C>
- Type Parameters:
T
- routeC
- connection object
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ModalCloseable
,ConnPool<T,
,C> ConnPoolControl<T>
,ConnPoolStats<T>
,ManagedConnPool<T,
C>
@Contract(threading=SAFE)
@Experimental
public class LaxConnPool<T,C extends ModalCloseable>
extends Object
implements ManagedConnPool<T,C>
Connection pool with higher concurrency but with lax connection limit guarantees.
- Since:
- 5.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
LaxConnPool.LeaseRequest<T,
C extends ModalCloseable> (package private) static class
LaxConnPool.PerRoutePool<T,
C extends ModalCloseable> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConnPoolListener
<T> private int
private final DisposalCallback
<C> private final AtomicBoolean
private final PoolReusePolicy
private final ConcurrentMap
<T, LaxConnPool.PerRoutePool<T, C>> private final TimeValue
-
Constructor Summary
ConstructorsConstructorDescriptionLaxConnPool
(int defaultMaxPerRoute) LaxConnPool
(int defaultMaxPerRoute, TimeValue timeToLive, PoolReusePolicy policy, ConnPoolListener<T> connPoolListener) LaxConnPool
(int defaultMaxPerRoute, TimeValue timeToLive, PoolReusePolicy policy, DisposalCallback<C> disposalCallback, ConnPoolListener<T> connPoolListener) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Closes this process or endpoint and releases any system resources associated with it.void
void
void
enumAvailable
(Callback<PoolEntry<T, C>> callback) void
enumLeased
(Callback<PoolEntry<T, C>> callback) int
int
getMaxPerRoute
(T route) int
private LaxConnPool.PerRoutePool
<T, C> boolean
Attempts to lease a connection for the given route and with the given state from the pool.void
Releases the pool entry back to the pool.void
setDefaultMaxPerRoute
(int max) void
setMaxPerRoute
(T route, int max) void
setMaxTotal
(int max) toString()
void
-
Field Details
-
timeToLive
-
policy
-
disposalCallback
-
connPoolListener
-
routeToPool
-
isShutDown
-
defaultMaxPerRoute
private volatile int defaultMaxPerRoute
-
-
Constructor Details
-
LaxConnPool
public LaxConnPool(int defaultMaxPerRoute, TimeValue timeToLive, PoolReusePolicy policy, DisposalCallback<C> disposalCallback, ConnPoolListener<T> connPoolListener) - Since:
- 5.0
-
LaxConnPool
public LaxConnPool(int defaultMaxPerRoute, TimeValue timeToLive, PoolReusePolicy policy, ConnPoolListener<T> connPoolListener) - Since:
- 5.0
-
LaxConnPool
public LaxConnPool(int defaultMaxPerRoute)
-
-
Method Details
-
isShutdown
public boolean isShutdown() -
close
Description copied from interface:ModalCloseable
Closes this process or endpoint and releases any system resources associated with it. If the endpoint or the process is already closed then invoking this method has no effect.- Specified by:
close
in interfaceModalCloseable
- Parameters:
closeMode
- How to close the receiver.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getPool
-
lease
public Future<PoolEntry<T,C>> lease(T route, Object state, Timeout requestTimeout, FutureCallback<PoolEntry<T, C>> callback) Description copied from interface:ConnPool
Attempts to lease a connection for the given route and with the given state from the pool.Please note the connection request can get automatically cancelled by the pool in case of a request timeout.
- Specified by:
lease
in interfaceConnPool<T,
C extends ModalCloseable> - Parameters:
route
- route of the connection.state
- arbitrary object that represents a particular state (usually a security principal or a unique token identifying the user whose credentials have been used while establishing the connection). May benull
.requestTimeout
- request timeout. In case of a timeout the request can get automatically cancelled by the pool.callback
- operation completion callback.- Returns:
- future for a leased pool entry.
-
lease
-
release
Description copied from interface:ConnPool
Releases the pool entry back to the pool.- Specified by:
release
in interfaceConnPool<T,
C extends ModalCloseable> - Parameters:
entry
- pool entry leased from the poolreusable
- flag indicating whether or not the released connection is in a consistent state and is safe for further use.
-
validatePendingRequests
public void validatePendingRequests() -
setMaxTotal
public void setMaxTotal(int max) - Specified by:
setMaxTotal
in interfaceConnPoolControl<T>
-
getMaxTotal
public int getMaxTotal()- Specified by:
getMaxTotal
in interfaceConnPoolControl<T>
-
setDefaultMaxPerRoute
public void setDefaultMaxPerRoute(int max) - Specified by:
setDefaultMaxPerRoute
in interfaceConnPoolControl<T>
-
getDefaultMaxPerRoute
public int getDefaultMaxPerRoute()- Specified by:
getDefaultMaxPerRoute
in interfaceConnPoolControl<T>
-
setMaxPerRoute
- Specified by:
setMaxPerRoute
in interfaceConnPoolControl<T>
-
getMaxPerRoute
- Specified by:
getMaxPerRoute
in interfaceConnPoolControl<T>
-
getTotalStats
- Specified by:
getTotalStats
in interfaceConnPoolStats<T>
-
getStats
- Specified by:
getStats
in interfaceConnPoolStats<T>
-
getRoutes
- Specified by:
getRoutes
in interfaceConnPoolControl<T>
-
enumAvailable
-
enumLeased
-
closeIdle
- Specified by:
closeIdle
in interfaceConnPoolControl<T>
-
closeExpired
public void closeExpired()- Specified by:
closeExpired
in interfaceConnPoolControl<T>
-
toString
-