T - the route type that represents the opposite endpoint of a pooled
connection.C - the connection type.E - the type of the pool entry containing a pooled connection.@ThreadSafe public abstract class AbstractConnPool<T,C,E extends PoolEntry<T,C>> extends Object implements ConnPool<T,E>, ConnPoolControl<T>
Threads.
Therefore, one must call Future.get() or Future.get(long, TimeUnit)
method on the Future object returned by the
lease(Object, Object, FutureCallback) method in order for the lease operation
to complete.| Constructor and Description |
|---|
AbstractConnPool(ConnFactory<T,C> connFactory,
int defaultMaxPerRoute,
int maxTotal) |
| Modifier and Type | Method and Description |
|---|---|
void |
closeExpired()
Closes expired connections and evicts them from the pool.
|
void |
closeIdle(long idletime,
TimeUnit tunit)
Closes connections that have been idle longer than the given period
of time and evicts them from the pool.
|
protected abstract E |
createEntry(T route,
C conn)
Creates a new entry for the given connection with the given route.
|
int |
getDefaultMaxPerRoute() |
int |
getMaxPerRoute(T route) |
int |
getMaxTotal() |
PoolStats |
getStats(T route) |
PoolStats |
getTotalStats() |
boolean |
isShutdown() |
Future<E> |
lease(T route,
Object state)
Attempts to lease a connection for the given route and with the given
state from the pool.
|
Future<E> |
lease(T route,
Object state,
FutureCallback<E> callback)
Attempts to lease a connection for the given route and with the given
state from the pool.
|
void |
release(E entry,
boolean reusable)
Releases the pool entry back to the pool.
|
void |
setDefaultMaxPerRoute(int max) |
void |
setMaxPerRoute(T route,
int max) |
void |
setMaxTotal(int max) |
void |
shutdown()
Shuts down the pool.
|
String |
toString() |
public AbstractConnPool(ConnFactory<T,C> connFactory, int defaultMaxPerRoute, int maxTotal)
protected abstract E createEntry(T route, C conn)
public boolean isShutdown()
public void shutdown()
throws IOException
IOExceptionpublic Future<E> lease(T route, Object state, FutureCallback<E> callback)
Threads. Therefore, one must call Future.get()
or Future.get(long, TimeUnit) method on the Future
returned by this method in order for the lease operation to complete.lease in interface ConnPool<T,E extends PoolEntry<T,C>>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.callback - operation completion callback.public Future<E> lease(T route, Object state)
Threads. Therefore, one must call Future.get()
or Future.get(long, TimeUnit) method on the Future
returned by this method in order for the lease operation to complete.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.public void release(E entry, boolean reusable)
ConnPoolpublic void setMaxTotal(int max)
setMaxTotal in interface ConnPoolControl<T>public int getMaxTotal()
getMaxTotal in interface ConnPoolControl<T>public void setDefaultMaxPerRoute(int max)
setDefaultMaxPerRoute in interface ConnPoolControl<T>public int getDefaultMaxPerRoute()
getDefaultMaxPerRoute in interface ConnPoolControl<T>public void setMaxPerRoute(T route, int max)
setMaxPerRoute in interface ConnPoolControl<T>public int getMaxPerRoute(T route)
getMaxPerRoute in interface ConnPoolControl<T>public PoolStats getTotalStats()
getTotalStats in interface ConnPoolControl<T>public PoolStats getStats(T route)
getStats in interface ConnPoolControl<T>public void closeIdle(long idletime,
TimeUnit tunit)
idletime - maximum idle time.tunit - time unit.public void closeExpired()
Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.