java.lang.Object | ||
↳ | org.apache.http.impl.conn.tsccm.AbstractConnPool | |
↳ | org.apache.http.impl.conn.tsccm.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:
poolLock
in the base class,
not via synchronized
methods.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
freeConnections | The list of free connections | ||||||||||
maxTotalConnections | |||||||||||
operator | Connection operator for this pool | ||||||||||
routeToPool | A map of route-specific pools. | ||||||||||
waitingThreads | The list of WaitingThreads waiting for a connection |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.http.impl.conn.tsccm.AbstractConnPool
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new connection pool, managed by route.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Deletes all entries for closed connections.
| |||||||||||
Returns an entry into the pool.
| |||||||||||
Returns a new
PoolEntryRequest , from which a BasicPoolEntry
can be obtained, or the request can be aborted. | |||||||||||
Shuts down this pool and all associated resources.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new pool entry.
| |||||||||||
Creates the queue for
freeConnections . | |||||||||||
Creates the map for
routeToPool . | |||||||||||
Creates the queue for
waitingThreads . | |||||||||||
Deletes a given pool entry.
| |||||||||||
Delete an old, free pool entry to make room for a new one.
| |||||||||||
Obtains a pool entry with a connection within the given timeout.
| |||||||||||
If available, get a free pool entry for a route.
| |||||||||||
Get a route-specific pool of available connections.
| |||||||||||
Handles cleaning up for a lost pool entry with the given route.
| |||||||||||
Creates a new route-specific pool.
| |||||||||||
Creates a new waiting thread.
| |||||||||||
Notifies a waiting thread that a connection is available.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class org.apache.http.impl.conn.tsccm.AbstractConnPool
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface org.apache.http.impl.conn.tsccm.RefQueueHandler
|
Connection operator for this pool
A map of route-specific pools.
Keys are of class HttpRoute
,
values of class RouteSpecificPool
.
The list of WaitingThreads waiting for a connection
Creates a new connection pool, managed by route.
Deletes all entries for closed connections.
Returns an entry into the pool. The connection of the entry is expected to be in a suitable state, either open and re-usable, or closed. The pool will not make any attempt to determine whether it can be re-used or not.
entry | the entry for the connection to release |
---|---|
reusable | true if the entry is deemed
reusable, false otherwise. |
validDuration | The duration that the entry should remain free and reusable. |
timeUnit | The unit of time the duration is measured in. |
Returns a new PoolEntryRequest
, from which a BasicPoolEntry
can be obtained, or the request can be aborted.
Shuts down this pool and all associated resources. Overriding methods MUST call the implementation here!
Creates a new pool entry. This method assumes that the new connection will be handed out immediately.
rospl | the route-specific pool for which to create the entry |
---|---|
op | the operator for creating a connection |
Creates the queue for freeConnections
.
Called once by the constructor.
Creates the map for routeToPool
.
Called once by the constructor.
Creates the queue for waitingThreads
.
Called once by the constructor.
Deletes a given pool entry. This closes the pooled connection and removes all references, so that it can be GCed.
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 delete |
---|
Delete an old, free pool entry to make room for a new one. Used to replace pool entries with ones for a different route.
Obtains a pool entry with a connection within the given timeout.
If a WaitingThread
is used to block, setWaitingThread(WaitingThread)
must be called before blocking, to allow the thread to be interrupted.
route | the route for which to get the connection |
---|---|
timeout | the timeout, 0 or negative for no timeout |
tunit | the unit for the timeout ,
may be null only if there is no timeout |
aborter | an object which can abort a WaitingThread . |
ConnectionPoolTimeoutException | if the timeout expired |
---|---|
InterruptedException | if the calling thread was interrupted |
If available, get a free pool entry for a route.
rospl | the route-specific pool from which to get an entry |
---|
null
if none is available
Get a route-specific pool of available connections.
route | the route |
---|---|
create | whether to create the pool if it doesn't exist |
null
if create
is true
Handles cleaning up for a lost pool entry with the given route. A lost pool entry corresponds to a connection that was garbage collected instead of being properly released.
route | the route of the pool entry that was lost |
---|
Creates a new route-specific pool.
Called by getRoutePool(HttpRoute, boolean)
when necessary.
route | the route |
---|
Creates a new waiting thread.
Called by getRoutePool(HttpRoute, boolean)
when necessary.
cond | the condition to wait for |
---|---|
rospl | the route specific pool, or null |
Notifies a waiting thread that a connection is available. This will wake a thread waiting in the specific route pool, if there is one. Otherwise, a thread in the connection pool will be notified.
rospl | the pool in which to notify, or null
|
---|