List of usage examples for org.apache.http.impl.conn PoolingHttpClientConnectionManager getMaxTotal
public int getMaxTotal()
From source file:de.codecentric.boot.admin.zuul.filters.route.SimpleHostRoutingFilterTests.java
@Test public void connectionPropertiesAreApplied() { addEnvironment(this.context, "zuul.host.maxTotalConnections=100", "zuul.host.maxPerRouteConnections=10"); setupContext();//w ww.j a va2s . c o m PoolingHttpClientConnectionManager connMgr = getFilter().newConnectionManager(); assertEquals(100, connMgr.getMaxTotal()); assertEquals(10, connMgr.getDefaultMaxPerRoute()); }
From source file:de.codecentric.boot.admin.zuul.filters.route.SimpleHostRoutingFilterTests.java
@Test public void defaultPropertiesAreApplied() { setupContext();/*from w w w .j a v a2 s . c o m*/ PoolingHttpClientConnectionManager connMgr = getFilter().newConnectionManager(); assertEquals(200, connMgr.getMaxTotal()); assertEquals(20, connMgr.getDefaultMaxPerRoute()); }
From source file:org.apache.camel.component.http4.HttpEndpointURLTest.java
@Test public void testConnectionManagerFromHttpUri() throws Exception { HttpEndpoint http1 = context.getEndpoint( "http4://www.google.com?maxTotalConnections=40&connectionsPerRoute=5", HttpEndpoint.class); HttpClientConnectionManager connectionManager = http1.getClientConnectionManager(); assertTrue("Get a wrong type of connection manager", connectionManager instanceof PoolingHttpClientConnectionManager); @SuppressWarnings("resource") PoolingHttpClientConnectionManager poolManager = (PoolingHttpClientConnectionManager) connectionManager; assertEquals("Get a wrong setting of maxTotalConnections", 40, poolManager.getMaxTotal()); assertEquals("Get a wrong setting of connectionsPerRoute", 5, poolManager.getDefaultMaxPerRoute()); }
From source file:org.springframework.cloud.netflix.ribbon.apache.RibbonLoadBalancingHttpClientTests.java
@Test public void testConnections() throws Exception { SpringClientFactory factory = new SpringClientFactory(); factory.setApplicationContext(//from w w w .j a v a 2 s . co m new AnnotationConfigApplicationContext(RibbonAutoConfiguration.class, Connections.class)); RibbonLoadBalancingHttpClient client = factory.getClient("service", RibbonLoadBalancingHttpClient.class); HttpClient delegate = client.getDelegate(); PoolingHttpClientConnectionManager connManager = (PoolingHttpClientConnectionManager) ReflectionTestUtils .getField(delegate, "connManager"); assertThat(connManager.getMaxTotal(), is(101)); assertThat(connManager.getDefaultMaxPerRoute(), is(201)); }
From source file:io.wcm.caravan.commons.httpclient.impl.HttpClientItemTest.java
@Test public void testClientConnectionManager() { HttpClientConfigImpl config = context.registerInjectActivateService(new HttpClientConfigImpl(), ImmutableMap.<String, Object>builder().put(MAX_CONNECTIONS_PER_HOST_PROPERTY, 9) .put(MAX_TOTAL_CONNECTIONS_PROPERTY, 99).build()); HttpClientItem item = new HttpClientItem(config); HttpClient client = item.getHttpClient(); PoolingHttpClientConnectionManager connManager = HttpClientTestUtils.getConnectionManager(client); assertEquals(9, connManager.getDefaultMaxPerRoute()); assertEquals(99, connManager.getMaxTotal()); item.close();/*from w ww . j a va 2 s. c om*/ }
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:org.apache.metron.stellar.dsl.functions.RestFunctionsTest.java
@Test public void restGetShouldGetPoolingConnectionManager() { RestFunctions.RestGet restGet = new RestFunctions.RestGet(); RestConfig restConfig = new RestConfig(); restConfig.put(POOLING_MAX_TOTAL, 5); restConfig.put(POOLING_DEFAULT_MAX_PER_RUOTE, 2); PoolingHttpClientConnectionManager cm = restGet.getConnectionManager(restConfig); assertEquals(5, cm.getMaxTotal());/*w w w. ja v a2 s . com*/ assertEquals(2, cm.getDefaultMaxPerRoute()); }
From source file:com.streamsets.datacollector.credential.cyberark.TestWebServicesFetcher.java
@Test public void testInitializationCustomNoSslBasicAuth() throws Exception { Properties props = new Properties(); props.setProperty(WebServicesFetcher.URL_KEY, "http://foo"); props.setProperty(WebServicesFetcher.APP_ID_KEY, "appId"); props.setProperty(WebServicesFetcher.KEYSTORE_FILE_KEY, ""); props.setProperty(WebServicesFetcher.KEYSTORE_PASSWORD_KEY, ""); props.setProperty(WebServicesFetcher.KEY_PASSWORD_KEY, ""); props.setProperty(WebServicesFetcher.TRUSTSTORE_FILE_KEY, ""); props.setProperty(WebServicesFetcher.TRUSTSTORE_PASSWORD_KEY, ""); props.setProperty(WebServicesFetcher.SUPPORTED_PROTOCOLS_KEY, ""); props.setProperty(WebServicesFetcher.HOSTNAME_VERIFIER_SKIP_KEY, ""); props.setProperty(WebServicesFetcher.MAX_CONCURRENT_CONNECTIONS_KEY, "1"); props.setProperty(WebServicesFetcher.VALIDATE_AFTER_INACTIVITY_KEY, "2"); props.setProperty(WebServicesFetcher.CONNECTION_TIMEOUT_KEY, "5000"); props.setProperty(WebServicesFetcher.NAME_SEPARATOR_KEY, "+"); props.setProperty(WebServicesFetcher.HTTP_AUTH_TYPE_KEY, "basic"); props.setProperty(WebServicesFetcher.HTTP_AUTH_USER_KEY, "user"); props.setProperty(WebServicesFetcher.HTTP_AUTH_PASSWORD_KEY, "password"); Configuration conf = createConfig(props); WebServicesFetcher fetcher = new WebServicesFetcher(); try {// www .j a va 2s . co m fetcher.init(conf); Assert.assertNotNull(fetcher.getConfig()); Assert.assertEquals("http://foo", fetcher.getUrl()); Assert.assertEquals("appId", fetcher.getAppId()); Assert.assertEquals(5000, fetcher.getConnectionTimeout()); Assert.assertEquals("+", fetcher.getSeparator()); Assert.assertEquals("basic", fetcher.getHttpAuth()); Assert.assertEquals("user", fetcher.getHttpAuthUser()); Assert.assertEquals("password", fetcher.getHttpAuthPassword()); Assert.assertNotNull(fetcher.getCredentialsProvider()); Assert.assertEquals("user", fetcher.getCredentialsProvider().getCredentials(AuthScope.ANY).getUserPrincipal().getName()); Assert.assertEquals("password", fetcher.getCredentialsProvider().getCredentials(AuthScope.ANY).getPassword()); Assert.assertTrue(fetcher.getAuthCache().get(new HttpHost(fetcher.getUrl())) instanceof BasicScheme); PoolingHttpClientConnectionManager connectionManager = fetcher.getConnectionManager(); Assert.assertEquals(1, connectionManager.getMaxTotal()); Assert.assertEquals(1, connectionManager.getDefaultMaxPerRoute()); Assert.assertEquals(2, connectionManager.getValidateAfterInactivity()); Assert.assertNull(fetcher.getSslConnectionSocketFactory()); } finally { fetcher.destroy(); } }
From source file:com.streamsets.datacollector.credential.cyberark.TestWebServicesFetcher.java
@Test public void testInitializationCustomNoSslDigestAuth() throws Exception { Properties props = new Properties(); props.setProperty(WebServicesFetcher.URL_KEY, "http://foo"); props.setProperty(WebServicesFetcher.APP_ID_KEY, "appId"); props.setProperty(WebServicesFetcher.KEYSTORE_FILE_KEY, ""); props.setProperty(WebServicesFetcher.KEYSTORE_PASSWORD_KEY, ""); props.setProperty(WebServicesFetcher.KEY_PASSWORD_KEY, ""); props.setProperty(WebServicesFetcher.TRUSTSTORE_FILE_KEY, ""); props.setProperty(WebServicesFetcher.TRUSTSTORE_PASSWORD_KEY, ""); props.setProperty(WebServicesFetcher.SUPPORTED_PROTOCOLS_KEY, ""); props.setProperty(WebServicesFetcher.HOSTNAME_VERIFIER_SKIP_KEY, ""); props.setProperty(WebServicesFetcher.MAX_CONCURRENT_CONNECTIONS_KEY, "1"); props.setProperty(WebServicesFetcher.VALIDATE_AFTER_INACTIVITY_KEY, "2"); props.setProperty(WebServicesFetcher.CONNECTION_TIMEOUT_KEY, "5000"); props.setProperty(WebServicesFetcher.NAME_SEPARATOR_KEY, "+"); props.setProperty(WebServicesFetcher.HTTP_AUTH_TYPE_KEY, "digest"); props.setProperty(WebServicesFetcher.HTTP_AUTH_USER_KEY, "user"); props.setProperty(WebServicesFetcher.HTTP_AUTH_PASSWORD_KEY, "password"); Configuration conf = createConfig(props); WebServicesFetcher fetcher = new WebServicesFetcher(); try {// w w w . jav a 2 s.c o m fetcher.init(conf); Assert.assertNotNull(fetcher.getConfig()); Assert.assertEquals("http://foo", fetcher.getUrl()); Assert.assertEquals("appId", fetcher.getAppId()); Assert.assertEquals(5000, fetcher.getConnectionTimeout()); Assert.assertEquals("+", fetcher.getSeparator()); Assert.assertEquals("digest", fetcher.getHttpAuth()); Assert.assertEquals("user", fetcher.getHttpAuthUser()); Assert.assertEquals("password", fetcher.getHttpAuthPassword()); Assert.assertNotNull(fetcher.getCredentialsProvider()); Assert.assertEquals("user", fetcher.getCredentialsProvider().getCredentials(AuthScope.ANY).getUserPrincipal().getName()); Assert.assertEquals("password", fetcher.getCredentialsProvider().getCredentials(AuthScope.ANY).getPassword()); Assert.assertTrue(fetcher.getAuthCache().get(new HttpHost(fetcher.getUrl())) instanceof DigestScheme); PoolingHttpClientConnectionManager connectionManager = fetcher.getConnectionManager(); Assert.assertEquals(1, connectionManager.getMaxTotal()); Assert.assertEquals(1, connectionManager.getDefaultMaxPerRoute()); Assert.assertEquals(2, connectionManager.getValidateAfterInactivity()); Assert.assertNull(fetcher.getSslConnectionSocketFactory()); } finally { fetcher.destroy(); } }
From source file:eu.europa.esig.dss.client.http.commons.CommonsDataLoader.java
private HttpClientConnectionManager getConnectionManager() throws DSSException { RegistryBuilder<ConnectionSocketFactory> socketFactoryRegistryBuilder = RegistryBuilder.create(); socketFactoryRegistryBuilder = setConnectionManagerSchemeHttp(socketFactoryRegistryBuilder); socketFactoryRegistryBuilder = setConnectionManagerSchemeHttps(socketFactoryRegistryBuilder); final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( socketFactoryRegistryBuilder.build()); connectionManager.setMaxTotal(getConnectionsMaxTotal()); connectionManager.setDefaultMaxPerRoute(getConnectionsMaxPerRoute()); LOG.debug("PoolingHttpClientConnectionManager: max total: " + connectionManager.getMaxTotal()); LOG.debug( "PoolingHttpClientConnectionManager: max per route: " + connectionManager.getDefaultMaxPerRoute()); return connectionManager; }