|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.http.pool.AbstractConnPool<T,C,E>
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>>
Abstract synchronous (blocking) pool of connections.
Please note that this class does not maintain its own pool of executionThread
s.
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 Summary | |
---|---|
AbstractConnPool(ConnFactory<T,C> connFactory,
int defaultMaxPerRoute,
int maxTotal)
|
Method Summary | |
---|---|
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. Please note that this class does not maintain its own pool of execution Thread s. |
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractConnPool(ConnFactory<T,C> connFactory, int defaultMaxPerRoute, int maxTotal)
Method Detail |
---|
protected abstract E createEntry(T route, C conn)
public boolean isShutdown()
public void shutdown() throws IOException
IOException
public Future<E> lease(T route, Object state, FutureCallback<E> callback)
Thread
s. 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)
Thread
s. 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)
ConnPool
release
in interface ConnPool<T,E extends PoolEntry<T,C>>
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 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()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |