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

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

Introduction

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

Prototype

public void setMaxTotal(final int max) 

Source Link

Usage

From source file:org.neo4j.ogm.drivers.http.driver.HttpDriverTest.java

@Test
@Ignore/*w w  w .j av  a  2s . c o m*/
public void shouldInitialiseWithCustomHttpClient() {

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(1);
    connectionManager.setDefaultMaxPerRoute(1);

    CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connectionManager).build();

    //        TODO does this still have any value?
    //        DriverManager.register(new HttpDriver(httpClient));

    //        assertThat(DriverManager.getDriver()).isNotNull();
}

From source file:org.neo4j.drivers.http.driver.HttpDriverTest.java

@Test
public void shouldInitialiseWithCustomHttpClient() {

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(1);
    connectionManager.setDefaultMaxPerRoute(1);

    CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connectionManager).build();

    Components.setDriver(new HttpDriver(httpClient));

    assertNotNull(Components.driver());//  ww  w .ja v  a 2s. com

}

From source file:lh.api.showcase.server.DefaultHttpClient.java

DefaultHttpClient() {
    logger.info("Create default http client");

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(maxTotalConnections);
    connectionManager.setDefaultMaxPerRoute(maxTotalPerRouteConnections);

    conf = DefaultConfiguration.INSTANCE.get();
    httpClient = HttpClientUtils.createHttpClient(conf.getHttpProxySettings(), connectionManager);

    logger.info("Default http client has " + connectionManager.getMaxTotal() + " max total connections and "
            + connectionManager.getDefaultMaxPerRoute() + " max connections per route");
}

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

private CloseableHttpClient createHttpClient() {
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(100);
    return HttpClients.custom().setConnectionManager(cm).build();
}

From source file:piecework.content.concrete.RemoteResourceTest.java

@Before
public void setup() {
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setMaxTotal(100);
    this.client = HttpClients.custom().setConnectionManager(cm).build();
    URI uri = URI.create(URI_STRING);
    this.remoteResource = new RemoteResource(client, uri);
}

From source file:org.neo4j.ogm.service.ComponentsTest.java

@Test
public void shouldCustomiseHttpDriverClient() {

    if (Components.driver() instanceof HttpDriver) {

        PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
        connectionManager.setMaxTotal(1);
        connectionManager.setDefaultMaxPerRoute(1);

        CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connectionManager).build();

        Driver driver = new HttpDriver(httpClient);

        Components.setDriver(driver);//from ww w . ja v a  2  s.  co  m

        Assert.assertEquals(driver, Components.driver());

    }
}

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:nl.eveoh.mytimetable.apiclient.service.MyTimetableHttpClientBuilderImpl.java

public CloseableHttpClient build(Configuration configuration) {
    Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", new PlainConnectionSocketFactory())
            .register("https", createSslSocketFactory(configuration)).build();

    // Create the Connection manager.
    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry);
    connectionManager.setMaxTotal(configuration.getApiMaxConnections());
    connectionManager.setDefaultMaxPerRoute(configuration.getApiMaxConnections());

    // Create the HttpClient.
    return HttpClients.custom().setConnectionManager(connectionManager).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);

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

From source file:org.sonatype.spice.zapper.client.hc4.Hc4ClientBuilder.java

public Hc4Client build() {
    final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", PlainConnectionSocketFactory.getSocketFactory())
            .register("https", SSLConnectionSocketFactory.getSystemSocketFactory()).build();

    final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
    cm.setMaxTotal(200);
    cm.setDefaultMaxPerRoute(parameters.getMaximumTrackCount());

    final HttpClientBuilder httpClientBuilder = HttpClientBuilder.create().setConnectionManager(cm)
            .setUserAgent("Zapper/1.0-HC4");

    if (proxyServer != null) {
        httpClientBuilder.setProxy(proxyServer);
    }/*from   w  w w  . j  a v  a2  s. c  o  m*/
    if (credentialsProvider != null) {
        httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
    }

    return new Hc4Client(parameters, remoteUrl, httpClientBuilder.build(),
            preemptiveAuth ? credentialsProvider : null);
}