public class MultiThreadedHttpConnectionManager extends Object implements HttpConnectionManager
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DEFAULT_MAX_HOST_CONNECTIONS
The default maximum number of connections allowed per host
|
static int |
DEFAULT_MAX_TOTAL_CONNECTIONS
The default maximum number of connections allowed overall
|
| 构造器和说明 |
|---|
MultiThreadedHttpConnectionManager()
No-args constructor
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
closeIdleConnections(long idleTimeout)
Closes connections that have been idle for at least the given amount of time.
|
void |
deleteClosedConnections()
Deletes all closed connections.
|
HttpConnection |
getConnection(HostConfiguration hostConfiguration)
Gets an HttpConnection for a given host configuration.
|
HttpConnection |
getConnection(HostConfiguration hostConfiguration,
long timeout)
已过时。
Use #getConnectionWithTimeout(HostConfiguration, long)
|
int |
getConnectionsInPool()
Gets the total number of pooled connections.
|
int |
getConnectionsInPool(HostConfiguration hostConfiguration)
Gets the total number of pooled connections for the given host configuration.
|
int |
getConnectionsInUse()
已过时。
|
int |
getConnectionsInUse(HostConfiguration hostConfiguration)
|
HttpConnection |
getConnectionWithTimeout(HostConfiguration hostConfiguration,
long timeout)
Gets an HttpConnection for a given host configuration.
|
int |
getMaxConnectionsPerHost()
|
int |
getMaxTotalConnections()
|
HttpConnectionManagerParams |
getParams()
Returns
parameters associated
with this connection manager. |
boolean |
isConnectionStaleCheckingEnabled()
|
void |
releaseConnection(HttpConnection conn)
Make the given HttpConnection available for use by other requests.
|
void |
setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)
|
void |
setMaxConnectionsPerHost(int maxHostConnections)
|
void |
setMaxTotalConnections(int maxTotalConnections)
|
void |
setParams(HttpConnectionManagerParams params)
Assigns
parameters for this
connection manager. |
void |
shutdown()
Shuts down the connection manager and releases all resources.
|
static void |
shutdownAll()
Shuts down and cleans up resources used by all instances of
MultiThreadedHttpConnectionManager.
|
public static final int DEFAULT_MAX_HOST_CONNECTIONS
public static final int DEFAULT_MAX_TOTAL_CONNECTIONS
public MultiThreadedHttpConnectionManager()
public static void shutdownAll()
shutdown() is called on all live instances of
MultiThreadedHttpConnectionManager.shutdown()public void shutdown()
The connection manager can no longer be used once shutdown.
Calling this method more than once will have no effect.
public boolean isConnectionStaleCheckingEnabled()
true if stale checking will be enabled on HttpConnectionsHttpConnection.isStaleCheckingEnabled()public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)
connectionStaleCheckingEnabled - true if stale checking will be enabled
on HttpConnectionsHttpConnection.setStaleCheckingEnabled(boolean)public void setMaxConnectionsPerHost(int maxHostConnections)
HttpConnectionManagerParams.setDefaultMaxConnectionsPerHost(int),
HttpConnectionManager.getParams().maxHostConnections - the number of connections allowed for each
hostConfigurationpublic int getMaxConnectionsPerHost()
HttpConnectionManagerParams.getDefaultMaxConnectionsPerHost(),
HttpConnectionManager.getParams().public void setMaxTotalConnections(int maxTotalConnections)
HttpConnectionManagerParams.setMaxTotalConnections(int),
HttpConnectionManager.getParams().maxTotalConnections - the maximum number of connections allowedpublic int getMaxTotalConnections()
public HttpConnection getConnection(HostConfiguration hostConfiguration)
HttpConnectionManagergetConnection 在接口中 HttpConnectionManagerhostConfiguration - the host configuration to use to configure the
connectionHttpConnectionManager.getConnection(HostConfiguration)public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) throws ConnectionPoolTimeoutException
HttpConnectionManagergetConnectionWithTimeout 在接口中 HttpConnectionManagerhostConfiguration - the host configuration to use to configure the
connectiontimeout - - the time (in milliseconds) to wait for a connection to
become available, 0 to specify an infinite timeoutConnectionPoolTimeoutException - if no connection becomes available before the
timeout expiresHttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) throws HttpException
HttpConnectionManagergetConnection 在接口中 HttpConnectionManagerhostConfiguration - the host configuration to use to configure the
connectiontimeout - - the time (in milliseconds) to wait for a connection to
become available, 0 to specify an infinite timeoutHttpException - if no connection becomes available before the
timeout expiresHttpConnectionManager.getConnection(HostConfiguration, long)public int getConnectionsInPool(HostConfiguration hostConfiguration)
maximum number of connections per
host.hostConfiguration - The host configurationpublic int getConnectionsInPool()
maximum number of connections.public int getConnectionsInUse(HostConfiguration hostConfiguration)
hostConfiguration - the key that connections are tracked onpublic int getConnectionsInUse()
getConnectionsInPool()public void deleteClosedConnections()
HttpConnection.isOpen()public void closeIdleConnections(long idleTimeout)
HttpConnectionManagercloseIdleConnections 在接口中 HttpConnectionManageridleTimeout - the minimum idle time, in milliseconds, for connections to be closedpublic void releaseConnection(HttpConnection conn)
releaseConnection 在接口中 HttpConnectionManagerconn - the HttpConnection to make available.public HttpConnectionManagerParams getParams()
parameters associated
with this connection manager.getParams 在接口中 HttpConnectionManagerHttpConnectionManagerParamspublic void setParams(HttpConnectionManagerParams params)
parameters for this
connection manager.setParams 在接口中 HttpConnectionManagerHttpConnectionManagerParamsCopyright © 2017. All rights reserved.