List of usage examples for org.apache.commons.httpclient.params HttpConnectionManagerParams setMaxTotalConnections
public void setMaxTotalConnections(int paramInt)
From source file:org.lockss.util.urlconn.LockssUrlConnectionPool.java
public void setMultiThreaded(int maxConn, int maxPerHost) { MultiThreadedHttpConnectionManager cm = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = cm.getParams(); params.setMaxTotalConnections(maxConn); params.setDefaultMaxConnectionsPerHost(maxPerHost); setTimeouts(params);//from w w w . ja v a 2 s.c o m hcConnManager = cm; if (httpClient != null) { httpClient.setHttpConnectionManager(cm); } }
From source file:org.mapfish.print.config.Config.java
private synchronized MultiThreadedHttpConnectionManager getConnectionManager() { if (connectionManager == null) { connectionManager = new MultiThreadedHttpConnectionManager(); final HttpConnectionManagerParams params = connectionManager.getParams(); params.setDefaultMaxConnectionsPerHost(perHostParallelFetches); params.setMaxTotalConnections(globalParallelFetches); params.setSoTimeout(socketTimeout); params.setConnectionTimeout(connectionTimeout); }/*from www .j a va 2 s . c om*/ return connectionManager; }
From source file:org.mule.transport.http.HttpConnector.java
@Override protected void doInitialise() throws InitialisationException { super.doInitialise(); if (clientConnectionManager == null) { clientConnectionManager = new MultiThreadedHttpConnectionManager(); String prop = System.getProperty("mule.http.disableCleanupThread"); disableCleanupThread = prop != null && prop.equals("true"); if (!disableCleanupThread) { connectionCleaner = new IdleConnectionTimeoutThread(); connectionCleaner.setName("HttpClient-connection-cleaner-" + getName()); connectionCleaner.addConnectionManager(clientConnectionManager); connectionCleaner.start();// ww w .ja va2 s. c o m } HttpConnectionManagerParams params = new HttpConnectionManagerParams(); if (getSendBufferSize() != INT_VALUE_NOT_SET) { params.setSendBufferSize(getSendBufferSize()); } if (getReceiveBufferSize() != INT_VALUE_NOT_SET) { params.setReceiveBufferSize(getReceiveBufferSize()); } if (getClientSoTimeout() != INT_VALUE_NOT_SET) { params.setSoTimeout(getClientSoTimeout()); } if (getSocketSoLinger() != INT_VALUE_NOT_SET) { params.setLinger(getSocketSoLinger()); } params.setTcpNoDelay(isSendTcpNoDelay()); params.setMaxTotalConnections(dispatchers.getMaxTotal()); params.setDefaultMaxConnectionsPerHost(dispatchers.getMaxTotal()); clientConnectionManager.setParams(params); } //connection manager must be created during initialization due that devkit requires the connection manager before start phase. //That's why it not manager only during stop/start phases and must be created also here. if (connectionManager == null) { try { connectionManager = new org.mule.transport.http.HttpConnectionManager(this, getReceiverWorkManager()); } catch (MuleException e) { throw new InitialisationException( CoreMessages.createStaticMessage("failed creating http connection manager"), this); } } }
From source file:org.obm.caldav.client.AbstractPushTest.java
private HttpClient createHttpClient() { HttpClient ret = new HttpClient(new MultiThreadedHttpConnectionManager()); HttpConnectionManagerParams mp = ret.getHttpConnectionManager().getParams(); mp.setDefaultMaxConnectionsPerHost(4); mp.setMaxTotalConnections(8); return ret;//from www . j a v a 2 s . c o m }
From source file:org.obm.caldav.obmsync.service.impl.ObmSyncProviderFactory.java
protected ObmSyncProviderFactory() { MultiThreadedHttpConnectionManager mtConMan = new MultiThreadedHttpConnectionManager(); HttpClient ret = new HttpClient(mtConMan); HttpConnectionManagerParams mp = ret.getHttpConnectionManager().getParams(); mp.setDefaultMaxConnectionsPerHost(10); mp.setMaxTotalConnections(20); this.hc = ret; }
From source file:org.opensaml.ws.soap.client.http.HttpClientBuilder.java
/** * Builds an HTTP client with the given settings. Settings are NOT reset to their default values after a client has * been created.//from ww w. ja v a 2 s.c om * * @return the created client. */ public HttpClient buildClient() { if (httpsProtocolSocketFactory != null) { Protocol.registerProtocol("https", new Protocol("https", httpsProtocolSocketFactory, 443)); } HttpClientParams clientParams = new HttpClientParams(); clientParams.setAuthenticationPreemptive(isPreemptiveAuthentication()); clientParams.setContentCharset(getContentCharSet()); clientParams.setParameter(HttpClientParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(connectionRetryAttempts, false)); HttpConnectionManagerParams connMgrParams = new HttpConnectionManagerParams(); connMgrParams.setConnectionTimeout(getConnectionTimeout()); connMgrParams.setDefaultMaxConnectionsPerHost(getMaxConnectionsPerHost()); connMgrParams.setMaxTotalConnections(getMaxTotalConnections()); connMgrParams.setReceiveBufferSize(getReceiveBufferSize()); connMgrParams.setSendBufferSize(getSendBufferSize()); connMgrParams.setTcpNoDelay(isTcpNoDelay()); MultiThreadedHttpConnectionManager connMgr = new MultiThreadedHttpConnectionManager(); connMgr.setParams(connMgrParams); HttpClient httpClient = new HttpClient(clientParams, connMgr); if (proxyHost != null) { HostConfiguration hostConfig = new HostConfiguration(); hostConfig.setProxy(proxyHost, proxyPort); httpClient.setHostConfiguration(hostConfig); if (proxyUsername != null) { AuthScope proxyAuthScope = new AuthScope(proxyHost, proxyPort); UsernamePasswordCredentials proxyCredentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword); httpClient.getState().setProxyCredentials(proxyAuthScope, proxyCredentials); } } return httpClient; }
From source file:org.paxle.filter.robots.impl.RobotsTxtManager.java
void init(Map<String, Object> props) { // configure caching manager this.manager = CacheManager.getInstance(); /* ================================================================================= * init a new cache//w w w . j a va2 s .c om * ================================================================================= */ Integer maxCacheSize = (Integer) props.get(PROP_MAX_CACHE_SIZE); if (maxCacheSize == null) maxCacheSize = Integer.valueOf(1000); this.cache = new Cache(CACHE_NAME, maxCacheSize.intValue(), false, false, 60 * 60, 30 * 60); this.manager.addCache(this.cache); /* ================================================================================= * init threadpool * ================================================================================= */ Integer maxIdle = (Integer) props.get(PROP_WORKER_MAX_IDLE); if (maxIdle == null) maxIdle = Integer.valueOf(20); Integer maxAlive = (Integer) props.get(PROP_WORKER_MAX_ALIVE); if (maxAlive == null) maxAlive = Integer.valueOf(20); if (maxAlive.compareTo(maxIdle) < 0) maxAlive = maxIdle; this.execService = new ThreadPoolExecutor(maxIdle.intValue(), maxAlive.intValue(), 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); /* ================================================================================= * init http-client * ================================================================================= */ this.connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = this.connectionManager.getParams(); final Integer connectionTimeout = (Integer) props.get(PROP_CONNECTION_TIMEOUT); if (connectionTimeout != null) params.setConnectionTimeout(connectionTimeout.intValue()); final Integer socketTimeout = (Integer) props.get(PROP_SOCKET_TIMEOUT); if (socketTimeout != null) params.setSoTimeout(socketTimeout.intValue()); final Integer maxConnections = (Integer) props.get(PROP_MAXCONNECTIONS_TOTAL); if (maxConnections != null) params.setMaxTotalConnections(maxConnections.intValue()); this.httpClient = new HttpClient(this.connectionManager); /* ================================================================================= * proxy configuration * ================================================================================= */ final Boolean useProxyVal = (Boolean) props.get(PROP_PROXY_USE); final boolean useProxy = (useProxyVal == null) ? false : useProxyVal.booleanValue(); final String host = (String) props.get(PROP_PROXY_HOST); final Integer portVal = (Integer) props.get(PROP_PROXY_PORT); if (useProxy && host != null && host.length() > 0 && portVal != null) { final int port = portVal.intValue(); this.logger.info(String.format("Proxy is enabled: %s:%d", host, Integer.valueOf(port))); final ProxyHost proxyHost = new ProxyHost(host, port); this.httpClient.getHostConfiguration().setProxyHost(proxyHost); final String user = (String) props.get(PROP_PROXY_HOST); final String pwd = (String) props.get(PROP_PROXY_PASSWORD); if (user != null && user.length() > 0 && pwd != null && pwd.length() > 0) this.httpClient.getState().setProxyCredentials(new AuthScope(host, port), new UsernamePasswordCredentials(user, pwd)); } else { this.logger.info("Proxy is disabled"); this.httpClient.getHostConfiguration().setProxyHost(null); this.httpClient.getState().clearCredentials(); } /* ================================================================================= * the user-agent name that should be used * ================================================================================= */ final String userAgent = (String) props.get(PROP_USER_AGENT); if (userAgent != null) { final StringBuffer buf = new StringBuffer(); Pattern pattern = Pattern.compile("\\$\\{[^\\}]*}"); Matcher matcher = pattern.matcher(userAgent); // replacing property placeholders with system-properties while (matcher.find()) { String placeHolder = matcher.group(); String propName = placeHolder.substring(2, placeHolder.length() - 1); String propValue = System.getProperty(propName); if (propValue != null) matcher.appendReplacement(buf, propValue); } matcher.appendTail(buf); this.userAgent = buf.toString(); } else { // Fallback this.userAgent = "PaxleFramework"; } this.logger .info(String.format("Robots.txt manager initialized. Using '%s' rule-store with %d stored entries.", loader.getClass().getSimpleName(), Integer.valueOf(loader.size()))); }
From source file:org.sonar.wsclient.connectors.HttpClient3Connector.java
private void createClient() { final HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setConnectionTimeout(AbstractQuery.DEFAULT_TIMEOUT_MILLISECONDS); params.setSoTimeout(AbstractQuery.DEFAULT_TIMEOUT_MILLISECONDS); params.setDefaultMaxConnectionsPerHost(MAX_HOST_CONNECTIONS); params.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS); final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); this.httpClient = new HttpClient(connectionManager); configureCredentials();/* w w w . jav a 2 s . co m*/ }
From source file:org.sonar.wsclient.WSClientFactory.java
/** * @see org.sonar.wsclient.connectors.HttpClient3Connector#createClient() *//*from w w w . j ava2 s. c om*/ private static HttpClient createHttpClient() { final HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setConnectionTimeout(TIMEOUT_MS); params.setSoTimeout(TIMEOUT_MS); params.setDefaultMaxConnectionsPerHost(MAX_HOST_CONNECTIONS); params.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS); final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return new HttpClient(connectionManager); }
From source file:org.wso2.carbon.andes.authentication.andes.oauth.OAuthTokenValidaterStubFactory.java
/** * This created httpclient pool that can be used to connect to external entity. This connection can be configured * via broker.xml by setting up the required http connection parameters. * @return an instance of HttpClient that is configured with MultiThreadedHttpConnectionManager *///www .j av a 2 s . c o m private HttpClient createHttpClient() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(config.getMaximumHttpConnectionPerHost()); params.setMaxTotalConnections(config.getMaximumTotalHttpConnection()); HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return new HttpClient(connectionManager); }