| Method from org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager Detail: |
public void closeExpiredConnections() {
log.debug("Closing expired connections");
connectionPool.closeExpiredConnections();
connectionPool.deleteClosedConnections();
}
|
public void closeIdleConnections(long idleTimeout,
TimeUnit tunit) {
if (log.isDebugEnabled()) {
log.debug("Closing connections idle for " + idleTimeout + " " + tunit);
}
connectionPool.closeIdleConnections(idleTimeout, tunit);
connectionPool.deleteClosedConnections();
}
|
protected ClientConnectionOperator createConnectionOperator(SchemeRegistry schreg) {
return new DefaultClientConnectionOperator(schreg);// @ThreadSafe
}
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 . |
protected AbstractConnPool createConnectionPool(HttpParams params) {
return new ConnPoolByRoute(connOperator, params);
}
Hook for creating the connection pool. |
protected void finalize() throws Throwable {
try {
shutdown();
} finally {
super.finalize();
}
}
|
public int getConnectionsInPool() {
int count;
connectionPool.poolLock.lock();
count = connectionPool.numConnections; //@@@
connectionPool.poolLock.unlock();
return count;
}
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. |
public int getConnectionsInPool(HttpRoute route) {
return ((ConnPoolByRoute)connectionPool).getConnectionsInPool(
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. |
public SchemeRegistry getSchemeRegistry() {
return this.schemeRegistry;
}
|
public void releaseConnection(ManagedClientConnection conn,
long validDuration,
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.");
}
synchronized (hca) {
BasicPoolEntry entry = (BasicPoolEntry) hca.getPoolEntry();
if (entry == null) {
return;
}
try {
// make sure that the response has been read completely
if (hca.isOpen() && !hca.isMarkedReusable()) {
// 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) {
if (log.isDebugEnabled())
log.debug("Exception shutting down released connection.",
iox);
} finally {
boolean reusable = hca.isMarkedReusable();
if (log.isDebugEnabled()) {
if (reusable) {
log.debug("Released connection is reusable.");
} else {
log.debug("Released connection is not reusable.");
}
}
hca.detach();
connectionPool.freeEntry(entry, reusable, validDuration, timeUnit);
}
}
}
|
public ClientConnectionRequest requestConnection(HttpRoute route,
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() {
log.debug("Shutting down");
connectionPool.shutdown();
}
|