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

public Class PoolingClientConnectionManager

extends Object
implements ClientConnectionManager, ConnPoolControl<HttpRoute>
Class Inheritance
All Implemented Interfaces
org.apache.http.pool.ConnPoolControl, org.apache.http.conn.ClientConnectionManager
Annotations
@Deprecated
@Contract
threading:SAFE_CONDITIONAL
Imports
java.io.IOException, java.util.concurrent.ExecutionException, .Future, .TimeUnit, .TimeoutException, org.apache.commons.logging.Log, .LogFactory, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.conn.ClientConnectionManager, .ClientConnectionOperator, .ClientConnectionRequest, .ConnectionPoolTimeoutException, .DnsResolver, .ManagedClientConnection, org.apache.http.conn.routing.HttpRoute, org.apache.http.conn.scheme.SchemeRegistry, org.apache.http.pool.ConnPoolControl, .PoolStats, org.apache.http.util.Args, .Asserts

Deprecated

(4.3) use PoolingHttpClientConnectionManager.

Manages a pool of org.apache.http.conn.OperatedClientConnection and is able to service connection requests from multiple execution threads. Connections are pooled on a per route basis. A request for a route which already the manager has persistent connections for available in the pool will be services by leasing a connection from the pool rather than creating a brand new connection.

PoolingConnectionManager maintains a maximum limit of connection on a per route basis and in total. Per default this implementation will create no more than than 2 concurrent connections per given route and no more 20 connections in total. For many real-world applications these limits may prove too constraining, especially if they use HTTP as a transport protocol for their services. Connection limits, however, can be adjusted using HTTP parameters.

Since
4.2

Field Summary

Modifier and TypeField and Description
private final DnsResolver
dnsResolver

the custom-configured DNS lookup mechanism.

private final Log
private final ClientConnectionOperator
operator

Deprecated as a consequence of ClientConnectionOperator being deprecated.
private final HttpConnPool
pool

Deprecated as a consequence of HttpConnPool being deprecated.
private final SchemeRegistry
schemeRegistry

Deprecated as a consequence of SchemeRegistry being deprecated.

Constructor Summary

AccessConstructor and Description
public
PoolingClientConnectionManager(final SchemeRegistry schreg)

Deprecated as a consequence of SchemeRegistry being deprecated.
public
PoolingClientConnectionManager(final SchemeRegistry schreg, final DnsResolver dnsResolver)

Deprecated as a consequence of SchemeRegistry being deprecated.
public
public
PoolingClientConnectionManager(final SchemeRegistry schemeRegistry, final long timeToLive, final TimeUnit timeUnit)

Deprecated as a consequence of SchemeRegistry being deprecated.
public
PoolingClientConnectionManager(final SchemeRegistry schemeRegistry, final long timeToLive, final TimeUnit timeUnit, final DnsResolver dnsResolver)

Deprecated as a consequence of SchemeRegistry being deprecated.

Method Summary

Modifier and TypeMethod and Description
public void
public void
closeIdleConnections(final long
the idle time of connections to be closed
idleTimeout
,
final TimeUnit
the unit for the idletime
timeUnit
)

Implements org.apache.http.conn.ClientConnectionManager.closeIdleConnections.

Closes idle connections in the pool.
protected ClientConnectionOperator

Returns:

the connection operator to use
createConnectionOperator
(final SchemeRegistry
the scheme registry.
schreg
)

Deprecated as a consequence of SchemeRegistry and ClientConnectionOperator being deprecated.
Hook for creating the connection operator.
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
private String
format(final HttpRoute route, final Object state)

private String
format(final HttpPoolEntry entry)

Deprecated as a consequence of HttpPoolEntry being deprecated.
private String
formatStats(final HttpRoute route)

public int
public int
public int
public SchemeRegistry
getSchemeRegistry()

Implements org.apache.http.conn.ClientConnectionManager.getSchemeRegistry.

Deprecated as a consequence of SchemeRegistry being deprecated.
Obtains the scheme registry used by this manager.
public PoolStats
public PoolStats
pack-priv ManagedClientConnection
leaseConnection(final Future<HttpPoolEntry> future, final long timeout, final TimeUnit timeUnit)

Deprecated as a consequence of ManagedClientConnection being deprecated.
public void
releaseConnection(final ManagedClientConnection
the connection to release
conn
,
final long
the duration of time this connection is valid for reuse
keepalive
,
final TimeUnit
the unit of time validDuration is measured in
timeUnit
)

Implements org.apache.http.conn.ClientConnectionManager.releaseConnection.

Deprecated as a consequence of ManagedClientConnection being deprecated.
Releases a connection for use by others.
public ClientConnectionRequest
requestConnection(final HttpRoute route, final Object state)

Implements org.apache.http.conn.ClientConnectionManager.requestConnection.

Deprecated as a consequence of ClientConnectionRequest being deprecated.
Returns a new ClientConnectionRequest, from which a ManagedClientConnection can be obtained or the request can be aborted.
public void
public void
public void
public void
shutdown()

Implements org.apache.http.conn.ClientConnectionManager.shutdown.

Shuts down this connection manager and releases allocated resources.
Inherited from java.lang.Object:
cloneequalsgetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dnsResolverback to summary
private final DnsResolver dnsResolver

the custom-configured DNS lookup mechanism.

logback to summary
private final Log log
operatorback to summary
private final ClientConnectionOperator operator

Deprecated

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

poolback to summary
private final HttpConnPool pool

Deprecated

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

schemeRegistryback to summary
private final SchemeRegistry schemeRegistry

Deprecated

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

Constructor Detail

PoolingClientConnectionManagerback to summary
public PoolingClientConnectionManager(final SchemeRegistry schreg)

