Package org.apache.http.impl.conn.tsccm
Class ConnPoolByRoute
- java.lang.Object
-
- org.apache.http.impl.conn.tsccm.AbstractConnPool
-
- org.apache.http.impl.conn.tsccm.ConnPoolByRoute
-
@Deprecated public class ConnPoolByRoute extends AbstractConnPool
Deprecated.(4.2) useAbstractConnPool
A connection pool that maintains connections by route. This class is derived fromMultiThreadedHttpConnectionManager
in HttpClient 3.x, see there for original authors. It implements the same algorithm for connection re-use and connection-per-host enforcement:- connections are re-used only for the exact same route
- connection limits are enforced per route rather than per host
poolLock
in the base class, not viasynchronized
methods.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description protected ConnPerRoute
connPerRoute
Deprecated.Connections per route lookupprotected java.util.Queue<BasicPoolEntry>
freeConnections
Deprecated.The list of free connectionsprotected java.util.Set<BasicPoolEntry>
leasedConnections
Deprecated.References to issued connectionsprotected int
maxTotalConnections
Deprecated.protected int
numConnections
Deprecated.protected ClientConnectionOperator
operator
Deprecated.Connection operator for this poolprotected java.util.Map<HttpRoute,RouteSpecificPool>
routeToPool
Deprecated.Map of route-specific poolsprotected boolean
shutdown
Deprecated.protected java.util.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
Constructors Constructor 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, java.util.concurrent.TimeUnit connTTLTimeUnit)
Deprecated.ConnPoolByRoute(ClientConnectionOperator operator, org.apache.http.params.HttpParams params)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
closeExpiredConnections()
Deprecated.void
closeIdleConnections(long idletime, java.util.concurrent.TimeUnit timeUnit)
Deprecated.Closes idle connections.protected BasicPoolEntry
createEntry(RouteSpecificPool rospl, ClientConnectionOperator op)
Deprecated.Creates a new pool entry.protected java.util.Queue<BasicPoolEntry>
createFreeConnQueue()
Deprecated.Creates the queue forfreeConnections
.protected java.util.Map<HttpRoute,RouteSpecificPool>
createRouteToPoolMap()
Deprecated.Creates the map forrouteToPool
.protected java.util.Queue<WaitingThread>
createWaitingThreadQueue()
Deprecated.Creates the queue forwaitingThreads
.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, java.util.concurrent.TimeUnit timeUnit)
Deprecated.Returns an entry into the pool.int
getConnectionsInPool()
Deprecated.int
getConnectionsInPool(HttpRoute route)
Deprecated.protected BasicPoolEntry
getEntryBlocking(HttpRoute route, java.lang.Object state, long timeout, java.util.concurrent.TimeUnit timeUnit, WaitingThreadAborter aborter)
Deprecated.Obtains a pool entry with a connection within the given timeout.protected BasicPoolEntry
getFreeEntry(RouteSpecificPool rospl, java.lang.Object state)
Deprecated.If available, get a free pool entry for a route.protected java.util.concurrent.locks.Lock
getLock()
Deprecated.int
getMaxTotalConnections()
Deprecated.since 4.1protected 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(java.util.concurrent.locks.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, java.lang.Object state)
Deprecated.Returns a newPoolEntryRequest
, from which aBasicPoolEntry
can be obtained, or the request can be aborted.void
setMaxTotalConnections(int max)
Deprecated.since 4.1void
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
-
-
-
-
Field Detail
-
operator
protected final ClientConnectionOperator operator
Deprecated.Connection operator for this pool
-
connPerRoute
protected final ConnPerRoute connPerRoute
Deprecated.Connections per route lookup
-
leasedConnections
protected final java.util.Set<BasicPoolEntry> leasedConnections
Deprecated.References to issued connections
-
freeConnections
protected final java.util.Queue<BasicPoolEntry> freeConnections
Deprecated.The list of free connections
-
waitingThreads
protected final java.util.Queue<WaitingThread> waitingThreads
Deprecated.The list of WaitingThreads waiting for a connection
-
routeToPool
protected final java.util.Map<HttpRoute,RouteSpecificPool> routeToPool
Deprecated.Map of route-specific pools
-
shutdown
protected volatile boolean shutdown
Deprecated.
-
maxTotalConnections
protected volatile int maxTotalConnections
Deprecated.
-
numConnections
protected volatile int numConnections
Deprecated.
-
-
Constructor Detail
-
ConnPoolByRoute
public ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections)
Deprecated.Creates a new connection pool, managed by route.- Since:
- 4.1
-
ConnPoolByRoute
public ConnPoolByRoute(ClientConnectionOperator operator, ConnPerRoute connPerRoute, int maxTotalConnections, long connTTL, java.util.concurrent.TimeUnit connTTLTimeUnit)
Deprecated.- Since:
- 4.1
-
ConnPoolByRoute
@Deprecated public ConnPoolByRoute(ClientConnectionOperator operator, org.apache.http.params.HttpParams params)
Deprecated.Creates a new connection pool, managed by route.
-
-
Method Detail
-
getLock
protected java.util.concurrent.locks.Lock getLock()
Deprecated.
-
createFreeConnQueue
protected java.util.Queue<BasicPoolEntry> createFreeConnQueue()
Deprecated.Creates the queue forfreeConnections
. Called once by the constructor.- Returns:
- a queue
-
createWaitingThreadQueue
protected java.util.Queue<WaitingThread> createWaitingThreadQueue()
Deprecated.Creates the queue forwaitingThreads
. Called once by the constructor.- Returns:
- a queue
-
createRouteToPoolMap
protected java.util.Map<HttpRoute,RouteSpecificPool> createRouteToPoolMap()
Deprecated.Creates the map forrouteToPool
. Called once by the constructor.- Returns:
- a map
-
newRouteSpecificPool
protected RouteSpecificPool newRouteSpecificPool(HttpRoute route)
Deprecated.Creates a new route-specific pool. Called bygetRoutePool(org.apache.http.conn.routing.HttpRoute, boolean)
when necessary.- Parameters:
route
- the route- Returns:
- the new pool
-
newWaitingThread
protected WaitingThread newWaitingThread(java.util.concurrent.locks.Condition cond, RouteSpecificPool rospl)
Deprecated.Creates a new waiting thread. Called bygetRoutePool(org.apache.http.conn.routing.HttpRoute, boolean)
when necessary.- Parameters:
cond
- the condition to wait forrospl
- the route specific pool, ornull
- Returns:
- a waiting thread representation
-
getRoutePool
protected RouteSpecificPool getRoutePool(HttpRoute route, boolean create)
Deprecated.Get a route-specific pool of available connections.- Parameters:
route
- the routecreate
- whether to create the pool if it doesn't exist- Returns:
- the pool for the argument route,
never
null
ifcreate
istrue
-
getConnectionsInPool
public int getConnectionsInPool(HttpRoute route)
Deprecated.
-
getConnectionsInPool
public int getConnectionsInPool()
Deprecated.
-
requestPoolEntry
public PoolEntryRequest requestPoolEntry(HttpRoute route, java.lang.Object state)
Deprecated.Description copied from class:AbstractConnPool
Returns a newPoolEntryRequest
, from which aBasicPoolEntry
can be obtained, or the request can be aborted.- Specified by:
requestPoolEntry
in classAbstractConnPool
- Parameters:
route
- the routestate
- the state- Returns:
- the entry request
-
getEntryBlocking
protected BasicPoolEntry getEntryBlocking(HttpRoute route, java.lang.Object state, long timeout, java.util.concurrent.TimeUnit timeUnit, WaitingThreadAborter aborter) throws ConnectionPoolTimeoutException, java.lang.InterruptedException
Deprecated.Obtains a pool entry with a connection within the given timeout. If aWaitingThread
is used to block,WaitingThreadAborter.setWaitingThread(WaitingThread)
must be called before blocking, to allow the thread to be interrupted.- Parameters:
route
- the route for which to get the connectiontimeout
- the timeout, 0 or negative for no timeouttimeUnit
- the unit for thetimeout
, may benull
only if there is no timeoutaborter
- an object which can abort aWaitingThread
.- Returns:
- pool entry holding a connection for the route
- Throws:
ConnectionPoolTimeoutException
- if the timeout expiredjava.lang.InterruptedException
- if the calling thread was interrupted
-
freeEntry
public void freeEntry(BasicPoolEntry entry, boolean reusable, long validDuration, java.util.concurrent.TimeUnit timeUnit)
Deprecated.Description copied from class:AbstractConnPool
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.- Specified by:
freeEntry
in classAbstractConnPool
- Parameters:
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.
-
getFreeEntry
protected BasicPoolEntry getFreeEntry(RouteSpecificPool rospl, java.lang.Object state)
Deprecated.If available, get a free pool entry for a route.- Parameters:
rospl
- the route-specific pool from which to get an entry- Returns:
- an available pool entry for the given route, or
null
if none is available
-
createEntry
protected BasicPoolEntry createEntry(RouteSpecificPool rospl, ClientConnectionOperator op)
Deprecated.Creates a new pool entry. This method assumes that the new connection will be handed out immediately.- Parameters:
rospl
- the route-specific pool for which to create the entryop
- the operator for creating a connection- Returns:
- the new pool entry for a new connection
-
deleteEntry
protected void deleteEntry(BasicPoolEntry entry)
Deprecated.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.
- Parameters:
entry
- the pool entry for the connection to delete
-
deleteLeastUsedEntry
protected void deleteLeastUsedEntry()
Deprecated.Delete an old, free pool entry to make room for a new one. Used to replace pool entries with ones for a different route.
-
handleLostEntry
protected void handleLostEntry(HttpRoute route)
Deprecated.- Specified by:
handleLostEntry
in classAbstractConnPool
-
notifyWaitingThread
protected void notifyWaitingThread(RouteSpecificPool rospl)
Deprecated.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.- Parameters:
rospl
- the pool in which to notify, ornull
-
deleteClosedConnections
public void deleteClosedConnections()
Deprecated.Description copied from class:AbstractConnPool
Deletes all entries for closed connections.- Specified by:
deleteClosedConnections
in classAbstractConnPool
-
closeIdleConnections
public void closeIdleConnections(long idletime, java.util.concurrent.TimeUnit timeUnit)
Deprecated.Closes idle connections.- Overrides:
closeIdleConnections
in classAbstractConnPool
- Parameters:
idletime
- the time the connections should have been idle in order to be closed nowtimeUnit
- the unit for theidletime
-
closeExpiredConnections
public void closeExpiredConnections()
Deprecated.- Overrides:
closeExpiredConnections
in classAbstractConnPool
-
shutdown
public void shutdown()
Deprecated.Description copied from class:AbstractConnPool
Shuts down this pool and all associated resources. Overriding methods MUST call the implementation here!- Overrides:
shutdown
in classAbstractConnPool
-
setMaxTotalConnections
public void setMaxTotalConnections(int max)
Deprecated.since 4.1
-
getMaxTotalConnections
public int getMaxTotalConnections()
Deprecated.since 4.1
-
-