List of usage examples for org.apache.commons.httpclient MultiThreadedHttpConnectionManager setParams
public void setParams(HttpConnectionManagerParams paramHttpConnectionManagerParams)
From source file:org.geoserver.gss.HTTPGSSClientFactory.java
HttpClient getClient() { if (client == null) { client = new HttpClient(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); // setting timeouts (one minute hard coded, TODO: make this configurable) params.setSoTimeout(60 * 1000);//from w ww . j a va2 s . c om params.setConnectionTimeout(60 * 1000); params.setDefaultMaxConnectionsPerHost(1); MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager(); manager.setParams(params); client.setHttpConnectionManager(manager); } return client; }
From source file:org.hydracache.client.transport.HttpTransport.java
public HttpTransport() { // FIXME Make this more IoC and configurable. MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams(); connectionManagerParams.setDefaultMaxConnectionsPerHost(10); connectionManagerParams.setMaxTotalConnections(100); connectionManager.setParams(connectionManagerParams); this.httpClient = new HttpClient(connectionManager); }
From source file:org.jahia.services.notification.HttpClientServiceTest.java
private void initClient() { // instantiate HttpClient HttpClientParams params = new HttpClientParams(); params.setAuthenticationPreemptive(true); params.setCookiePolicy("ignoreCookies"); HttpConnectionManagerParams cmParams = new HttpConnectionManagerParams(); cmParams.setConnectionTimeout(15000); cmParams.setSoTimeout(60000);/*from w w w . j av a 2 s . c o m*/ MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager(); httpConnectionManager.setParams(cmParams); httpClientService = new HttpClientService(); httpClientService.setHttpClient(new HttpClient(params, httpConnectionManager)); }
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. j a va2 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.opensaml.ws.soap.client.HTTPSOAPTransportFactory.java
/** * Initializes the {@link HttpClient} that will be used by the created {@link HTTPSOAPTransport} built by this * factory./* w w w . ja v a2 s . com*/ */ protected void initializeHttpClient() { HttpConnectionManagerParams connectionParams = new HttpConnectionManagerParams(); connectionParams.setConnectionTimeout(connectionTimeout); MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(connectionParams); HttpClientParams clientParams = new HttpClientParams(); clientParams.setSoTimeout(socketTimeout); if (httpVersion == HTTP_VERSION.HTTP1_0) { clientParams.setVersion(HttpVersion.HTTP_1_0); } else { clientParams.setVersion(HttpVersion.HTTP_1_1); } httpClient = new HttpClient(clientParams, connectionManager); }
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();/*from w w w.j ava 2 s . c o m*/ }
From source file:org.sonar.wsclient.WSClientFactory.java
/** * @see org.sonar.wsclient.connectors.HttpClient3Connector#createClient() *///from ww w . ja v a 2s . 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.automation.test.utils.axis2client.ConfigurationContextProvider.java
private ConfigurationContextProvider() { try {//from ww w. jav a 2s . c o m MultiThreadedHttpConnectionManager httpConnectionManager; HttpClient httpClient; HttpConnectionManagerParams params; configurationContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem( FrameworkPathUtil.getSystemResourceLocation() + File.separator + "client", null); httpConnectionManager = new MultiThreadedHttpConnectionManager(); params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(25); httpConnectionManager.setParams(params); httpClient = new HttpClient(httpConnectionManager); configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient); configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE); } catch (AxisFault axisFault) { log.error(axisFault); } }
From source file:org.wso2.carbon.core.init.CarbonServerManager.java
private ConfigurationContext getClientConfigurationContext() throws AxisFault { String clientRepositoryLocation = serverConfig.getFirstProperty(CLIENT_REPOSITORY_LOCATION); String clientAxis2XmlLocationn = serverConfig.getFirstProperty(CLIENT_AXIS2_XML_LOCATION); ConfigurationContext clientConfigContextToReturn = ConfigurationContextFactory .createConfigurationContextFromFileSystem(clientRepositoryLocation, clientAxis2XmlLocationn); MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); // Set the default max connections per host int defaultMaxConnPerHost = 500; Parameter defaultMaxConnPerHostParam = clientConfigContextToReturn.getAxisConfiguration() .getParameter("defaultMaxConnPerHost"); if (defaultMaxConnPerHostParam != null) { defaultMaxConnPerHost = Integer.parseInt((String) defaultMaxConnPerHostParam.getValue()); }/*ww w . ja va 2s . com*/ params.setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost); // Set the max total connections int maxTotalConnections = 15000; Parameter maxTotalConnectionsParam = clientConfigContextToReturn.getAxisConfiguration() .getParameter("maxTotalConnections"); if (maxTotalConnectionsParam != null) { maxTotalConnections = Integer.parseInt((String) maxTotalConnectionsParam.getValue()); } params.setMaxTotalConnections(maxTotalConnections); params.setSoTimeout(600000); params.setConnectionTimeout(600000); httpConnectionManager.setParams(params); clientConfigContextToReturn.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, httpConnectionManager); registerHouseKeepingTask(clientConfigContextToReturn); clientConfigContextToReturn.setProperty(ServerConstants.WORK_DIR, serverWorkDir); return clientConfigContextToReturn; }
From source file:org.wso2.carbon.event.output.adapter.soap.SoapEventAdapter.java
private HttpClient createMultiThreadedHttpConnectionManager(int connectionTimeOut, int maxConnectionPerHost) { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(maxConnectionPerHost); params.setConnectionTimeout(connectionTimeOut); MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager(); httpConnectionManager.setParams(params); return new HttpClient(httpConnectionManager); }