|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.http.impl.conn.tsccm.AbstractConnPool
org.apache.http.impl.conn.tsccm.ConnPoolByRoute
public class ConnPoolByRoute
A connection pool that maintains connections by route.
This class is derived from MultiThreadedHttpConnectionManager
in HttpClient 3.x, see there for original authors. It implements the same
algorithm for connection re-use and connection-per-host enforcement:
Nested Class Summary | |
---|---|
protected static class |
ConnPoolByRoute.WaitingThread
A thread and the pool in which it is waiting. |
Field Summary |
---|
Fields inherited from class org.apache.http.impl.conn.tsccm.AbstractConnPool |
---|
connManager, idleConnHandler, isShutDown, issuedConnections, numConnections, params, refQueue |
Constructor Summary | |
---|---|
ConnPoolByRoute(ClientConnectionManager mgr)
Creates a new connection pool, managed by route. |
Method Summary | |
---|---|
protected BasicPoolEntry |
createEntry(RouteSpecificPool rospl,
ClientConnectionOperator op)
Creates a new pool entry. |
void |
deleteClosedConnections()
Deletes all entries for closed connections. |
protected void |
deleteEntry(BasicPoolEntry entry)
Deletes a given pool entry. |
protected void |
deleteLeastUsedEntry()
Delete an old, free pool entry to make room for a new one. |
void |
freeEntry(BasicPoolEntry entry)
Returns an entry into the pool. |
int |
getConnectionsInPool(HttpRoute route)
|
BasicPoolEntry |
getEntry(HttpRoute route,
long timeout,
ClientConnectionOperator operator)
Obtains a pool entry with a connection within the given timeout. |
protected BasicPoolEntry |
getFreeEntry(RouteSpecificPool rospl)
If available, get a free pool entry for a route. |
protected RouteSpecificPool |
getRoutePool(HttpRoute route,
boolean create)
Get a route-specific pool of available connections. |
protected void |
handleLostEntry(HttpRoute route)
Handles cleaning up for a lost pool entry with the given route. |
protected RouteSpecificPool |
newRouteSpecificPool(HttpRoute route)
Creates a new route-specific pool. |
protected void |
notifyWaitingThread(RouteSpecificPool rospl)
Notifies a waiting thread that a connection is available. |
void |
shutdown()
Shuts down this pool and all associated resources. |
Methods inherited from class org.apache.http.impl.conn.tsccm.AbstractConnPool |
---|
closeConnection, closeIdleConnections, handleReference |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConnPoolByRoute(ClientConnectionManager mgr)
mgr
- the connection managerMethod Detail |
---|
protected RouteSpecificPool getRoutePool(HttpRoute route, boolean create)
route
- the routecreate
- whether to create the pool if it doesn't exist
null
if create
is true
protected RouteSpecificPool newRouteSpecificPool(HttpRoute route)
getRoutePool
, if necessary.
route
- the route
public int getConnectionsInPool(HttpRoute route)
public BasicPoolEntry getEntry(HttpRoute route, long timeout, ClientConnectionOperator operator) throws ConnectionPoolTimeoutException, java.lang.InterruptedException
AbstractConnPool
getEntry
in class AbstractConnPool
route
- the route for which to get the connectiontimeout
- the timeout, or 0 for no timeoutoperator
- the connection operator, in case
a connection has to be created
ConnectionPoolTimeoutException
- if the timeout expired
java.lang.InterruptedException
- if the calling thread was interruptedpublic void freeEntry(BasicPoolEntry entry)
AbstractConnPool
freeEntry
in class AbstractConnPool
entry
- the entry for the connection to releaseprotected BasicPoolEntry getFreeEntry(RouteSpecificPool rospl)
rospl
- the route-specific pool from which to get an entry
null
if none is availableprotected BasicPoolEntry createEntry(RouteSpecificPool rospl, ClientConnectionOperator op)
rospl
- the route-specific pool for which to create the entryop
- the operator for creating a connection
protected void deleteEntry(BasicPoolEntry entry)
Note: Does not remove the entry from the freeConnections list. It is assumed that the caller has already handled this step.
entry
- the pool entry for the connection to deleteprotected void deleteLeastUsedEntry()
protected void handleLostEntry(HttpRoute route)
AbstractConnPool
handleLostEntry
in class AbstractConnPool
route
- the route of the pool entry that was lostprotected void notifyWaitingThread(RouteSpecificPool rospl)
rospl
- the pool in which to notify, or null
public void deleteClosedConnections()
AbstractConnPool
deleteClosedConnections
in class AbstractConnPool
public void shutdown()
AbstractConnPool
shutdown
in class AbstractConnPool
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |