Top Description Fields Constructors Methods
org.apache.http.impl.conn.tsccm

public Class ConnPoolByRoute

extends AbstractConnPool
Class Inheritance
Annotations
@Deprecated
Imports
java.io.IOException, java.util.Date, .HashMap, .Iterator, .LinkedList, .Map, .Queue, .Set, java.util.concurrent.TimeUnit, java.util.concurrent.locks.Condition, .Lock, org.apache.commons.logging.Log, .LogFactory, org.apache.http.conn.ClientConnectionOperator, .ConnectionPoolTimeoutException, .OperatedClientConnection, org.apache.http.conn.params.ConnManagerParams, .ConnPerRoute, org.apache.http.conn.routing.HttpRoute, org.apache.http.params.HttpParams, org.apache.http.util.Args, .Asserts

Deprecated

(4.2) use org.apache.http.pool.AbstractConnPool

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: Note that access to the pool data structures is synchronized via the poolLock in the base class, not via synchronized methods.
Since
4.0

Field Summary

Modifier and TypeField and Description
protected final ConnPerRoute
connPerRoute

Connections per route lookup

private final long
private final TimeUnit
protected final Queue<BasicPoolEntry>
freeConnections

The list of free connections

protected final Set<BasicPoolEntry>
private final Log
protected volatile int
protected volatile int
protected final ClientConnectionOperator
operator

Connection operator for this pool

private final Lock
protected final Map<HttpRoute, RouteSpecificPool>
routeToPool

Map of route-specific pools

protected volatile boolean
protected final Queue<WaitingThread>
waitingThreads

The list of WaitingThreads waiting for a connection

Inherited from org.apache.http.impl.conn.tsccm.AbstractConnPool:
idleConnHandlerisShutDownissuedConnectionsrefQueue

Constructor Summary

AccessConstructor and Description
public
ConnPoolByRoute(final ClientConnectionOperator operator, final ConnPerRoute connPerRoute, final int maxTotalConnections)

Deprecated as a consequence of ClientConnectionOperator and ConnPerRoute being deprecated.
Creates a new connection pool, managed by route.
public
ConnPoolByRoute(final ClientConnectionOperator operator, final ConnPerRoute connPerRoute, final int maxTotalConnections, final long connTTL, final TimeUnit connTTLTimeUnit)

Deprecated as a consequence of ClientConnectionOperator and ConnPerRoute being deprecated.
public
ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params)

Creates a new connection pool, managed by route.

Method Summary

Modifier and TypeMethod and Description
private void
closeConnection(final BasicPoolEntry entry)

Deprecated as a consequence of BasicPoolEntry being deprecated.
public void
public void
closeIdleConnections(final long
the time the connections should have been idle in order to be closed now
idletime
,
final TimeUnit
the unit for the idletime
timeUnit
)

Overrides org.apache.http.impl.conn.tsccm.AbstractConnPool.closeIdleConnections.

Closes idle connections.
protected BasicPoolEntry

Returns:

the new pool entry for a new connection
createEntry
(final RouteSpecificPool
the route-specific pool for which to create the entry
rospl
,
final ClientConnectionOperator
the operator for creating a connection
op
)

Deprecated as a consequence of RouteSpecificPool, ClientConnectionOperator and BasicPoolEntry being deprecated.
Creates a new pool entry.
protected Queue<BasicPoolEntry>

Returns:

a queue
createFreeConnQueue
()

Creates the queue for freeConnections.

protected Map<HttpRoute, RouteSpecificPool>

Returns:

a map
createRouteToPoolMap
()

Creates the map for routeToPool.

protected Queue<WaitingThread>

Returns:

a queue
createWaitingThreadQueue
()

Creates the queue for waitingThreads.

public void
deleteClosedConnections()

Implements abstract org.apache.http.impl.conn.tsccm.AbstractConnPool.deleteClosedConnections.

Deletes all entries for closed connections.
protected void
deleteEntry(final BasicPoolEntry
the pool entry for the connection to delete
entry
)

Deprecated as a consequence of BasicPoolEntry being deprecated.
Deletes a given pool entry.
protected void
deleteLeastUsedEntry()

Delete an old, free pool entry to make room for a new one.

public void
freeEntry(final BasicPoolEntry
the entry for the connection to release
entry
,
final boolean
true if the entry is deemed reusable, false otherwise.
reusable
,
final long
The duration that the entry should remain free and reusable.
validDuration
,
final TimeUnit
The unit of time the duration is measured in.
timeUnit
)

Implements abstract org.apache.http.impl.conn.tsccm.AbstractConnPool.freeEntry.

Deprecated as a consequence of BasicPoolEntry being deprecated.
Returns an entry into the pool.
public int
public int
protected BasicPoolEntry

Returns:

pool entry holding a connection for the route
getEntryBlocking
(final HttpRoute
the route for which to get the connection
route
,
final Object state, final long
the timeout, 0 or negative for no timeout
timeout
,
final TimeUnit
the unit for the timeout, may be null only if there is no timeout
timeUnit
,
final WaitingThreadAborter
an object which can abort a WaitingThread.
aborter
)

Deprecated as a consequence of WaitingThreadAborter and BasicPoolEntry being deprecated.
Obtains a pool entry with a connection within the given timeout.
protected BasicPoolEntry

Returns:

an available pool entry for the given route, or null if none is available
getFreeEntry
(final RouteSpecificPool
the route-specific pool from which to get an entry
rospl
,
final Object state)

Deprecated as a consequence of RouteSpecificPool and BasicPoolEntry being deprecated.
If available, get a free pool entry for a route.
protected Lock
public int
protected RouteSpecificPool

Returns:

the pool for the argument route, never null if create is true
getRoutePool
(final HttpRoute
the route
route
,
final boolean
whether to create the pool if it doesn't exist
create
)

Deprecated as a consequence of RouteSpecificPool being deprecated.
Get a route-specific pool of available connections.
protected void
protected RouteSpecificPool

Returns:

the new pool
newRouteSpecificPool
(final HttpRoute
the route
route
)

Deprecated as a consequence of RouteSpecificPool being deprecated.
Creates a new route-specific pool.
protected WaitingThread

Returns:

a waiting thread representation
newWaitingThread
(final Condition
the condition to wait for
cond
,
final RouteSpecificPool
the route specific pool, or null
rospl
)

Deprecated as a consequence of RouteSpecificPool and WaitingThread being deprecated.
Creates a new waiting thread.
protected void
notifyWaitingThread(final RouteSpecificPool
the pool in which to notify, or null
rospl
)

Deprecated as a consequence of RouteSpecificPool being deprecated.
Notifies a waiting thread that a connection is available.
public PoolEntryRequest
requestPoolEntry(final HttpRoute
the route
route
,
final Object
the state
state
)

Implements abstract org.apache.http.impl.conn.tsccm.AbstractConnPool.requestPoolEntry.

Deprecated as a consequence of PoolEntryRequest being deprecated.
Returns a new PoolEntryRequest, from which a BasicPoolEntry can be obtained, or the request can be aborted.
public void
setMaxTotalConnections(final int max)

since 4.1

public void
shutdown()

Overrides org.apache.http.impl.conn.tsccm.AbstractConnPool.shutdown.

Shuts down this pool and all associated resources.
Inherited from org.apache.http.impl.conn.tsccm.AbstractConnPool:
closeConnectionenableConnectionGCgetEntryhandleReference

Field Detail

connPerRouteback to summary
protected final ConnPerRoute connPerRoute

Deprecated

as a consequence of ConnPerRoute being deprecated. See corresponding docs for further information.

Connections per route lookup

connTTLback to summary
private final long connTTL
connTTLTimeUnitback to summary
private final TimeUnit connTTLTimeUnit
freeConnectionsback to summary
protected final Queue<BasicPoolEntry> freeConnections

The list of free connections

leasedConnectionsback to summary
protected final Set<BasicPoolEntry> leasedConnections

Hides org.apache.http.impl.conn.tsccm.AbstractConnPool.leasedConnections.

References to issued connections

logback to summary
private final Log log

Hides org.apache.http.impl.conn.tsccm.AbstractConnPool.log.

maxTotalConnectionsback to summary
protected volatile int maxTotalConnections
numConnectionsback to summary
protected volatile int numConnections

Hides org.apache.http.impl.conn.tsccm.AbstractConnPool.numConnections.

operatorback to summary
protected final ClientConnectionOperator operator

Deprecated

as a consequence of ClientConnectionOperator being deprecated. See corresponding docs for further information.

Connection operator for this pool

poolLockback to summary
private final Lock poolLock

Hides org.apache.http.impl.conn.tsccm.AbstractConnPool.poolLock.

routeToPoolback to summary
protected final Map<HttpRoute, RouteSpecificPool> routeToPool

Map of route-specific pools

shutdownback to summary
protected volatile boolean shutdown
waitingThreadsback to summary
protected final Queue<WaitingThread> waitingThreads

The list of WaitingThreads waiting for a connection

Constructor Detail

ConnPoolByRouteback to summary
public ConnPoolByRoute(final ClientConnectionOperator operator, final ConnPerRoute connPerRoute, final int maxTotalConnections)

Deprecated

as a consequence of ClientConnectionOperator and ConnPerRoute being deprecated. See corresponding docs for further information.

Creates a new connection pool, managed by route.

Since
4.1
ConnPoolByRouteback to summary
public ConnPoolByRoute(final ClientConnectionOperator operator, final ConnPerRoute connPerRoute, final int maxTotalConnections, final long connTTL, final TimeUnit connTTLTimeUnit)

Deprecated

as a consequence of ClientConnectionOperator and ConnPerRoute being deprecated. See corresponding docs for further information.

Since
4.1
ConnPoolByRouteback to summary
public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params)

Creates a new connection pool, managed by route.

Annotations
@Deprecated

Method Detail

closeConnectionback to summary
private void closeConnection(final BasicPoolEntry entry)

Deprecated

as a consequence of BasicPoolEntry being deprecated. See corresponding docs for further information.

closeExpiredConnectionsback to summary
public void closeExpiredConnections()

Overrides org.apache.http.impl.conn.tsccm.AbstractConnPool.closeExpiredConnections.

Annotations
@Override
closeIdleConnectionsback to summary
public void closeIdleConnections(final long idletime, final TimeUnit timeUnit)

Overrides org.apache.http.impl.conn.tsccm.AbstractConnPool.closeIdleConnections.

Closes idle connections.

Parameters
idletime:long

the time the connections should have been idle in order to be closed now

timeUnit:TimeUnit

the unit for the idletime

Annotations
@Override
createEntryback to summary
protected BasicPoolEntry createEntry(final RouteSpecificPool rospl, final ClientConnectionOperator op)

Deprecated

as a consequence of RouteSpecificPool, ClientConnectionOperator and BasicPoolEntry being deprecated. See corresponding docs for further information.

Creates a new pool entry. This method assumes that the new connection will be handed out immediately.

Parameters
rospl:RouteSpecificPool

the route-specific pool for which to create the entry

op:ClientConnectionOperator

the operator for creating a connection

Returns:BasicPoolEntry

the new pool entry for a new connection

createFreeConnQueueback to summary
protected Queue<BasicPoolEntry> createFreeConnQueue()

Creates the queue for freeConnections. Called once by the constructor.

Returns:Queue<BasicPoolEntry>

a queue

createRouteToPoolMapback to summary
protected Map<HttpRoute, RouteSpecificPool> createRouteToPoolMap()

Creates the map for routeToPool. Called once by the constructor.

Returns:Map<HttpRoute, RouteSpecificPool>

a map

createWaitingThreadQueueback to summary
protected Queue<WaitingThread> createWaitingThreadQueue()

Creates the queue for waitingThreads. Called once by the constructor.

Returns:Queue<WaitingThread>

a queue

deleteClosedConnectionsback to summary
public void deleteClosedConnections()

Implements abstract org.apache.http.impl.conn.tsccm.AbstractConnPool.deleteClosedConnections.

Doc from org.apache.http.impl.conn.tsccm.AbstractConnPool.deleteClosedConnections.

Deletes all entries for closed connections.

Annotations
@Override
deleteEntryback to summary
protected void deleteEntry(final BasicPoolEntry entry)

Deprecated

as a consequence of BasicPoolEntry being deprecated. See corresponding docs for further information.

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:BasicPoolEntry

the pool entry for the connection to delete

deleteLeastUsedEntryback to summary
protected void deleteLeastUsedEntry()

Delete an old, free pool entry to make room for a new one. Used to replace pool entries with ones for a different route.

freeEntryback to summary
public void freeEntry(final BasicPoolEntry entry, final boolean reusable, final long validDuration, final TimeUnit timeUnit)

Implements abstract org.apache.http.impl.conn.tsccm.AbstractConnPool.freeEntry.

Doc from org.apache.http.impl.conn.tsccm.AbstractConnPool.freeEntry.

Deprecated

as a consequence of BasicPoolEntry being deprecated. See corresponding docs for further information.

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.

Parameters
entry:BasicPoolEntry

the entry for the connection to release

reusable:boolean

true if the entry is deemed reusable, false otherwise.

validDuration:long

The duration that the entry should remain free and reusable.

timeUnit:TimeUnit

The unit of time the duration is measured in.

Annotations
@Override
getConnectionsInPoolback to summary
public int getConnectionsInPool(final HttpRoute route)
getConnectionsInPoolback to summary
public int getConnectionsInPool()
getEntryBlockingback to summary
protected BasicPoolEntry getEntryBlocking(final HttpRoute route, final Object state, final long timeout, final TimeUnit timeUnit, final WaitingThreadAborter aborter) throws ConnectionPoolTimeoutException, InterruptedException

Deprecated

as a consequence of WaitingThreadAborter and BasicPoolEntry being deprecated. See corresponding docs for further information.

Obtains a pool entry with a connection within the given timeout. If a WaitingThread is used to block, WaitingThreadAborter#setWaitingThread(WaitingThread) must be called before blocking, to allow the thread to be interrupted.

Parameters
route:HttpRoute

the route for which to get the connection

timeout:long

the timeout, 0 or negative for no timeout

timeUnit:TimeUnit

the unit for the timeout, may be null only if there is no timeout

aborter:WaitingThreadAborter

an object which can abort a WaitingThread.

Returns:BasicPoolEntry

pool entry holding a connection for the route

Exceptions
ConnectionPoolTimeoutException:
if the timeout expired
InterruptedException:
if the calling thread was interrupted
getFreeEntryback to summary
protected BasicPoolEntry getFreeEntry(final RouteSpecificPool rospl, final Object state)

Deprecated

as a consequence of RouteSpecificPool and BasicPoolEntry being deprecated. See corresponding docs for further information.

If available, get a free pool entry for a route.

Parameters
rospl:RouteSpecificPool

the route-specific pool from which to get an entry

Returns:BasicPoolEntry

an available pool entry for the given route, or null if none is available

getLockback to summary
protected Lock getLock()
getMaxTotalConnectionsback to summary
public int getMaxTotalConnections()

since 4.1

getRoutePoolback to summary
protected RouteSpecificPool getRoutePool(final HttpRoute route, final boolean create)

Deprecated

as a consequence of RouteSpecificPool being deprecated. See corresponding docs for further information.

Get a route-specific pool of available connections.

Parameters
route:HttpRoute

the route

create:boolean

whether to create the pool if it doesn't exist

Returns:RouteSpecificPool

the pool for the argument route, never null if create is true

handleLostEntryback to summary
protected void handleLostEntry(final HttpRoute route)

Implements abstract org.apache.http.impl.conn.tsccm.AbstractConnPool.handleLostEntry.

Annotations
@Override
newRouteSpecificPoolback to summary
protected RouteSpecificPool newRouteSpecificPool(final HttpRoute route)

Deprecated

as a consequence of RouteSpecificPool being deprecated. See corresponding docs for further information.

Creates a new route-specific pool. Called by getRoutePool when necessary.

Parameters
route:HttpRoute

the route

Returns:RouteSpecificPool

the new pool

newWaitingThreadback to summary
protected WaitingThread newWaitingThread(final Condition cond, final RouteSpecificPool rospl)

Deprecated

as a consequence of RouteSpecificPool and WaitingThread being deprecated. See corresponding docs for further information.

Creates a new waiting thread. Called by getRoutePool when necessary.

Parameters
cond:Condition

the condition to wait for

rospl:RouteSpecificPool

the route specific pool, or null

Returns:WaitingThread

a waiting thread representation

notifyWaitingThreadback to summary
protected void notifyWaitingThread(final RouteSpecificPool rospl)

Deprecated

as a consequence of RouteSpecificPool being deprecated. See corresponding docs for further information.

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:RouteSpecificPool

the pool in which to notify, or null

requestPoolEntryback to summary
public PoolEntryRequest requestPoolEntry(final HttpRoute route, final Object state)

Implements abstract org.apache.http.impl.conn.tsccm.AbstractConnPool.requestPoolEntry.

Doc from org.apache.http.impl.conn.tsccm.AbstractConnPool.requestPoolEntry.

Deprecated

as a consequence of PoolEntryRequest being deprecated. See corresponding docs for further information.

Returns a new PoolEntryRequest, from which a BasicPoolEntry can be obtained, or the request can be aborted.

Parameters
route:HttpRoute

the route

state:Object

the state

Returns:PoolEntryRequest

the entry request

Annotations
@Override
setMaxTotalConnectionsback to summary
public void setMaxTotalConnections(final int max)

since 4.1

shutdownback to summary
public void shutdown()

Overrides org.apache.http.impl.conn.tsccm.AbstractConnPool.shutdown.

Doc from org.apache.http.impl.conn.tsccm.AbstractConnPool.shutdown.

Shuts down this pool and all associated resources. Overriding methods MUST call the implementation here!

Annotations
@Override