/** * Closes idle connections. */ public synchronized void run() { while (!shutdown) { Iterator iter = connectionManagers.iterator(); while (iter.hasNext()) { HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next(); handleCloseIdleConnections(connectionManager); } try { this.wait(timeoutInterval); } catch (InterruptedException e) { } } // clear out the connection managers now that we're shutdown this.connectionManagers.clear(); }
public IdleConnectionTimeoutThread() { setDaemon(true); }
/** * Create and start a new HttpConnectionManager, close idle connections every minute. */ public static void start() { synchronized (LOCK) { if (httpConnectionManagerThread == null) { httpConnectionManagerThread = new IdleConnectionTimeoutThread(); httpConnectionManagerThread.setName(IdleConnectionTimeoutThread.class.getSimpleName()); httpConnectionManagerThread.setConnectionTimeout(ONE_MINUTE); httpConnectionManagerThread.setTimeoutInterval(ONE_MINUTE); httpConnectionManagerThread.start(); } } }
/** * 私有的构造方法 */ private HttpProtocolHandler() { // 创建一个线程安全的HTTP连接池 connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost); connectionManager.getParams().setMaxTotalConnections(defaultMaxTotalConn); IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread(); ict.addConnectionManager(connectionManager); ict.setConnectionTimeout(defaultIdleConnTimeout); ict.start(); }
if (!disableCleanupThread) connectionCleaner = new IdleConnectionTimeoutThread(); connectionCleaner.setName("HttpClient-connection-cleaner-" + getName()); connectionCleaner.addConnectionManager(clientConnectionManager); connectionCleaner.start();
/** * Stop HttpConnectionManager. */ public static void stop() { synchronized (LOCK) { if (httpConnectionManagerThread != null) { httpConnectionManagerThread.shutdown(); httpConnectionManagerThread.interrupt(); httpConnectionManagerThread = null; } for (MultiThreadedHttpConnectionManager httpConnectionManager : ALL_CONNECTION_MANAGERS) { // try to avoid deadlock by connection manager level lock, // used internally in MultiThreadedHttpConnectionManager.freeConnection() //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (httpConnectionManager) { httpConnectionManager.shutdown(); } } } }
public void close() { reaper.shutdown(); if (idleConnectionTimeoutThread != null) { idleConnectionTimeoutThread.shutdown(); idleConnectionTimeoutThread = null; } if (connectionManager != null) { try { connectionManager.shutdown(); } catch (Exception e) { logger.error("Error shutting down connection manager", e); } } }
/** * Create and set connection pool. * * @param httpClient httpClient instance */ public static void createMultiThreadedHttpConnectionManager(HttpClient httpClient) { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setDefaultMaxConnectionsPerHost(Settings.getIntProperty("davmail.exchange.maxConnections", 100)); connectionManager.getParams().setConnectionTimeout(Settings.getIntProperty("davmail.exchange.connectionTimeout", 10) * 1000); connectionManager.getParams().setSoTimeout(Settings.getIntProperty("davmail.exchange.soTimeout", 120) * 1000); synchronized (LOCK) { ALL_CONNECTION_MANAGERS.add(connectionManager); httpConnectionManagerThread.addConnectionManager(connectionManager); } httpClient.setHttpConnectionManager(connectionManager); }
idleConnectionTimeoutThread = new IdleConnectionTimeoutThread(); idleConnectionTimeoutThread.setName("Http_Idle_Connection_Timeout_Thread"); long idleConnectionTimeout = Long.parseLong( odeConfigurationProperties log.debug("http.idle.connection.check.interval=" + idleConnectionCheckInterval); idleConnectionTimeoutThread.setConnectionTimeout(idleConnectionTimeout); idleConnectionTimeoutThread.setTimeoutInterval(idleConnectionCheckInterval); idleConnectionTimeoutThread.addConnectionManager(httpConnectionManager); idleConnectionTimeoutThread.start();
idleConnectionTimeoutThread.shutdown(); idleConnectionTimeoutThread = null; idleConnectionTimeoutThread = new IdleConnectionTimeoutThread(); idleConnectionTimeoutThread.setConnectionTimeout(config.getReadTimeout()); idleConnectionTimeoutThread.addConnectionManager(connectionManager); idleConnectionTimeoutThread.start();
log.debug("Shutting down Idle Connection Timeout Thread."); idleConnectionTimeoutThread.shutdown(); } catch (Exception e) { log.warn("Idle connection timeout thread shutdown failed.");
public IdleConnectionTimeoutThread() { setDaemon(true); }
/** * Closes idle connections. */ public synchronized void run() { while (!shutdown) { Iterator iter = connectionManagers.iterator(); while (iter.hasNext()) { HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next(); handleCloseIdleConnections(connectionManager); } try { this.wait(timeoutInterval); } catch (InterruptedException e) { } } // clear out the connection managers now that we're shutdown this.connectionManagers.clear(); }
@Override protected void doDispose() { if (!disableCleanupThread) { connectionCleaner.shutdown(); if (!muleContext.getConfiguration().isStandalone()) { MultiThreadedHttpConnectionManager.shutdownAll(); } } if (this.connectionManager != null) { connectionManager.dispose(); connectionManager = null; } super.doDispose(); }
public IdleConnectionTimeoutThread() { setDaemon(true); }
/** * Closes idle connections. */ public synchronized void run() { while (!shutdown) { Iterator iter = connectionManagers.iterator(); while (iter.hasNext()) { HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next(); handleCloseIdleConnections(connectionManager); } try { this.wait(timeoutInterval); } catch (InterruptedException e) { } } // clear out the connection managers now that we're shutdown this.connectionManagers.clear(); }
public IdleConnectionTimeoutThread() { setDaemon(true); }
/** * Closes idle connections. */ public synchronized void run() { while (!shutdown) { Iterator iter = connectionManagers.iterator(); while (iter.hasNext()) { HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next(); handleCloseIdleConnections(connectionManager); } try { this.wait(timeoutInterval); } catch (InterruptedException e) { } } // clear out the connection managers now that we're shutdown this.connectionManagers.clear(); }
public IdleConnectionTimeoutThread() { setDaemon(true); }
/** * Closes idle connections. */ public synchronized void run() { while (!shutdown) { Iterator iter = connectionManagers.iterator(); while (iter.hasNext()) { HttpConnectionManager connectionManager = (HttpConnectionManager) iter.next(); handleCloseIdleConnections(connectionManager); } try { this.wait(timeoutInterval); } catch (InterruptedException e) { } } // clear out the connection managers now that we're shutdown this.connectionManagers.clear(); }