List of usage examples for org.apache.http.impl.conn PoolingClientConnectionManager setDefaultMaxPerRoute
public void setDefaultMaxPerRoute(final int max)
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 w w w .j a va2 s .com*/ // Increase default max connection per route to 50 cm.setDefaultMaxPerRoute(50); httpClient = new DefaultHttpClient(cm); httpClient = (DefaultHttpClient) WebClientWrapper.wrapClient(httpClient); }
From source file:com.jillesvangurp.httpclientfuture.HttpClientWithFutureTest.java
@BeforeClass public void beforeClass() { webServerExecutor = Executors.newSingleThreadExecutor(); webServer = new WebServer(); webServerExecutor.execute(webServer); clientThreadPool = Executors.newFixedThreadPool(threads); PoolingClientConnectionManager conman = new PoolingClientConnectionManager(); conman.setDefaultMaxPerRoute(threads); conman.setMaxTotal(threads);/* w w w.java 2 s .c o m*/ DefaultHttpClient httpclient = new DefaultHttpClient(conman); client = new HttpClientWithFuture<Boolean>(httpclient, clientThreadPool, new ResponseHandler<Boolean>() { @Override public Boolean handleResponse(HttpResponse response) throws ClientProtocolException, IOException { return response.getStatusLine().getStatusCode() == 200; } }); }
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 w w w. java2 s .co m*/ // Increase default max connection per route to 50 cm.setDefaultMaxPerRoute(50); httpClient = new DefaultHttpClient(cm); }
From source file:org.yamj.api.common.http.AbstractPoolingHttpClient.java
@Override protected ClientConnectionManager createClientConnectionManager() { PoolingClientConnectionManager clientManager = new PoolingClientConnectionManager(); clientManager.setDefaultMaxPerRoute(connectionsMaxPerRoute); clientManager.setMaxTotal(connectionsMaxTotal); return clientManager; }
From source file:com.sematext.ag.sink.AbstractHttpSink.java
/** * (non-Javadoc)/* w ww .j a v a2 s. c o m*/ * * @see com.sematext.ag.sink.Sink#init(com.sematext.ag.PlayerConfig) */ @Override public void init(PlayerConfig config) throws InitializationFailedException { super.init(config); PoolingClientConnectionManager connectionManager = (PoolingClientConnectionManager) HTTP_CLIENT_INSTANCE .getConnectionManager(); if (config.get(MAXIMUM_CONNECTIONS_PER_ROUTE_KEY) != null && !config.get(MAXIMUM_CONNECTIONS_PER_ROUTE_KEY).isEmpty()) { connectionManager .setDefaultMaxPerRoute(Integer.parseInt(config.get(MAXIMUM_CONNECTIONS_PER_ROUTE_KEY))); } if (config.get(MAXIMUM_CONNECTIONS_TOTAL_KEY) != null && !config.get(MAXIMUM_CONNECTIONS_TOTAL_KEY).isEmpty()) { connectionManager.setMaxTotal(Integer.parseInt(config.get(MAXIMUM_CONNECTIONS_TOTAL_KEY))); } }
From source file:com.proofpoint.http.client.ApacheHttpClient.java
public ApacheHttpClient(HttpClientConfig config, Set<? extends HttpRequestFilter> requestFilters) { Preconditions.checkNotNull(config, "config is null"); Preconditions.checkNotNull(requestFilters, "requestFilters is null"); PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(); connectionManager.setMaxTotal(config.getMaxConnections()); connectionManager.setDefaultMaxPerRoute(config.getMaxConnectionsPerServer()); BasicHttpParams httpParams = new BasicHttpParams(); httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, Ints.checkedCast(config.getReadTimeout().toMillis())); httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Ints.checkedCast(config.getConnectTimeout().toMillis())); httpParams.setParameter(CoreConnectionPNames.SO_LINGER, 0); // do we need this? DefaultHttpClient defaultHttpClient = new DefaultHttpClient(connectionManager, httpParams); defaultHttpClient.setKeepAliveStrategy(new FixedIntervalKeepAliveStrategy(config.getKeepAliveInterval())); defaultHttpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false)); this.httpClient = defaultHttpClient; this.requestFilters = ImmutableList.copyOf(requestFilters); }
From source file:org.oss.bonita.utils.bonita.RestClient.java
public RestClient(String bonitaURI) { this.bonitaURI = bonitaURI; this.httpContext = new BasicHttpContext(); PoolingClientConnectionManager conMan = new PoolingClientConnectionManager( SchemeRegistryFactory.createDefault()); conMan.setMaxTotal(200);// www.ja v a 2 s .c o m conMan.setDefaultMaxPerRoute(200); this.httpClient = new DefaultHttpClient(conMan); }
From source file:org.wrml.runtime.service.rest.RestService.java
@Override protected void initFromConfiguration(final ServiceConfiguration config) { final SchemeRegistry schemeRegistry = new SchemeRegistry(); // Tips on HttpClient performance: http://hc.apache.org/httpclient-3.x/performance.html schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); // TODO: Make configurable final PoolingClientConnectionManager _ConnectionManager = new PoolingClientConnectionManager( schemeRegistry);/*w ww . j av a 2s. co m*/ _ConnectionManager.setMaxTotal(200); _ConnectionManager.setDefaultMaxPerRoute(20); _HttpClient = new DefaultHttpClient(_ConnectionManager); }
From source file:org.greencheek.spring.rest.SSLCachingHttpComponentsClientHttpRequestFactory.java
/** * Create a new instance of the HttpComponentsClientHttpRequestFactory with a default * {@link HttpClient} that uses a default {@link org.apache.http.impl.conn.PoolingClientConnectionManager}. *///from w w w .j a v a 2 s. co m public SSLCachingHttpComponentsClientHttpRequestFactory(boolean useSSLCaching) { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSystemSocketFactory())); PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry); connectionManager.setMaxTotal(DEFAULT_MAX_TOTAL_CONNECTIONS); connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_CONNECTIONS_PER_ROUTE); this.httpClient = new DefaultHttpClient(connectionManager); ((DefaultHttpClient) this.httpClient).removeRequestInterceptorByClass(RequestDefaultHeaders.class); setReadTimeout(DEFAULT_READ_TIMEOUT_MILLISECONDS); setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLISECONDS); this.useSSLCaching = useSSLCaching; setTcpNoDelay(DEFAULT_TCP_NO_DELAY); }
From source file:nextflow.fs.dx.api.DxHttpClient.java
/** * Creates the http client using a thread safe {@code PoolingClientConnectionManager} * * See http://hc.apache.org/httpcomponents-client-4.2.x/tutorial/html/connmgmt.html#d5e581 * * @authors Paolo Di Tommaso <paolo.ditommaso@gmail.com> * * @return/* w w w .j a va2 s.c o m*/ */ protected DxHttpClient() { log.debug("Creating DxHttpClient object"); try { DxEnv env = DxEnv.getInstance(); securityContext = env.getSecurityContext(); apiserver = env.getApiserverPath(); final String PROT = env.getApiserverProtocol(); final String HOST = env.getApiserverHost(); final int PORT = env.getApiserverPort(); SchemeRegistry schemeRegistry = new SchemeRegistry(); SchemeSocketFactory factory = "https".equals(PROT) ? SSLSocketFactory.getSocketFactory() : PlainSocketFactory.getSocketFactory(); schemeRegistry.register(new Scheme(PROT, PORT, factory)); PoolingClientConnectionManager manager = new PoolingClientConnectionManager(schemeRegistry); manager.setMaxTotal(100); manager.setDefaultMaxPerRoute(10); manager.setMaxPerRoute(new HttpRoute(new HttpHost(HOST, PORT)), 50); httpclient = new DefaultHttpClient(manager); } catch (IOException e) { throw new IllegalStateException(e); } }