Example usage for org.apache.http.impl.conn PoolingClientConnectionManager getTotalStats

List of usage examples for org.apache.http.impl.conn PoolingClientConnectionManager getTotalStats

Introduction

In this page you can find the example usage for org.apache.http.impl.conn PoolingClientConnectionManager getTotalStats.

Prototype

public PoolStats getTotalStats() 

Source Link

Usage

From source file:org.openrepose.core.services.httpclient.impl.ClientDecommissioner.java

@Override
public void run() {
    while (!this.done) {
        synchronized (listLock) {

            LOG.trace("Iterating through decommissioned clients...");

            List<HttpClient> clientsToRemove = new ArrayList<HttpClient>();

            for (HttpClient client : clientList) {

                String clientId = client.getParams().getParameter(HttpConnectionPoolProvider.CLIENT_INSTANCE_ID)
                        .toString();/*ww w.j a  v  a2  s  . c  om*/

                if (userManager.hasUsers(clientId)) {
                    LOG.warn("Failed to shutdown connection pool client {} due to a connection still in "
                            + "use after last reconfiguration of Repose.", clientId);
                    break;
                }

                PoolingClientConnectionManager connMan = (PoolingClientConnectionManager) client
                        .getConnectionManager();
                PoolStats stats = connMan.getTotalStats();

                if (stats.getLeased() == 0) { // if no active connections we will shutdown this client
                    LOG.debug("Shutting down client {}", clientId);
                    connMan.shutdown();
                    clientsToRemove.add(client);
                }
            }
            for (HttpClient client : clientsToRemove) {
                clientList.remove(client);
                LOG.info("HTTP connection pool {} has been destroyed.",
                        client.getParams().getParameter(HttpConnectionPoolProvider.CLIENT_INSTANCE_ID));
            }
        }

        try {
            Thread.sleep(DEFAULT_INTERVAL);
        } catch (InterruptedException ex) {
            LOG.info("Interrupted", ex);
            break;
        }

    }

    LOG.info("Shutting down HTTP Client Service Decommissioner");
    Thread.currentThread().interrupt();
}

From source file:com.flipkart.poseidon.handlers.http.impl.HttpConnectionPool.java

/**
 * Get the statistics/*  w w  w .j a  v a2  s. c  o m*/
 */
public String getStats() {
    PoolingClientConnectionManager cm = (PoolingClientConnectionManager) this.client.getConnectionManager();
    PoolStats stats = cm.getTotalStats();
    return "Connections: " + stats.toString() + " AvailableRequests: " + processQueue.availablePermits();
}