public final class ConnectionPool extends Object
Address
may share a
Connection
. This class implements the policy of which connections to
keep open for future use.
The system-wide default
uses system properties for
tuning parameters:
http.keepAlive
true if HTTP and SPDY connections should be
pooled at all. Default is true.
http.maxConnections
maximum number of idle connections to
each to keep in the pool. Default is 5.
http.keepAliveDuration
Time in milliseconds to keep the
connection alive in the pool before closing it. Default is 5 minutes.
This property isn't used by HttpURLConnection
.
The default instance doesn't adjust its configuration as system properties are changed. This assumes that the applications that set these parameters do so before making HTTP connections, and that this class is initialized lazily.
Constructor and Description |
---|
ConnectionPool(int maxIdleConnections,
long keepAliveDurationMs) |
ConnectionPool(int maxIdleConnections,
long keepAliveDuration,
TimeUnit timeUnit) |
Modifier and Type | Method and Description |
---|---|
void |
evictAll()
Close and remove all idle connections in the pool.
|
int |
getConnectionCount()
Returns total number of connections in the pool.
|
static ConnectionPool |
getDefault() |
int |
getHttpConnectionCount()
Returns total number of http connections in the pool.
|
int |
getIdleConnectionCount()
Returns the number of idle connections in the pool.
|
int |
getMultiplexedConnectionCount()
Returns total number of multiplexed connections in the pool.
|
int |
getSpdyConnectionCount()
Deprecated.
|
public ConnectionPool(int maxIdleConnections, long keepAliveDurationMs)
public ConnectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit)
public static ConnectionPool getDefault()
public int getIdleConnectionCount()
public int getConnectionCount()
getIdleConnectionCount()
to count connections not currently
in use.@Deprecated public int getSpdyConnectionCount()
getMultiplexedConnectionCount()
.public int getMultiplexedConnectionCount()
public int getHttpConnectionCount()
public void evictAll()
Copyright © 2016. All Rights Reserved.