List of usage examples for org.apache.commons.httpclient MultiThreadedHttpConnectionManager MultiThreadedHttpConnectionManager
public MultiThreadedHttpConnectionManager()
From source file:com.taobao.diamond.client.impl.DefaultDiamondPublisher.java
private void initHttpClient() { if (MockServer.isTestMode()) { return;/* w w w .ja v a 2 s. c o m*/ } HostConfiguration hostConfiguration = new HostConfiguration(); hostConfiguration.setHost(diamondConfigure.getDomainNameList().get(domainNamePos.get()), diamondConfigure.getPort()); MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.closeIdleConnections(60 * 1000); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setStaleCheckingEnabled(diamondConfigure.isConnectionStaleCheckingEnabled()); params.setMaxConnectionsPerHost(hostConfiguration, diamondConfigure.getMaxHostConnections()); params.setMaxTotalConnections(diamondConfigure.getMaxTotalConnections()); params.setConnectionTimeout(diamondConfigure.getConnectionTimeout()); params.setSoTimeout(requestTimeout); connectionManager.setParams(params); httpClient = new HttpClient(connectionManager); httpClient.setHostConfiguration(hostConfiguration); }
From source file:edu.unc.lib.dl.fedora.ManagementClient.java
public void init() throws Exception { this.httpManager = new MultiThreadedHttpConnectionManager(); this.httpManager.getParams().setConnectionTimeout(5000); initializeConnections();/*from w w w .ja v a 2s . c o m*/ }
From source file:it.intecs.pisa.develenv.model.launch.ToolboxScriptRunLaunch.java
protected static InputStream sendFile(String url, String soapAction, InputStream stream) throws FileNotFoundException, IOException, HttpException { PostMethod post;//from w ww.j a va 2 s. com int result; MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); HttpClient client = new HttpClient(connectionManager); post = new PostMethod(url); post.setRequestEntity(new InputStreamRequestEntity(stream, "text/xml")); post.setRequestHeader("soapaction", soapAction); result = client.executeMethod(post); InputStream in = post.getResponseBodyAsStream(); return in; }
From source file:flex.messaging.services.http.HTTPProxyAdapter.java
/** * Sets <code>HTTPConnectionManagerSettings</code>. * * @param connectionManagerSettings The connection manager settings. *//*from w w w . ja va2s.co m*/ public void setConnectionManagerSettings(HTTPConnectionManagerSettings connectionManagerSettings) { this.connectionManagerSettings = connectionManagerSettings; initHttpConnectionManagerParams(connectionManagerSettings); connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(connectionParams); }
From source file:davmail.http.DavGatewayHttpClientFacade.java
/** * Create and set connection pool./*ww w. ja v a2 s . c om*/ * * @param httpClient httpClient instance */ public static void createMultiThreadedHttpConnectionManager(HttpClient httpClient) { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.getParams().setDefaultMaxConnectionsPerHost(100); connectionManager.getParams().setConnectionTimeout(10000); synchronized (LOCK) { httpConnectionManagerThread.addConnectionManager(connectionManager); } httpClient.setHttpConnectionManager(connectionManager); }
From source file:com.amazonaws.a2s.AmazonA2SClient.java
/** * Configure HttpClient with set of defaults as well as configuration * from AmazonA2SConfig instance/* www .j a v a2 s .c om*/ * */ private HttpClient configureHttpClient() { /* Set http client parameters */ HttpClientParams httpClientParams = new HttpClientParams(); httpClientParams.setParameter(HttpMethodParams.USER_AGENT, config.getUserAgent()); httpClientParams.setParameter(HttpClientParams.RETRY_HANDLER, new HttpMethodRetryHandler() { public boolean retryMethod(HttpMethod method, IOException exception, int executionCount) { if (executionCount > 3) { log.debug("Maximum Number of Retry attempts reached, will not retry"); return false; } log.debug("Retrying request. Attempt " + executionCount); if (exception instanceof NoHttpResponseException) { log.debug("Retrying on NoHttpResponseException"); return true; } if (!method.isRequestSent()) { log.debug("Retrying on failed sent request"); return true; } return false; } }); /* Set host configuration */ HostConfiguration hostConfiguration = new HostConfiguration(); /* Set connection manager parameters */ HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams(); connectionManagerParams.setConnectionTimeout(50000); connectionManagerParams.setSoTimeout(50000); connectionManagerParams.setStaleCheckingEnabled(true); connectionManagerParams.setTcpNoDelay(true); connectionManagerParams.setMaxTotalConnections(3); connectionManagerParams.setMaxConnectionsPerHost(hostConfiguration, 3); /* Set connection manager */ MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(connectionManagerParams); /* Set http client */ httpClient = new HttpClient(httpClientParams, connectionManager); /* Set proxy if configured */ if (config.isSetProxyHost() && config.isSetProxyPort()) { log.info("Configuring Proxy. Proxy Host: " + config.getProxyHost() + "Proxy Port: " + config.getProxyPort()); hostConfiguration.setProxy(config.getProxyHost(), config.getProxyPort()); } httpClient.setHostConfiguration(hostConfiguration); return httpClient; }
From source file:nl.b3p.viewer.image.ImageManager.java
public ImageManager(List<CombineImageUrl> urls, int maxResponseTime, String uname, String pw) { this.maxResponseTime = maxResponseTime; if (urls == null || urls.size() <= 0) { return;//from www . j av a 2 s . c o m } MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); HttpClient client = new HttpClient(connectionManager); client.getHttpConnectionManager().getParams().setConnectionTimeout(this.maxResponseTime); if (uname != null && pw != null) { client.getParams().setAuthenticationPreemptive(true); Credentials defaultcreds = new UsernamePasswordCredentials(uname, pw); AuthScope authScope = new AuthScope(host, port); client.getState().setCredentials(authScope, defaultcreds); } for (CombineImageUrl ciu : urls) { ImageCollector ic = null; if (ciu instanceof CombineWmsUrl) { ic = new ImageCollector(ciu, maxResponseTime, client, uname, pw); } else if (ciu instanceof CombineArcIMSUrl) { ic = new ArcImsImageCollector(ciu, maxResponseTime, client); } else if (ciu instanceof CombineArcServerUrl) { ic = new ArcServerImageCollector(ciu, maxResponseTime, client); } else { ic = new ImageCollector(ciu, maxResponseTime, client, uname, pw); } ics.add(ic); } }
From source file: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 *//*from ww w. jav a 2s. c om*/ private HttpClient createHttpClient() { HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(Integer .parseInt(tokenValidationProperties.getProperty(UIConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST))); params.setMaxTotalConnections( Integer.parseInt(tokenValidationProperties.getProperty(UIConstants.MAXIMUM_TOTAL_HTTP_CONNECTION))); HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); connectionManager.setParams(params); return new HttpClient(connectionManager); }
From source file:open.hyperion.nimblestorage.connection.NimbleStorageAPIFactory.java
/** * Initialize HTTP client//from ww w.ja v a 2s .co m */ public void init() { _log.info("NimbleStorageDriver:NimbleStorageAPIFactory init enter"); _clientMap = new ConcurrentHashMap<String, NimbleStorageAPI>(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(_maxConnPerHost); params.setMaxTotalConnections(_maxConn); params.setTcpNoDelay(true); params.setConnectionTimeout(_connTimeout); params.setSoTimeout(_socketConnTimeout); _connectionManager = new MultiThreadedHttpConnectionManager(); _connectionManager.setParams(params); _connectionManager.closeIdleConnections(0); // close idle connections immediately HttpClient client = new HttpClient(_connectionManager); client.getParams().setConnectionManagerTimeout(_connManagerTimeout); client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new HttpMethodRetryHandler() { @Override public boolean retryMethod(HttpMethod httpMethod, IOException e, int i) { return false; } }); Protocol.registerProtocol("https", new Protocol("https", new NonValidatingSocketFactory(), 8080)); }
From source file:open.hyperion.purestorage.connection.PureStorageAPIFactory.java
/** * Initialize HTTP client// www. j a va2 s . com */ public void init() { _log.info("PureStorageDriver:PureStorageAPIFactory init enter"); _clientMap = new ConcurrentHashMap<String, PureStorageAPI>(); HttpConnectionManagerParams params = new HttpConnectionManagerParams(); params.setDefaultMaxConnectionsPerHost(_maxConnPerHost); params.setMaxTotalConnections(_maxConn); params.setTcpNoDelay(true); params.setConnectionTimeout(_connTimeout); params.setSoTimeout(_socketConnTimeout); _connectionManager = new MultiThreadedHttpConnectionManager(); _connectionManager.setParams(params); _connectionManager.closeIdleConnections(0); // close idle connections immediately HttpClient client = new HttpClient(_connectionManager); client.getParams().setConnectionManagerTimeout(_connManagerTimeout); client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new HttpMethodRetryHandler() { @Override public boolean retryMethod(HttpMethod httpMethod, IOException e, int i) { return false; } }); Protocol.registerProtocol("https", new Protocol("https", new NonValidatingSocketFactory(), 8080)); }