use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionTest method assertMaxConnections.
@SuppressWarnings("resource")
private static void assertMaxConnections(DefaultConnection connection, int maxConnections, ProxyConfiguration proxyConfiguration) {
CloseableHttpClient httpClient = ReflectionUtil.getField(connection, "httpClient", CloseableHttpClient.class);
PoolingHttpClientConnectionManager connectionManager = ReflectionUtil.getField(httpClient, "connManager", PoolingHttpClientConnectionManager.class);
Assert.assertEquals(maxConnections, connectionManager.getDefaultMaxPerRoute());
Assert.assertTrue(maxConnections <= connectionManager.getMaxTotal());
HttpHost target = new HttpHost("api-sandbox.globalcollect.com", -1, "https");
HttpHost proxy = proxyConfiguration != null ? new HttpHost(proxyConfiguration.getHost(), proxyConfiguration.getPort(), proxyConfiguration.getScheme()) : null;
HttpRoute route = proxy != null ? new HttpRoute(target, proxy) : new HttpRoute(target);
Assert.assertEquals(maxConnections, connectionManager.getMaxPerRoute(route));
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnection method createHttpClientConnectionManager.
private HttpClientConnectionManager createHttpClientConnectionManager(int maxConnections) {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setDefaultMaxPerRoute(maxConnections);
connectionManager.setMaxTotal(maxConnections + 20);
return connectionManager;
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project solr-cmd-utils by tblsoft.
the class HttpFilter method init.
@Override
public void init() {
urlField = getProperty("urlField", "url");
userAgent = getProperty("userAgent", "Solr Cmd Utils Http Agent/1.0");
// httpclient = HttpClients.createDefault();
threads = getPropertyAsInt("threads", 1);
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(threads);
cm.setDefaultMaxPerRoute(threads);
httpclient = HttpClients.custom().setConnectionManager(cm).setMaxConnPerRoute(threads).build();
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("tblsoft-http-filter-thread-%d").build();
executor = Executors.newFixedThreadPool(threads, namedThreadFactory);
System.out.println("start http filter with threads: " + threads);
super.init();
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project spring-cloud-netflix by spring-cloud.
the class RibbonLoadBalancingHttpClientTests method testConnections.
@Test
public void testConnections() throws Exception {
SpringClientFactory factory = new SpringClientFactory();
factory.setApplicationContext(new AnnotationConfigApplicationContext(RibbonAutoConfiguration.class, Connections.class));
RetryableRibbonLoadBalancingHttpClient client = factory.getClient("service", RetryableRibbonLoadBalancingHttpClient.class);
HttpClient delegate = client.getDelegate();
PoolingHttpClientConnectionManager connManager = (PoolingHttpClientConnectionManager) ReflectionTestUtils.getField(delegate, "connManager");
assertThat(connManager.getMaxTotal(), is(101));
assertThat(connManager.getDefaultMaxPerRoute(), is(201));
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project repseqio by repseqio.
the class SequenceResolvers method initDefaultResolver.
public static void initDefaultResolver(Path cacheFolderPath) {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
CloseableHttpClient httpClient = HttpClients.custom().disableCookieManagement().setConnectionManager(cm).build();
HTTPResolversContext context = new HTTPResolversContext(cacheFolderPath, httpClient);
initDefaultResolver(context);
}
Aggregations