List of usage examples for org.apache.commons.httpclient MultiThreadedHttpConnectionManager MultiThreadedHttpConnectionManager
public MultiThreadedHttpConnectionManager()
From source file:org.zaizi.alfresco.redlink.service.search.solr.SensefySolrQueryHTTPClient.java
public void init() { PropertyCheck.mandatory(this, "NodeService", nodeService); PropertyCheck.mandatory(this, "PermissionService", permissionService); PropertyCheck.mandatory(this, "RepositoryState", repositoryState); MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); httpClient = new HttpClient(connectionManager); HttpClientParams params = httpClient.getParams(); params.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true); params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, true); params.setSoTimeout(socketTimeout);/*w w w .jav a 2 s .c om*/ HttpConnectionManagerParams connectionManagerParams = httpClient.getHttpConnectionManager().getParams(); connectionManagerParams.setMaxTotalConnections(maxTotalConnections); connectionManagerParams.setDefaultMaxConnectionsPerHost(maxHostConnections); httpClient.getHostConfiguration().setHost(host, port); }
From source file:playground.johannes.socialnetworks.survey.ivt2009.util.GoogleGeoCoder.java
public GoogleGeoCoder(String proxy, int port, long sleep) { HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); if (proxy != null) { httpClient.getHostConfiguration().setProxy(proxy, port); }//ww w.ja va2 s . c om geocoder = new AdvancedGeoCoder(httpClient); this.sleepInterval = sleep; cache = new HashMap<String, LatLng>(); readCache(); }
From source file:se.sll.rtjp.puadapter.lookupresident.fetcher.ThreadedSNODFetcher.java
public ThreadedSNODFetcher(String baseURL, String username, String password) { this.baseURL = baseURL; MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); httpClient = new HttpClient(connectionManager); httpClient.getParams().setAuthenticationPreemptive(true); Credentials defaultcreds = new UsernamePasswordCredentials(username, password); httpClient.getState().setCredentials(AuthScope.ANY, defaultcreds); }
From source file:terrastore.client.connection.resteasy.HTTPConnection.java
public HTTPConnection(HostManager hostManager, List<JsonObjectDescriptor<?>> descriptors) { this(hostManager, descriptors, new HttpClient(new MultiThreadedHttpConnectionManager())); }
From source file:terrastore.client.connection.resteasy.HTTPConnectionFactory.java
public HTTPConnectionFactory() { HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams(); httpParams.setDefaultMaxConnectionsPerHost(Runtime.getRuntime().availableProcessors() * 10); httpParams.setMaxTotalConnections(Runtime.getRuntime().availableProcessors() * 10); HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager(); httpManager.setParams(httpParams);/* ww w . ja v a2s .c om*/ this.client = new HttpClient(httpManager); }
From source file:terrastore.integration.IntegrationTest.java
@BeforeClass public static void setUpClass() throws Exception { System.err.println("Waiting " + SETUP_TIME + " millis for system to set up ..."); Thread.sleep(SETUP_TIME);//w w w . j a v a2s.co m // HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams(); httpParams.setDefaultMaxConnectionsPerHost(100); httpParams.setMaxTotalConnections(100); HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager(); httpManager.setParams(httpParams); HTTP_CLIENT.setHttpConnectionManager(httpManager); }
From source file:terrastore.metrics.PerformanceTest.java
@BeforeClass public static void setUpClass() throws Exception { HTTP_CLIENT.setHttpConnectionManager(new MultiThreadedHttpConnectionManager()); System.err.println("Waiting " + SETUP_TIME + " millis for system to set up ..."); Thread.sleep(SETUP_TIME);/*from ww w .jav a2s .c o m*/ // HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams(); httpParams.setDefaultMaxConnectionsPerHost(100); httpParams.setMaxTotalConnections(100); HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager(); httpManager.setParams(httpParams); HTTP_CLIENT.setHttpConnectionManager(httpManager); }
From source file:uk.ac.bbsrc.tgac.miso.webapp.service.integration.jira.JiraIssueManager.java
private WebResource prepareWebResource(URI uri) { WebResource wr = null;//www . j av a2s .com if (httpBasicAuthUsername != null && httpBasicAuthPassword != null) { if (this.client == null) { DefaultApacheHttpClientConfig config = new DefaultApacheHttpClientConfig(); config.getState().setCredentials(null, null, -1, httpBasicAuthUsername, httpBasicAuthPassword); config.getProperties().put(ApacheHttpClientConfig.PROPERTY_PREEMPTIVE_AUTHENTICATION, true); ApacheHttpClientHandler ahcHandler = new ApacheHttpClientHandler( new HttpClient(new MultiThreadedHttpConnectionManager()), config); ApacheHttpClient ahc = new ApacheHttpClient(ahcHandler); setClient(ahc); wr = ahc.resource(uri); } else { wr = this.client.resource(uri); } } else if (oAuthConsumerKey != null && oAuthConsumerSecret != null && oAuthSignatureMethod != null) { if (this.client == null) { Client c = new Client(); OAuthParameters params = new OAuthParameters().signatureMethod(oAuthSignatureMethod) .consumerKey(oAuthConsumerKey).version("1.1"); OAuthSecrets secrets = new OAuthSecrets().consumerSecret(oAuthConsumerSecret); OAuthClientFilter filter = new OAuthClientFilter(c.getProviders(), params, secrets); setClient(c); wr = c.resource(uri); wr.addFilter(filter); } else { wr = this.client.resource(uri); } } return wr; }
From source file:uk.ac.ebi.arrayexpress.servlets.GenomeSpaceUploadServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); String proxyHost = System.getProperty("http.proxyHost"); String proxyPort = System.getProperty("http.proxyPort"); logger.info("Checking system properties for proxy configuration: [{}:{}]", proxyHost, proxyPort); if (null != proxyHost && null != proxyPort) { httpClient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort)); }//from w ww.jav a2s . co m }
From source file:uk.ac.ebi.arrayexpress.servlets.HttpProxyServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); /* proxy is not needed here I think, but I'll keep this just in case String proxyHost = System.getProperty("http.proxyHost"); String proxyPort = System.getProperty("http.proxyPort"); logger.info("Checking system properties for proxy configuration: [{}:{}]", proxyHost, proxyPort); if (null != proxyHost && null != proxyPort) { httpClient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort)); }//from w w w . jav a 2 s .co m */ }