Example usage for org.apache.http.pool PoolStats toString

List of usage examples for org.apache.http.pool PoolStats toString

Introduction

In this page you can find the example usage for org.apache.http.pool PoolStats toString.

Prototype

public String toString() 

Source Link

Usage

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

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

From source file:org.grycap.gpf4med.DownloadService.java

/**
 * Initiates shutdown of the download manager and blocks approximately for the 
 * given period of time in milliseconds waiting for the download manager to 
 * terminate all active connections, to shut down itself and to release system 
 * resources it currently holds./*from  w  w  w. j a  v a 2  s  . c om*/
 * @param connectionManager connection session pool.
 * @param waitMs wait time in milliseconds.
 */
private void shutdown(final PoolingNHttpClientConnectionManager connectionManager, final long waitMs) {
    PoolStats poolStats = null;
    try {
        if (connectionManager != null) {
            try {
                poolStats = connectionManager.getTotalStats();
            } catch (Exception ignore) {
                LOGGER.warn("Failed to collect connection manager stats", ignore);
            }
            connectionManager.shutdown(waitMs);
        }
    } catch (Exception e) {
        LOGGER.warn("Failed to shut down connection manager", e);
    } finally {
        LOGGER.info("Connection manager was shutted down [pool_stats_before_shutdown="
                + (poolStats != null ? poolStats.toString() : "NOT_AVAILABLE") + "]");
    }
}

From source file:org.eclipse.aether.transport.http.HttpTransporterTest.java

@Test
public void testConnectionReuse() throws Exception {
    httpServer.addSslConnector();//from w  w w.  j ava2 s  . c  o  m
    session.setCache(new DefaultRepositoryCache());
    for (int i = 0; i < 3; i++) {
        newTransporter(httpServer.getHttpsUrl());
        GetTask task = new GetTask(URI.create("repo/file.txt"));
        transporter.get(task);
        assertEquals("test", task.getDataString());
    }
    PoolStats stats = ((ConnPoolControl<?>) ((HttpTransporter) transporter).getState().getConnectionManager())
            .getTotalStats();
    assertEquals(stats.toString(), 1, stats.getAvailable());
}