List of usage examples for org.apache.http.impl.conn PoolingClientConnectionManager PoolingClientConnectionManager
public PoolingClientConnectionManager()
From source file:org.apache.stratos.kubernetes.client.rest.RestClient.java
public RestClient() { PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); // Increase max total connection to 200 cm.setMaxTotal(200);/*from ww w. j a v a2 s. c o m*/ // Increase default max connection per route to 50 cm.setDefaultMaxPerRoute(50); httpClient = new DefaultHttpClient(cm); }
From source file:okhttp3.benchmarks.ApacheHttpClient.java
@Override public void prepare(Benchmark benchmark) { super.prepare(benchmark); ClientConnectionManager connectionManager = new PoolingClientConnectionManager(); if (benchmark.tls) { SslClient sslClient = SslClient.localhost(); connectionManager.getSchemeRegistry() .register(new Scheme("https", 443, new SSLSocketFactory(sslClient.sslContext))); }/*from w w w. j ava 2 s. co m*/ client = new DefaultHttpClient(connectionManager); }
From source file:com.squareup.okhttp.benchmarks.ApacheHttpClient.java
@Override public void prepare(Benchmark benchmark) { super.prepare(benchmark); ClientConnectionManager connectionManager = new PoolingClientConnectionManager(); if (benchmark.tls) { SSLContext sslContext = SslContextBuilder.localhost(); connectionManager.getSchemeRegistry() .register(new Scheme("https", 443, new SSLSocketFactory(sslContext))); }//from w ww . jav a 2 s .co m client = new DefaultHttpClient(connectionManager); }
From source file:at.ac.tuwien.big.testsuite.impl.util.HttpClientProducer.java
@Produces @ApplicationScoped//from w w w. j ava 2 s. c om HttpClient produceHttpClient() { PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); cm.setMaxTotal(100); cm.setDefaultMaxPerRoute(20); DefaultHttpClient client = new DefaultHttpClient(cm); client.setHttpRequestRetryHandler(new HttpRequestRetryHandler() { @Override public boolean retryRequest(IOException exception, int executionCount, HttpContext context) { if (executionCount >= MAX_RETRY_COUNT) { // Do not retry if over max retry count return false; } if (exception instanceof InterruptedIOException) { // Timeout return true; } if (exception instanceof UnknownHostException) { // Unknown host return true; } if (exception instanceof ConnectException) { // Connection refused return true; } if (exception instanceof SSLException) { // SSL handshake exception return true; } HttpRequest request = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST); boolean idempotent = !(request instanceof HttpEntityEnclosingRequest); if (idempotent) { // Retry if the request is considered idempotent return true; } return false; } }); return new DecompressingHttpClient(client); }
From source file:org.bimserver.client.json.JsonSocketReflectorFactory.java
public JsonSocketReflectorFactory(SServicesMap servicesMap) { if (servicesMap == null) { throw new IllegalArgumentException("servicesMap cannot be null"); }//from w ww .jav a 2 s .co m this.servicesMap = servicesMap; connectionManager = new PoolingClientConnectionManager(); connectionManager.setDefaultMaxPerRoute(5); connectionManager.setMaxTotal(20); httpclient = new DefaultHttpClient(connectionManager); httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); httpclient.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8"); }
From source file:com.kixeye.chassis.bootstrap.configuration.zookeeper.KixeyeExhibitorRestClient.java
public KixeyeExhibitorRestClient(boolean useSsl) { this.useSsl = useSsl; this.connectionManager = new PoolingClientConnectionManager(); this.client = new DefaultHttpClient(connectionManager); }
From source file:org.apache.stratos.integration.common.rest.IntegrationMockClient.java
public IntegrationMockClient(String endpoint) { super(endpoint); this.endpoint = endpoint; PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); // Increase max total connection to 200 cm.setMaxTotal(200);//from ww w . j a v a2s . co m // Increase default max connection per route to 50 cm.setDefaultMaxPerRoute(50); httpClient = new DefaultHttpClient(cm); httpClient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpClient); }
From source file:com.rackspacecloud.blueflood.http.HttpClientVendor.java
private ClientConnectionManager buildConnectionManager(int concurrency) { final PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(); connectionManager.setDefaultMaxPerRoute(concurrency); connectionManager.setMaxTotal(concurrency); return connectionManager; }
From source file:org.datacleaner.monitor.cluster.HttpClusterManagerFactory.java
@Override public ClusterManager getClusterManager(TenantIdentifier tenant) { final DefaultHttpClient httpClient = new DefaultHttpClient(new PoolingClientConnectionManager()); if (username != null && password != null) { final CredentialsProvider credentialsProvider = httpClient.getCredentialsProvider(); final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); final List<String> authpref = new ArrayList<String>(); authpref.add(AuthPolicy.BASIC);/*w w w . j a va2 s . c om*/ authpref.add(AuthPolicy.DIGEST); httpClient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref); credentialsProvider.setCredentials(new AuthScope(null, -1), credentials); } // use the server list final List<String> finalEndpoints = new ArrayList<String>(); for (String endpoint : slaveServerUrls) { if (!endpoint.endsWith("/")) { endpoint = endpoint + "/"; } endpoint = endpoint + "repository/" + tenant.getId() + "/cluster_slave_endpoint"; finalEndpoints.add(endpoint); } return new HttpClusterManager(httpClient, finalEndpoints); }
From source file:com.microsoft.applicationinsights.internal.channel.common.ApacheSender42.java
public ApacheSender42() { PoolingClientConnectionManager cm = new PoolingClientConnectionManager(); cm.setMaxTotal(DEFAULT_MAX_TOTAL_CONNECTIONS); cm.setDefaultMaxPerRoute(DEFAULT_MAX_CONNECTIONS_PER_ROUTE); httpClient = new DefaultHttpClient(cm); HttpParams params = httpClient.getParams(); HttpConnectionParams.setConnectionTimeout(params, REQUEST_TIMEOUT_IN_MILLIS); HttpConnectionParams.setSoTimeout(params, REQUEST_TIMEOUT_IN_MILLIS); InternalLogger.INSTANCE.info("Using Apache HttpClient 4.2"); }