|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.http.impl.conn.tsccm.AbstractConnPool org.apache.http.impl.conn.tsccm.ConnPoolByRoute
AbstractConnPool
@Deprecated 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:
poolLock
in the base class,
not via synchronized
methods.
Field Summary | |
---|---|
protected ConnPerRoute |
connPerRoute
Deprecated. Connections per route lookup |
protected Queue<BasicPoolEntry> |
freeConnections
Deprecated. The list of free connections |
protected Set<BasicPoolEntry> |
leasedConnections
Deprecated. References to issued connections |
protected int |
maxTotalConnections
Deprecated. |
protected int |
numConnections
Deprecated. |
protected ClientConnectionOperator |
operator
Deprecated. Connection operator for this pool |
protected Map<HttpRoute,RouteSpecificPool> |
routeToPool
Deprecated. Map of route-specific pools |
protected boolean |
shutdown
Deprecated. |
protected Queue<WaitingThread> |
waitingThreads
Deprecated. The list of WaitingThreads waiting for a connection |
Fields inherited from class org.apache.http.impl.conn.tsccm.AbstractConnPool |
---|
idleConnHandler, isShutDown, issuedConnections, refQueue |
Constructor Summary | |
---|---|
ConnPoolByRoute(ClientConnectionOperator operator,
ConnPerRoute connPerRoute,
int maxTotalConnections)
Deprecated. Creates a new connection pool, managed by route. |
|
ConnPoolByRoute(ClientConnectionOperator operator,
ConnPerRoute connPerRoute,
int maxTotalConnections,
long connTTL,
TimeUnit connTTLTimeUnit)
Deprecated. |
|
ConnPoolByRoute(ClientConnectionOperator operator,
org.apache.http.params.HttpParams params)
Deprecated. (4.1) use ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute, int) |
Method Summary | |
---|---|
void |
closeExpiredConnections()
Deprecated. |
void |
closeIdleConnections(long idletime,
TimeUnit timeUnit)
Deprecated. Closes idle connections. |
protected BasicPoolEntry |
createEntry(RouteSpecificPool rospl,
ClientConnectionOperator op)
Deprecated. Creates a new pool entry. |
protected Queue<BasicPoolEntry> |
createFreeConnQueue()
Deprecated. Creates the queue for freeConnections . |
protected Map<HttpRoute,RouteSpecificPool> |
createRouteToPoolMap()
Deprecated. Creates the map for routeToPool . |
protected Queue<WaitingThread> |
createWaitingThreadQueue()
Deprecated. Creates the queue for waitingThreads . |
void |
deleteClosedConnections()
Deprecated. Deletes all entries for closed connections. |
protected void |
deleteEntry(BasicPoolEntry entry)
Deprecated. Deletes a given pool entry. |
protected void |
deleteLeastUsedEntry()
Deprecated. Delete an old, free pool entry to make room for a new one. |
void |
freeEntry(BasicPoolEntry entry,
boolean reusable,
long validDuration,
TimeUnit timeUnit)
Deprecated. Returns an entry into the pool. |
int |
getConnectionsInPool()
Deprecated. |
int |
getConnectionsInPool(HttpRoute route)
Deprecated. |
protected BasicPoolEntry |
getEntryBlocking(HttpRoute route,
Object state,
long timeout,
TimeUnit timeUnit,
WaitingThreadAborter aborter)
Deprecated. Obtains a pool entry with a connection within the given timeout. |
protected BasicPoolEntry |
getFreeEntry(RouteSpecificPool rospl,
Object state)
Deprecated. If available, get a free pool entry for a route. |
protected Lock |
getLock()
Deprecated. |
int |
getMaxTotalConnections()
Deprecated. since 4.1 |
protected RouteSpecificPool |
getRoutePool(HttpRoute route,
boolean create)
Deprecated. Get a route-specific pool of available connections. |
protected void |
handleLostEntry(HttpRoute route)
Deprecated. |
protected RouteSpecificPool |
newRouteSpecificPool(HttpRoute route)
Deprecated. Creates a new route-specific pool. |
protected WaitingThread |
newWaitingThread(Condition cond,
RouteSpecificPool rospl)
Deprecated. Creates a new waiting thread. |
protected void |
notifyWaitingThread(RouteSpecificPool rospl)
Deprecated. Notifies a waiting thread that a connection is available. |
PoolEntryRequest |
requestPoolEntry(HttpRoute route,
Object state)
Deprecated. Returns a new PoolEntryRequest , from which a BasicPoolEntry
can be obtained, or the request can be aborted. |
void |
setMaxTotalConnections(int max)
Deprecated. since 4.1 |
void |
shutdown()
Deprecated. Shuts down this pool and all associated resources. |
Methods inherited from class org.apache.http.impl.conn.tsccm.AbstractConnPool |
---|
closeConnection, enableConnectionGC, getEntry, handleReference |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final ClientConnectionOperator operator
protected final ConnPerRoute connPerRoute
protected final Set<BasicPoolEntry> leasedConnections
protected final Queue<BasicPoolEntry> freeConnections
protected final Queue<WaitingThread> waitingThreads
protected final Map<HttpRoute,RouteSpecificPool> routeToPool
protected volatile boolean shutdown
protected volatile int maxTotalConnections
protected volatile int numConnections
Constructor Detail |
---|
public ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections)
public ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, TimeUnit connTTLTimeUnit)
@Deprecated public ConnPoolByRoute(ClientConnectionOperator operator, org.apache.http.params.HttpParams params)
ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute, int)
Method Detail |
---|
protected Lock getLock()
protected Queue<BasicPoolEntry> createFreeConnQueue()
freeConnections
.
Called once by the constructor.
protected Queue<WaitingThread> createWaitingThreadQueue()
waitingThreads
.
Called once by the constructor.
protected Map<HttpRoute,RouteSpecificPool> createRouteToPoolMap()
routeToPool
.
Called once by the constructor.
protected RouteSpecificPool newRouteSpecificPool(HttpRoute route)
getRoutePool(org.apache.http.conn.routing.HttpRoute, boolean)
when necessary.
route
- the route
protected WaitingThread newWaitingThread(Condition cond, RouteSpecificPool rospl)
getRoutePool(org.apache.http.conn.routing.HttpRoute, boolean)
when necessary.
cond
- the condition to wait forrospl
- the route specific pool, or null
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
public int getConnectionsInPool(HttpRoute route)
public int getConnectionsInPool()
public PoolEntryRequest requestPoolEntry(HttpRoute route, Object state)
AbstractConnPool
PoolEntryRequest
, from which a BasicPoolEntry
can be obtained, or the request can be aborted.
requestPoolEntry
in class AbstractConnPool
route
- the routestate
- the state
protected BasicPoolEntry getEntryBlocking(HttpRoute route, Object state, long timeout, TimeUnit timeUnit, WaitingThreadAborter aborter) throws ConnectionPoolTimeoutException, InterruptedException
WaitingThread
is used to block, WaitingThreadAborter.setWaitingThread(WaitingThread)
must be called before blocking, to allow the thread to be interrupted.
route
- the route for which to get the connectiontimeout
- the timeout, 0 or negative for no timeouttimeUnit
- the unit for the timeout
,
may be null
only if there is no timeoutaborter
- an object which can abort a WaitingThread
.
ConnectionPoolTimeoutException
- if the timeout expired
InterruptedException
- if the calling thread was interruptedpublic void freeEntry(BasicPoolEntry entry, boolean reusable, long validDuration, TimeUnit timeUnit)
AbstractConnPool
freeEntry
in class AbstractConnPool
entry
- the entry for the connection to releasereusable
- 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.protected BasicPoolEntry getFreeEntry(RouteSpecificPool rospl, Object state)
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)
handleLostEntry
in class AbstractConnPool
protected void notifyWaitingThread(RouteSpecificPool rospl)
rospl
- the pool in which to notify, or null
public void deleteClosedConnections()
AbstractConnPool
deleteClosedConnections
in class AbstractConnPool
public void closeIdleConnections(long idletime, TimeUnit timeUnit)
closeIdleConnections
in class AbstractConnPool
idletime
- the time the connections should have been idle
in order to be closed nowtimeUnit
- the unit for the idletime
public void closeExpiredConnections()
closeExpiredConnections
in class AbstractConnPool
public void shutdown()
AbstractConnPool
shutdown
in class AbstractConnPool
public void setMaxTotalConnections(int max)
public int getMaxTotalConnections()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |