Methods Summary |
---|
public void | closeExpiredConnections()
connectionPool.closeExpiredConnections();
connectionPool.deleteClosedConnections();
|
public void | closeIdleConnections(long idleTimeout, java.util.concurrent.TimeUnit tunit)
// combine these two in a single call?
connectionPool.closeIdleConnections(idleTimeout, tunit);
connectionPool.deleteClosedConnections();
|
protected org.apache.http.conn.ClientConnectionOperator | createConnectionOperator(org.apache.http.conn.scheme.SchemeRegistry schreg)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
{@link DefaultClientConnectionOperator DefaultClientConnectionOperator}.
return new DefaultClientConnectionOperator(schreg);
|
protected org.apache.http.impl.conn.tsccm.AbstractConnPool | createConnectionPool(org.apache.http.params.HttpParams params)Hook for creating the connection pool.
AbstractConnPool acp = new ConnPoolByRoute(connOperator, params);
boolean conngc = true; //@@@ check parameters to decide
if (conngc) {
acp.enableConnectionGC();
}
return acp;
|
protected void | finalize()
shutdown();
super.finalize();
|
public int | getConnectionsInPool()Gets the total number of pooled connections. This is the total number of
connections that have been created and are still in use by this connection
manager. This value will not exceed the maximum number of connections
in total.
synchronized (connectionPool) {
return connectionPool.numConnections; //@@@
}
|
public int | getConnectionsInPool(org.apache.http.conn.routing.HttpRoute route)Gets the total number of pooled connections for the given route.
This is the total number of connections that have been created and
are still in use by this connection manager for the route.
This value will not exceed the maximum number of connections per host.
return ((ConnPoolByRoute)connectionPool).getConnectionsInPool(
route);
|
public org.apache.http.conn.scheme.SchemeRegistry | getSchemeRegistry()
return this.schemeRegistry;
|
public void | releaseConnection(org.apache.http.conn.ManagedClientConnection conn, long validDuration, java.util.concurrent.TimeUnit timeUnit)
if (!(conn instanceof BasicPooledConnAdapter)) {
throw new IllegalArgumentException
("Connection class mismatch, " +
"connection not obtained from this manager.");
}
BasicPooledConnAdapter hca = (BasicPooledConnAdapter) conn;
if ((hca.getPoolEntry() != null) && (hca.getManager() != this)) {
throw new IllegalArgumentException
("Connection not obtained from this manager.");
}
try {
// make sure that the response has been read completely
if (hca.isOpen() && !hca.isMarkedReusable()) {
if (log.isDebugEnabled()) {
log.debug
("Released connection open but not marked reusable.");
}
// In MTHCM, there would be a call to
// SimpleHttpConnectionManager.finishLastResponse(conn);
// Consuming the response is handled outside in 4.0.
// make sure this connection will not be re-used
// Shut down rather than close, we might have gotten here
// because of a shutdown trigger.
// Shutdown of the adapter also clears the tracked route.
hca.shutdown();
}
} catch (IOException iox) {
//@@@ log as warning? let pass?
if (log.isDebugEnabled())
log.debug("Exception shutting down released connection.",
iox);
} finally {
BasicPoolEntry entry = (BasicPoolEntry) hca.getPoolEntry();
boolean reusable = hca.isMarkedReusable();
hca.detach();
if (entry != null) {
connectionPool.freeEntry(entry, reusable, validDuration, timeUnit);
}
}
|
public org.apache.http.conn.ClientConnectionRequest | requestConnection(org.apache.http.conn.routing.HttpRoute route, java.lang.Object state)
final PoolEntryRequest poolRequest = connectionPool.requestPoolEntry(
route, state);
return new ClientConnectionRequest() {
public void abortRequest() {
poolRequest.abortRequest();
}
public ManagedClientConnection getConnection(
long timeout, TimeUnit tunit) throws InterruptedException,
ConnectionPoolTimeoutException {
if (route == null) {
throw new IllegalArgumentException("Route may not be null.");
}
if (log.isDebugEnabled()) {
log.debug("ThreadSafeClientConnManager.getConnection: "
+ route + ", timeout = " + timeout);
}
BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, tunit);
return new BasicPooledConnAdapter(ThreadSafeClientConnManager.this, entry);
}
};
|
public void | shutdown()
connectionPool.shutdown();
|