AbstractConnPool@Deprecated public class ConnPoolByRoute extends AbstractConnPool
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.| 限定符和类型 | 字段和说明 |
|---|---|
protected ConnPerRoute |
connPerRoute
已过时。
Connections per route lookup
|
protected java.util.Queue<BasicPoolEntry> |
freeConnections
已过时。
The list of free connections
|
protected java.util.Set<BasicPoolEntry> |
leasedConnections
已过时。
References to issued connections
|
protected int |
maxTotalConnections
已过时。
|
protected int |
numConnections
已过时。
|
protected ClientConnectionOperator |
operator
已过时。
Connection operator for this pool
|
protected java.util.Map<HttpRoute,RouteSpecificPool> |
routeToPool
已过时。
Map of route-specific pools
|
protected boolean |
shutdown
已过时。
|
protected java.util.Queue<WaitingThread> |
waitingThreads
已过时。
The list of WaitingThreads waiting for a connection
|
idleConnHandler, isShutDown, issuedConnections, refQueue| 构造器和说明 |
|---|
ConnPoolByRoute(ClientConnectionOperator operator,
ConnPerRoute connPerRoute,
int maxTotalConnections)
已过时。
Creates a new connection pool, managed by route.
|
ConnPoolByRoute(ClientConnectionOperator operator,
ConnPerRoute connPerRoute,
int maxTotalConnections,
long connTTL,
java.util.concurrent.TimeUnit connTTLTimeUnit)
已过时。
|
ConnPoolByRoute(ClientConnectionOperator operator,
HttpParams params)
已过时。
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
closeExpiredConnections()
已过时。
|
void |
closeIdleConnections(long idletime,
java.util.concurrent.TimeUnit tunit)
已过时。
Closes idle connections.
|
protected BasicPoolEntry |
createEntry(RouteSpecificPool rospl,
ClientConnectionOperator op)
已过时。
Creates a new pool entry.
|
protected java.util.Queue<BasicPoolEntry> |
createFreeConnQueue()
已过时。
Creates the queue for
freeConnections. |
protected java.util.Map<HttpRoute,RouteSpecificPool> |
createRouteToPoolMap()
已过时。
Creates the map for
routeToPool. |
protected java.util.Queue<WaitingThread> |
createWaitingThreadQueue()
已过时。
Creates the queue for
waitingThreads. |
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,
boolean reusable,
long validDuration,
java.util.concurrent.TimeUnit timeUnit)
已过时。
Returns an entry into the pool.
|
int |
getConnectionsInPool()
已过时。
|
int |
getConnectionsInPool(HttpRoute route)
已过时。
|
protected BasicPoolEntry |
getEntryBlocking(HttpRoute route,
java.lang.Object state,
long timeout,
java.util.concurrent.TimeUnit tunit,
WaitingThreadAborter aborter)
已过时。
Obtains a pool entry with a connection within the given timeout.
|
protected BasicPoolEntry |
getFreeEntry(RouteSpecificPool rospl,
java.lang.Object state)
已过时。
If available, get a free pool entry for a route.
|
protected java.util.concurrent.locks.Lock |
getLock()
已过时。
|
int |
getMaxTotalConnections()
已过时。
since 4.1
|
protected RouteSpecificPool |
getRoutePool(HttpRoute route,
boolean create)
已过时。
Get a route-specific pool of available connections.
|
protected void |
handleLostEntry(HttpRoute route)
已过时。
|
protected RouteSpecificPool |
newRouteSpecificPool(HttpRoute route)
已过时。
Creates a new route-specific pool.
|
protected WaitingThread |
newWaitingThread(java.util.concurrent.locks.Condition cond,
RouteSpecificPool rospl)
已过时。
Creates a new waiting thread.
|
protected void |
notifyWaitingThread(RouteSpecificPool rospl)
已过时。
Notifies a waiting thread that a connection is available.
|
PoolEntryRequest |
requestPoolEntry(HttpRoute route,
java.lang.Object state)
已过时。
Returns a new
PoolEntryRequest, from which a BasicPoolEntry
can be obtained, or the request can be aborted. |
void |
setMaxTotalConnections(int max)
已过时。
since 4.1
|
void |
shutdown()
已过时。
Shuts down this pool and all associated resources.
|
closeConnection, enableConnectionGC, getEntry, handleReferenceprotected final ClientConnectionOperator operator
protected final ConnPerRoute connPerRoute
protected final java.util.Set<BasicPoolEntry> leasedConnections
protected final java.util.Queue<BasicPoolEntry> freeConnections
protected final java.util.Queue<WaitingThread> waitingThreads
protected final java.util.Map<HttpRoute,RouteSpecificPool> routeToPool
protected volatile boolean shutdown
protected volatile int maxTotalConnections
protected volatile int numConnections
public ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections)
public ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, java.util.concurrent.TimeUnit connTTLTimeUnit)
public ConnPoolByRoute(ClientConnectionOperator operator, HttpParams params)
ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute, int)protected java.util.concurrent.locks.Lock getLock()
protected java.util.Queue<BasicPoolEntry> createFreeConnQueue()
freeConnections.
Called once by the constructor.protected java.util.Queue<WaitingThread> createWaitingThreadQueue()
waitingThreads.
Called once by the constructor.protected java.util.Map<HttpRoute,RouteSpecificPool> createRouteToPoolMap()
routeToPool.
Called once by the constructor.protected RouteSpecificPool newRouteSpecificPool(HttpRoute route)
getRoutePool(depends.org.apache.http.conn.routing.HttpRoute, boolean) when necessary.route - the routeprotected WaitingThread newWaitingThread(java.util.concurrent.locks.Condition cond, RouteSpecificPool rospl)
getRoutePool(depends.org.apache.http.conn.routing.HttpRoute, boolean) when necessary.cond - the condition to wait forrospl - the route specific pool, or nullprotected RouteSpecificPool getRoutePool(HttpRoute route, boolean create)
route - the routecreate - whether to create the pool if it doesn't existnull if create is truepublic int getConnectionsInPool(HttpRoute route)
public int getConnectionsInPool()
public PoolEntryRequest requestPoolEntry(HttpRoute route, java.lang.Object state)
AbstractConnPoolPoolEntryRequest, from which a BasicPoolEntry
can be obtained, or the request can be aborted.requestPoolEntry 在类中 AbstractConnPoolprotected BasicPoolEntry getEntryBlocking(HttpRoute route, java.lang.Object state, long timeout, java.util.concurrent.TimeUnit tunit, WaitingThreadAborter aborter) throws ConnectionPoolTimeoutException, java.lang.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 timeouttunit - 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 expiredjava.lang.InterruptedException - if the calling thread was interruptedpublic void freeEntry(BasicPoolEntry entry, boolean reusable, long validDuration, java.util.concurrent.TimeUnit timeUnit)
AbstractConnPoolfreeEntry 在类中 AbstractConnPoolentry - 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, java.lang.Object state)
rospl - the route-specific pool from which to get an entrynull 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 connectionprotected 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 在类中 AbstractConnPoolprotected void notifyWaitingThread(RouteSpecificPool rospl)
rospl - the pool in which to notify, or nullpublic void deleteClosedConnections()
AbstractConnPooldeleteClosedConnections 在类中 AbstractConnPoolpublic void closeIdleConnections(long idletime,
java.util.concurrent.TimeUnit tunit)
closeIdleConnections 在类中 AbstractConnPoolidletime - the time the connections should have been idle
in order to be closed nowtunit - the unit for the idletimepublic void closeExpiredConnections()
public void shutdown()
AbstractConnPoolshutdown 在类中 AbstractConnPoolpublic void setMaxTotalConnections(int max)
public int getMaxTotalConnections()