List of usage examples for org.apache.http.impl.conn PoolingClientConnectionManager shutdown
public void shutdown()
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();/*from w w w . j a v a 2s . 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(); }