R - route key typeC - connection type (must be ModalCloseable)@Contract(threading=SAFE_CONDITIONAL) @Experimental public final class RouteSegmentedConnPool<R,C extends ModalCloseable> extends Object implements ManagedConnPool<R,C>
Per-route state is kept in independent segments. Disposal of connections is offloaded to a bounded executor so slow closes do not block threads leasing on other routes. A minimal round-robin drainer is engaged only when there are many pending routes and there is global headroom; it never scans all routes.
ManagedConnPool,
PoolReusePolicy,
DisposalCallback| Constructor and Description |
|---|
RouteSegmentedConnPool(int defaultMaxPerRoute,
int maxTotal,
TimeValue timeToLive,
PoolReusePolicy reusePolicy,
DisposalCallback<C> disposal) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
close(CloseMode closeMode)
Closes this process or endpoint and releases any system resources associated
with it.
|
void |
closeExpired() |
void |
closeIdle(TimeValue idleTime) |
int |
getDefaultMaxPerRoute() |
int |
getMaxPerRoute(R route) |
int |
getMaxTotal() |
Set<R> |
getRoutes() |
PoolStats |
getStats(R route) |
PoolStats |
getTotalStats() |
Future<PoolEntry<R,C>> |
lease(R route,
Object state,
Timeout requestTimeout,
FutureCallback<PoolEntry<R,C>> callback)
Attempts to lease a connection for the given route and with the given
state from the pool.
|
void |
release(PoolEntry<R,C> entry,
boolean reusable)
Releases the pool entry back to the pool.
|
void |
setDefaultMaxPerRoute(int max) |
void |
setMaxPerRoute(R route,
int max) |
void |
setMaxTotal(int max) |
public RouteSegmentedConnPool(int defaultMaxPerRoute,
int maxTotal,
TimeValue timeToLive,
PoolReusePolicy reusePolicy,
DisposalCallback<C> disposal)
public Future<PoolEntry<R,C>> lease(R route, Object state, Timeout requestTimeout, FutureCallback<PoolEntry<R,C>> callback)
ConnPoolPlease note the connection request can get automatically cancelled by the pool in case of a request timeout.
lease in interface ConnPool<R,C extends ModalCloseable>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 be null.requestTimeout - request timeout. In case of a timeout the request
can get automatically cancelled by the pool.callback - operation completion callback.public void release(PoolEntry<R,C> entry, boolean reusable)
ConnPoolrelease in interface ConnPool<R,C extends ModalCloseable>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.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void close(CloseMode closeMode)
ModalCloseableclose in interface ModalCloseablecloseMode - How to close the receiver.public void closeIdle(TimeValue idleTime)
closeIdle in interface ConnPoolControl<R>public void closeExpired()
closeExpired in interface ConnPoolControl<R>public Set<R> getRoutes()
getRoutes in interface ConnPoolControl<R>public int getMaxTotal()
getMaxTotal in interface ConnPoolControl<R>public void setMaxTotal(int max)
setMaxTotal in interface ConnPoolControl<R>public int getDefaultMaxPerRoute()
getDefaultMaxPerRoute in interface ConnPoolControl<R>public void setDefaultMaxPerRoute(int max)
setDefaultMaxPerRoute in interface ConnPoolControl<R>public int getMaxPerRoute(R route)
getMaxPerRoute in interface ConnPoolControl<R>public void setMaxPerRoute(R route, int max)
setMaxPerRoute in interface ConnPoolControl<R>public PoolStats getTotalStats()
getTotalStats in interface ConnPoolStats<R>public PoolStats getStats(R route)
getStats in interface ConnPoolStats<R>Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.