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.| Modifier and Type | Field and Description |
|---|---|
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
|
idleConnHandler, isShutDown, issuedConnections, refQueue| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
closeConnection, enableConnectionGC, getEntry, handleReferenceprotected 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
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)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 routeprotected 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 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, Object state)
AbstractConnPoolPoolEntryRequest, from which a BasicPoolEntry
can be obtained, or the request can be aborted.requestPoolEntry in class AbstractConnPoolroute - the routestate - the stateprotected 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 expiredInterruptedException - if the calling thread was interruptedpublic void freeEntry(BasicPoolEntry entry, boolean reusable, long validDuration, TimeUnit timeUnit)
AbstractConnPoolfreeEntry in class 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, 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 in class AbstractConnPoolprotected void notifyWaitingThread(RouteSpecificPool rospl)
rospl - the pool in which to notify, or nullpublic void deleteClosedConnections()
AbstractConnPooldeleteClosedConnections in class AbstractConnPoolpublic void closeIdleConnections(long idletime,
TimeUnit timeUnit)
closeIdleConnections in class AbstractConnPoolidletime - the time the connections should have been idle
in order to be closed nowtimeUnit - the unit for the idletimepublic void closeExpiredConnections()
closeExpiredConnections in class AbstractConnPoolpublic void shutdown()
AbstractConnPoolshutdown in class AbstractConnPoolpublic void setMaxTotalConnections(int max)
public int getMaxTotalConnections()
Copyright © 1999–2022 The Apache Software Foundation. All rights reserved.