@Override public void run() { try { while (!shutdown) { synchronized (this) { wait(HTTPCLIENTCONNECTIONMANAGER_CLOSEWAITTIME_MS); for (PoolingHttpClientConnectionManager connectionManager : connectionManagers) { connectionManager.closeExpiredConnections(); connectionManager.closeIdleConnections(HTTPCLIENTCONNECTIONMANAGER_CLOSEIDLETIME_S, TimeUnit.SECONDS); } } } } catch (InterruptedException ex) { shutdown(); } }
@Override public void run() { try { while (!shutdown) { synchronized (this) { wait(HTTPCLIENTCONNECTIONMANAGER_CLOSEWAITTIME_MS); for (PoolingHttpClientConnectionManager connectionManager : connectionManagers) { connectionManager.closeExpiredConnections(); connectionManager.closeIdleConnections(HTTPCLIENTCONNECTIONMANAGER_CLOSEIDLETIME_S, TimeUnit.SECONDS); } } } } catch (InterruptedException ex) { shutdown(); } }
@Override public void run() { try { while (!shutdown) { synchronized (this) { wait(5000); // Close expired connections connMgr.closeExpiredConnections(); // Optionally, close connections that have been idle longer than 30 sec connMgr.closeIdleConnections(30, TimeUnit.SECONDS); } } } catch (InterruptedException ignored) { // terminate } }
/** * release connections from the pool * * @param idleSeconds idle seconds, longer than the configured value will be evicted */ public void releaseConnection(long idleSeconds) { this.connManager.closeExpiredConnections(); this.connManager.closeIdleConnections(idleSeconds, TimeUnit.SECONDS); } }
@Override public void run() { try { // Holds the stop request that stopped the process. Stop stopRequest; // Every 5 seconds. while ((stopRequest = stopSignal.poll(5, TimeUnit.SECONDS)) == null) { // Close expired connections cm.closeExpiredConnections(); // Optionally, close connections that have been idle too long. cm.closeIdleConnections(60, TimeUnit.SECONDS); // Look at pool stats. log.debug("Stats: {}", cm.getTotalStats()); } // Acknowledge the stop request. stopRequest.stopped(); } catch (InterruptedException ex) { // terminate } }
@Override public void closeExpiredConnections() { logger.trace( "Closing expired connections" ); connectionManager.closeExpiredConnections(); }
/** * release connections from the pool * * @param idleSeconds idle seconds, longer than the configured value will be evicted */ public void releaseConnection(long idleSeconds) { this.connManager.closeExpiredConnections(); this.connManager.closeIdleConnections(idleSeconds, TimeUnit.SECONDS); } }
public static void reset() { cm.closeIdleConnections(1000,TimeUnit.SECONDS); cm.closeExpiredConnections(); } /**
/** * @param mapHttpClientPerHttpClientKey */ private void closeCurrentConnections( Map<HttpClientKey, Pair<CloseableHttpClient, PoolingHttpClientConnectionManager>> mapHttpClientPerHttpClientKey) { for (Pair<CloseableHttpClient, PoolingHttpClientConnectionManager> pair : mapHttpClientPerHttpClientKey.values()) { PoolingHttpClientConnectionManager poolingHttpClientConnectionManager = pair.getRight(); poolingHttpClientConnectionManager.closeExpiredConnections(); poolingHttpClientConnectionManager.closeIdleConnections(1L, TimeUnit.MICROSECONDS); } }
@Override public void run() { try { connManager.closeIdleConnections(30, TimeUnit.SECONDS); connManager.closeExpiredConnections(); } catch (Throwable e) { logger.warn("fail to close idle connections.{}", e.getMessage()); } } };
void cleanUp() { manager.closeExpiredConnections(); manager.closeIdleConnections(30, TimeUnit.SECONDS); }
private void checkKeepAlive(HttpRequestBase httpRequestBase, PoolingHttpClientConnectionManager connManager, String keepAliveInput, CloseableHttpResponse httpResponse) { boolean keepAlive = StringUtils.isBlank(keepAliveInput) || Boolean.parseBoolean(keepAliveInput); if (!keepAlive) { try { httpResponse.close(); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } httpRequestBase.releaseConnection(); connManager.closeExpiredConnections(); } }
@Override @Scheduled(fixedDelay = 10000) public void run() { try { if (connectionManager != null) { LOGGER.trace("run IdleConnectionMonitor - Closing expired and idle connections..."); connectionManager.closeExpiredConnections(); connectionManager.closeIdleConnections(p.getCloseIdleConnectionWaitTimeSecs(), TimeUnit.SECONDS); } else { LOGGER.trace("run IdleConnectionMonitor - Http Client Connection manager is not initialised"); } } catch (Exception e) { LOGGER.error("run IdleConnectionMonitor - Exception occurred. msg={}, e={}", e.getMessage(), e); } } };
@Override public void run() { try { while (!shutdown) { synchronized (this) { wait(5000); // Close expired connections connMgr.closeExpiredConnections(); // Optionally, close connections that have been idle longer than 30 sec connMgr.closeIdleConnections(30, TimeUnit.SECONDS); } } } catch (InterruptedException ignored) { // terminate } }
private void checkKeepAlive(HttpRequestBase httpRequestBase, PoolingHttpClientConnectionManager connManager, String keepAliveInput, CloseableHttpResponse httpResponse) { boolean keepAlive = StringUtils.isBlank(keepAliveInput) || Boolean.parseBoolean(keepAliveInput); if (keepAlive) { httpRequestBase.releaseConnection(); } else { try { httpResponse.close(); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } httpRequestBase.releaseConnection(); connManager.closeExpiredConnections(); } }
private void checkKeepAlive(HttpRequestBase httpRequestBase, PoolingHttpClientConnectionManager connManager, String keepAliveInput, CloseableHttpResponse httpResponse) { boolean keepAlive = StringUtils.isBlank(keepAliveInput) || Boolean.parseBoolean(keepAliveInput); if (keepAlive) { httpRequestBase.releaseConnection(); } else { try { httpResponse.close(); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } httpRequestBase.releaseConnection(); connManager.closeExpiredConnections(); } }
@Override protected void closeIdleConnection(PoolingHttpClientConnectionManager manager) { try { manager.closeExpiredConnections(); } catch (final Throwable t) { _logger.warn("Error closing expired connections for sync pool", t); } try { manager.closeIdleConnections(idleTime(), TimeUnit.MILLISECONDS); } catch (final Throwable t) { _logger.warn("Error closing idle connections for sync pool", t); } }
private void checkKeepAlive(HttpRequestBase httpRequestBase, PoolingHttpClientConnectionManager connManager, String keepAliveInput, CloseableHttpResponse httpResponse) { boolean keepAlive = StringUtils.isBlank(keepAliveInput) || Boolean.parseBoolean(keepAliveInput); if (keepAlive) { httpRequestBase.releaseConnection(); } else { try { httpResponse.close(); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } httpRequestBase.releaseConnection(); connManager.closeExpiredConnections(); } }
@Override protected void closeIdleConnection(PoolingHttpClientConnectionManager manager) { try { manager.closeExpiredConnections(); } catch (final Throwable t) { _logger.warn("Error closing expired connections for sync pool", t); } try { manager.closeIdleConnections(idleTime(), TimeUnit.MILLISECONDS); } catch (final Throwable t) { _logger.warn("Error closing idle connections for sync pool", t); } }
void closeIdleConnections() { if (asyncConnectionManager != null) { asyncConnectionManager.closeExpiredConnections(); asyncConnectionManager.closeIdleConnections(IDLE_CONNECTION_TIMEOUT, TimeUnit.SECONDS); } if (syncConnectionManager != null) { syncConnectionManager.closeExpiredConnections(); syncConnectionManager.closeIdleConnections(IDLE_CONNECTION_TIMEOUT, TimeUnit.SECONDS); } }