|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.http.impl.conn.PoolingHttpClientConnectionManager
@ThreadSafe public class PoolingHttpClientConnectionManager
ClientConnectionPoolManager maintains a pool of
HttpClientConnections 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.
ConnPoolControl methods.
| Method Summary | |
|---|---|
void |
close()
|
void |
closeExpiredConnections()
Closes all expired connections in the pool. |
void |
closeIdleConnections(long idleTimeout,
java.util.concurrent.TimeUnit tunit)
Closes idle connections in the pool. |
void |
connect(org.apache.http.HttpClientConnection managedConn,
org.apache.http.conn.routing.HttpRoute route,
int connectTimeout,
org.apache.http.protocol.HttpContext context)
Connects the underlying connection socket to the connection target in case of a direct route or to the first proxy hop in case of a route via a proxy (or multiple proxies). |
protected void |
finalize()
|
ConnectionConfig |
getConnectionConfig(org.apache.http.HttpHost host)
|
ConnectionConfig |
getDefaultConnectionConfig()
|
int |
getDefaultMaxPerRoute()
|
SocketConfig |
getDefaultSocketConfig()
|
int |
getMaxPerRoute(org.apache.http.conn.routing.HttpRoute route)
|
int |
getMaxTotal()
|
SocketConfig |
getSocketConfig(org.apache.http.HttpHost host)
|
PoolStats |
getStats(org.apache.http.conn.routing.HttpRoute route)
|
PoolStats |
getTotalStats()
|
protected org.apache.http.HttpClientConnection |
leaseConnection(java.util.concurrent.Future<org.apache.http.impl.conn.CPoolEntry> future,
long timeout,
java.util.concurrent.TimeUnit tunit)
|
void |
releaseConnection(org.apache.http.HttpClientConnection managedConn,
java.lang.Object state,
long keepalive,
java.util.concurrent.TimeUnit tunit)
Releases the connection back to the manager making it potentially re-usable by other consumers. |
ConnectionRequest |
requestConnection(org.apache.http.conn.routing.HttpRoute route,
java.lang.Object state)
Returns a new ConnectionRequest, from which a
HttpClientConnection can be obtained or the request can be
aborted. |
void |
routeComplete(org.apache.http.HttpClientConnection managedConn,
org.apache.http.conn.routing.HttpRoute route,
org.apache.http.protocol.HttpContext context)
Marks the connection as fully established with all its intermediate hops completed. |
void |
setConnectionConfig(org.apache.http.HttpHost host,
ConnectionConfig connectionConfig)
|
void |
setDefaultConnectionConfig(ConnectionConfig defaultConnectionConfig)
|
void |
setDefaultMaxPerRoute(int max)
|
void |
setDefaultSocketConfig(SocketConfig defaultSocketConfig)
|
void |
setMaxPerRoute(org.apache.http.conn.routing.HttpRoute route,
int max)
|
void |
setMaxTotal(int max)
|
void |
setSocketConfig(org.apache.http.HttpHost host,
SocketConfig socketConfig)
|
void |
shutdown()
Shuts down this connection manager and releases allocated resources. |
void |
upgrade(org.apache.http.HttpClientConnection managedConn,
org.apache.http.conn.routing.HttpRoute route,
org.apache.http.protocol.HttpContext context)
Upgrades the underlying connection socket to TLS/SSL (or another layering protocol) after having executed CONNECT method to all
intermediate proxy hops |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PoolingHttpClientConnectionManager()
public PoolingHttpClientConnectionManager(long timeToLive,
java.util.concurrent.TimeUnit tunit)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry,
DnsResolver dnsResolver)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry,
HttpConnectionFactory<org.apache.http.conn.routing.HttpRoute,ManagedHttpClientConnection> connFactory)
public PoolingHttpClientConnectionManager(HttpConnectionFactory<org.apache.http.conn.routing.HttpRoute,ManagedHttpClientConnection> connFactory)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry,
HttpConnectionFactory<org.apache.http.conn.routing.HttpRoute,ManagedHttpClientConnection> connFactory,
DnsResolver dnsResolver)
public PoolingHttpClientConnectionManager(Registry<ConnectionSocketFactory> socketFactoryRegistry,
HttpConnectionFactory<org.apache.http.conn.routing.HttpRoute,ManagedHttpClientConnection> connFactory,
SchemePortResolver schemePortResolver,
DnsResolver dnsResolver,
long timeToLive,
java.util.concurrent.TimeUnit tunit)
| Method Detail |
|---|
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic void close()
close in interface java.io.Closeable
public ConnectionRequest requestConnection(org.apache.http.conn.routing.HttpRoute route,
java.lang.Object state)
HttpClientConnectionManagerConnectionRequest, from which a
HttpClientConnection can be obtained or the request can be
aborted.
Please note that newly allocated connections can be returned
in the closed state. The consumer of that connection is responsible
for fully establishing the route the to the connection target
by calling connect in order to connect
directly to the target or to the first proxy hop, optionally calling
upgrade method to upgrade
the connection after having executed CONNECT method to
all intermediate proxy hops and and finally calling routeComplete to mark the route
as fully completed.
requestConnection in interface HttpClientConnectionManagerroute - HTTP route of the requested connection.state - expected state of the connection or null
if the connection is not expected to carry any state.
protected org.apache.http.HttpClientConnection leaseConnection(java.util.concurrent.Future<org.apache.http.impl.conn.CPoolEntry> future,
long timeout,
java.util.concurrent.TimeUnit tunit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
org.apache.http.conn.ConnectionPoolTimeoutException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
org.apache.http.conn.ConnectionPoolTimeoutException
public void releaseConnection(org.apache.http.HttpClientConnection managedConn,
java.lang.Object state,
long keepalive,
java.util.concurrent.TimeUnit tunit)
HttpClientConnectionManagervalidDuration and timeUnit
parameters.
releaseConnection in interface HttpClientConnectionManagermanagedConn - the managed connection to release.keepalive - the duration of time this connection is valid for reuse.tunit - the time unit.HttpClientConnectionManager.closeExpiredConnections()
public void connect(org.apache.http.HttpClientConnection managedConn,
org.apache.http.conn.routing.HttpRoute route,
int connectTimeout,
org.apache.http.protocol.HttpContext context)
throws java.io.IOException
HttpClientConnectionManager
connect in interface HttpClientConnectionManagermanagedConn - the managed connection.route - the route of the connection.connectTimeout - connect timeout in milliseconds.context - the actual HTTP context.
java.io.IOException
public void upgrade(org.apache.http.HttpClientConnection managedConn,
org.apache.http.conn.routing.HttpRoute route,
org.apache.http.protocol.HttpContext context)
throws java.io.IOException
HttpClientConnectionManagerCONNECT method to all
intermediate proxy hops
upgrade in interface HttpClientConnectionManagermanagedConn - the managed connection.route - the route of the connection.context - the actual HTTP context.
java.io.IOException
public void routeComplete(org.apache.http.HttpClientConnection managedConn,
org.apache.http.conn.routing.HttpRoute route,
org.apache.http.protocol.HttpContext context)
throws java.io.IOException
HttpClientConnectionManager
routeComplete in interface HttpClientConnectionManagermanagedConn - the managed connection.route - the route of the connection.context - the actual HTTP context.
java.io.IOExceptionpublic void shutdown()
HttpClientConnectionManager
shutdown in interface HttpClientConnectionManager
public void closeIdleConnections(long idleTimeout,
java.util.concurrent.TimeUnit tunit)
HttpClientConnectionManager
closeIdleConnections in interface HttpClientConnectionManageridleTimeout - the idle time of connections to be closedtunit - the unit for the idletimeHttpClientConnectionManager.closeExpiredConnections()public void closeExpiredConnections()
HttpClientConnectionManager
closeExpiredConnections in interface HttpClientConnectionManagerpublic int getMaxTotal()
getMaxTotal in interface ConnPoolControl<org.apache.http.conn.routing.HttpRoute>public void setMaxTotal(int max)
setMaxTotal in interface ConnPoolControl<org.apache.http.conn.routing.HttpRoute>public int getDefaultMaxPerRoute()
getDefaultMaxPerRoute in interface ConnPoolControl<org.apache.http.conn.routing.HttpRoute>public void setDefaultMaxPerRoute(int max)
setDefaultMaxPerRoute in interface ConnPoolControl<org.apache.http.conn.routing.HttpRoute>public int getMaxPerRoute(org.apache.http.conn.routing.HttpRoute route)
getMaxPerRoute in interface ConnPoolControl<org.apache.http.conn.routing.HttpRoute>
public void setMaxPerRoute(org.apache.http.conn.routing.HttpRoute route,
int max)
setMaxPerRoute in interface ConnPoolControl<org.apache.http.conn.routing.HttpRoute>public PoolStats getTotalStats()
getTotalStats in interface ConnPoolControl<org.apache.http.conn.routing.HttpRoute>public PoolStats getStats(org.apache.http.conn.routing.HttpRoute route)
getStats in interface ConnPoolControl<org.apache.http.conn.routing.HttpRoute>public SocketConfig getDefaultSocketConfig()
public void setDefaultSocketConfig(SocketConfig defaultSocketConfig)
public ConnectionConfig getDefaultConnectionConfig()
public void setDefaultConnectionConfig(ConnectionConfig defaultConnectionConfig)
public SocketConfig getSocketConfig(org.apache.http.HttpHost host)
public void setSocketConfig(org.apache.http.HttpHost host,
SocketConfig socketConfig)
public ConnectionConfig getConnectionConfig(org.apache.http.HttpHost host)
public void setConnectionConfig(org.apache.http.HttpHost host,
ConnectionConfig connectionConfig)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||