Example usage for org.apache.http.impl.conn PoolingHttpClientConnectionManager PoolingHttpClientConnectionManager

List of usage examples for org.apache.http.impl.conn PoolingHttpClientConnectionManager PoolingHttpClientConnectionManager

Introduction

In this page you can find the example usage for org.apache.http.impl.conn PoolingHttpClientConnectionManager PoolingHttpClientConnectionManager.

Prototype

public PoolingHttpClientConnectionManager() 

Source Link

Usage

From source file:co.tuzza.clicksend4j.http.HttpClientUtils.java

public HttpClientUtils(int connectionTimeout, int socketTimeout) {
    this.connectionTimeout = connectionTimeout;
    this.socketTimeout = socketTimeout;

    this.clientConnectionManager = new PoolingHttpClientConnectionManager();
    this.clientConnectionManager.setDefaultMaxPerRoute(200);
    this.clientConnectionManager.setMaxTotal(200);
}

From source file:com.microsoft.applicationinsights.internal.channel.common.ApacheSender43.java

public ApacheSender43() {
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(DEFAULT_MAX_TOTAL_CONNECTIONS);
    cm.setDefaultMaxPerRoute(DEFAULT_MAX_CONNECTIONS_PER_ROUTE);

    httpClient = HttpClients.custom().setConnectionManager(cm).build();
}

From source file:ok.MyService2.java

@Override
protected Task<BlockingQueue> createTask() {
    final Task<BlockingQueue> task;
    task = new Task<BlockingQueue>() {

        @Override/*from w ww .  j  av a 2 s .  c  om*/
        protected BlockingQueue call() throws Exception {
            BlockingQueue result = new LinkedBlockingQueue<String>();

            PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
            cm.setMaxTotal(100);

            CloseableHttpClient httpclient = HttpClients.custom().setConnectionManager(cm).build();
            try {
                ExecutorService executor = Executors.newFixedThreadPool(sites.size());
                List<Future<String>> results = new ArrayList<Future<String>>();
                for (int i = 0; i < sites.size(); i++) {
                    HttpGet httpget = new HttpGet(sites.get(i));
                    Callable worker = new MyCallable(httpclient, httpget);
                    Future<String> res = executor.submit(worker);
                    results.add(res);
                    // String url = hostList[i];
                    //   Runnable worker = new MyRunnable(url);
                    //   executor.execute(worker);
                    //   executor.submit(null);

                }
                executor.shutdown();
                // Wait until all threads are finish
                //                   while (!executor.isTerminated()) {
                //
                //                   }
                for (Future<String> element : results) {
                    result.add(element.get());
                }
                System.out.println("\nFinished all threads");

            } finally {
                httpclient.close();
            }
            return result;
        }

    };
    return task;
}

From source file:fi.vm.kapa.identification.config.HttpClientConfiguration.java

@Bean
public HttpClientConnectionManager connectionManager() {
    PoolingHttpClientConnectionManager connectionManager;
    connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setDefaultMaxPerRoute(defaultMaxPerRoute);
    connectionManager.setMaxTotal(maxTotal);
    return connectionManager;
}

From source file:org.fcrepo.examples.models.integration.ExampleNodeTypesIT.java

public ExampleNodeTypesIT() {
    connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(Integer.MAX_VALUE);
    connectionManager.setDefaultMaxPerRoute(20);
    connectionManager.closeIdleConnections(3, TimeUnit.SECONDS);
    client = HttpClientBuilder.create().setConnectionManager(connectionManager).build();
    modelSetsDirectory = new File(modelSetsPath);
    if (!modelSetsDirectory.exists()) {
        throw new Error("Cannot find model sets");
    }/*from w  ww.j a  v a2  s. com*/
}

From source file:com.indoqa.httpproxy.HttpProxyBuilder.java

@SuppressWarnings("resource")
public HttpProxy build() {
    CloseableHttpClient httpClient = this.httpClientBuilder.setDefaultHeaders(this.defaultHeaders)
            .setConnectionManager(new PoolingHttpClientConnectionManager())
            .setDefaultRequestConfig(this.requestConfigBuilder.build()).build();

    return new HttpClientProxy(this.proxyMountPath, this.targetBaseUrl, httpClient, this.proxyPathCreator);
}

From source file:org.apache.hadoop.gateway.services.metrics.impl.instr.InstrHttpClientBuilderProvider.java

@Override
public HttpClientBuilder getInstrumented(MetricsContext metricsContext) {
    MetricRegistry registry = (MetricRegistry) metricsContext
            .getProperty(DefaultMetricsService.METRICS_REGISTRY);
    return HttpClientBuilder.create()
            .setRequestExecutor(new InstrumentedHttpRequestExecutor(registry, TOPOLOGY_URL_AND_METHOD))
            .setConnectionManager(new PoolingHttpClientConnectionManager());
}

From source file:com.github.autermann.wps.streaming.delegate.DelegatingExecutor.java

private CloseableHttpClient createHttpClient() {
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(100);/*from  w ww. j a  v  a2s . com*/
    return HttpClients.custom().setConnectionManager(cm).build();
}

From source file:com.olacabs.fabric.compute.builder.impl.HttpJarDownloader.java

public HttpJarDownloader() throws Exception {
    FileAttribute<Set<PosixFilePermission>> perms = PosixFilePermissions
            .asFileAttribute(PosixFilePermissions.fromString("rwxr-xr-x"));
    Path createdPath = Files.createTempDirectory(null, perms);
    this.tmpDirectory = createdPath.toAbsolutePath().toString();

    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(20);/*from   w w  w. ja  v a2  s.  c o  m*/

    httpClient = HttpClients.custom().setConnectionManager(cm).build();
}