Deprecated

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

PoolingClientConnectionManagerback to summary
public PoolingClientConnectionManager(final SchemeRegistry schreg, final DnsResolver dnsResolver)

Deprecated

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

PoolingClientConnectionManagerback to summary
public PoolingClientConnectionManager()
PoolingClientConnectionManagerback to summary
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry, final long timeToLive, final TimeUnit timeUnit)

Deprecated

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

PoolingClientConnectionManagerback to summary
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry, final long timeToLive, final TimeUnit timeUnit, final DnsResolver dnsResolver)

Deprecated

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

Method Detail

closeExpiredConnectionsback to summary
public void closeExpiredConnections()

Implements org.apache.http.conn.ClientConnectionManager.closeExpiredConnections.

Doc from org.apache.http.conn.ClientConnectionManager.closeExpiredConnections.

Closes all expired connections in the pool. Open connections in the pool that have not been used for the timespan defined when the connection was released will be closed. Currently allocated connections are not subject to this method. Times will be checked with milliseconds precision.

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

Implements org.apache.http.conn.ClientConnectionManager.closeIdleConnections.

Doc from org.apache.http.conn.ClientConnectionManager.closeIdleConnections.

Closes idle connections in the pool. Open connections in the pool that have not been used for the timespan given by the argument will be closed. Currently allocated connections are not subject to this method. Times will be checked with milliseconds precision All expired connections will also be closed.

Parameters
idleTimeout:long

the idle time of connections to be closed

timeUnit:TimeUnit

the unit for the idletime

Annotations
@Override
createConnectionOperatorback to summary
protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry schreg)

Deprecated

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

Hook for creating the connection operator. It is called by the constructor. Derived classes can override this method to change the instantiation of the operator. The default implementation here instantiates DefaultClientConnectionOperator.

Parameters
schreg:SchemeRegistry

the scheme registry.

Returns:ClientConnectionOperator

the connection operator to use

finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
formatback to summary
private String format(final HttpRoute route, final Object state)
formatback to summary
private String format(final HttpPoolEntry entry)

Deprecated

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

formatStatsback to summary
private String formatStats(final HttpRoute route)
getDefaultMaxPerRouteback to summary
public int getDefaultMaxPerRoute()

Implements org.apache.http.pool.ConnPoolControl.getDefaultMaxPerRoute.

Annotations
@Override
getMaxPerRouteback to summary
public int getMaxPerRoute(final HttpRoute route)

Implements org.apache.http.pool.ConnPoolControl.getMaxPerRoute.

Annotations
@Override
getMaxTotalback to summary
public int getMaxTotal()

Implements org.apache.http.pool.ConnPoolControl.getMaxTotal.

Annotations
@Override
getSchemeRegistryback to summary
public SchemeRegistry getSchemeRegistry()

Implements org.apache.http.conn.ClientConnectionManager.getSchemeRegistry.

Doc from org.apache.http.conn.ClientConnectionManager.getSchemeRegistry.

Deprecated

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

Obtains the scheme registry used by this manager.

Returns:SchemeRegistry

the scheme registry, never null

Annotations
@Override
getStatsback to summary
public PoolStats getStats(final HttpRoute route)

Implements org.apache.http.pool.ConnPoolControl.getStats.

Annotations
@Override
getTotalStatsback to summary
public PoolStats getTotalStats()

Implements org.apache.http.pool.ConnPoolControl.getTotalStats.

Annotations
@Override
leaseConnectionback to summary
pack-priv ManagedClientConnection leaseConnection(final Future<HttpPoolEntry> future, final long timeout, final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException

Deprecated

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

releaseConnectionback to summary
public void releaseConnection(final ManagedClientConnection conn, final long keepalive, final TimeUnit timeUnit)

Implements org.apache.http.conn.ClientConnectionManager.releaseConnection.

Doc from org.apache.http.conn.ClientConnectionManager.releaseConnection.

Deprecated

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

Releases a connection for use by others. You may optionally specify how long the connection is valid to be reused. Values <= 0 are considered to be valid forever. If the connection is not marked as reusable, the connection will not be reused regardless of the valid duration. If the connection has been released before, the call will be ignored.

Parameters
conn:ManagedClientConnection

the connection to release

keepalive:long

the duration of time this connection is valid for reuse

timeUnit:TimeUnit

the unit of time validDuration is measured in

Annotations
@Override
requestConnectionback to summary
public ClientConnectionRequest requestConnection(final HttpRoute route, final Object state)

Implements org.apache.http.conn.ClientConnectionManager.requestConnection.

Doc from org.apache.http.conn.ClientConnectionManager.requestConnection.

Deprecated

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

Returns a new ClientConnectionRequest, from which a ManagedClientConnection can be obtained or the request can be aborted.

Annotations
@Override
setDefaultMaxPerRouteback to summary
public void setDefaultMaxPerRoute(final int max)

Implements org.apache.http.pool.ConnPoolControl.setDefaultMaxPerRoute.

Annotations
@Override
setMaxPerRouteback to summary
public void setMaxPerRoute(final HttpRoute route, final int max)

Implements org.apache.http.pool.ConnPoolControl.setMaxPerRoute.

Annotations
@Override
setMaxTotalback to summary
public void setMaxTotal(final int max)

Implements org.apache.http.pool.ConnPoolControl.setMaxTotal.

Annotations
@Override
shutdownback to summary
public void shutdown()

Implements org.apache.http.conn.ClientConnectionManager.shutdown.

Doc from org.apache.http.conn.ClientConnectionManager.shutdown.

Shuts down this connection manager and releases allocated resources. This includes closing all connections, whether they are currently used or not.

Annotations
@Override