Example usage for org.apache.http.impl.nio.conn PoolingNHttpClientConnectionManager shutdown

List of usage examples for org.apache.http.impl.nio.conn PoolingNHttpClientConnectionManager shutdown

Introduction

In this page you can find the example usage for org.apache.http.impl.nio.conn PoolingNHttpClientConnectionManager shutdown.

Prototype

public void shutdown(final long waitMs) throws IOException 

Source Link

Usage

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.//  w  w  w. j a  va  2s .  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") + "]");
    }
}