LOG.debug("HTTP Client config"); LOG.debug(crowdServer.toString()); LOG.debug("Max connections: {}", connectionManager.getDefaultMaxPerRoute()); LOG.debug("Socket timeout: {}", requestConfig.getSocketTimeout()); LOG.debug("Connect timeout: {}", requestConfig.getConnectTimeout());
if (null == destinationAcceptsMap.putIfAbsent(baseUrl, destinationAccepts)) { connManager.setMaxTotal(connManager.getMaxTotal() + connManager.getDefaultMaxPerRoute());
@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()); assertEquals(2, cm.getDefaultMaxPerRoute()); }
private HttpClientConnectionManager getConnectionManager() { 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; }
public static Map<String, Integer> getConnectionPoolStats() { Map<String, Integer> stats = new HashMap<>(); PoolStats poolStats = pool.getTotalStats(); stats.put("availableConnections", poolStats.getAvailable()); stats.put("maxConnections", poolStats.getMax()); stats.put("leasedConnections", poolStats.getLeased()); stats.put("pendingConnections", poolStats.getPending()); stats.put("defaultMaxPerRoute", pool.getDefaultMaxPerRoute()); return stats; }
public static Map<String, Integer> getConnectionPoolStats() { Map<String, Integer> stats = new HashMap<>(); PoolStats poolStats = pool.getTotalStats(); stats.put("availableConnections", poolStats.getAvailable()); stats.put("maxConnections", poolStats.getMax()); stats.put("leasedConnections", poolStats.getLeased()); stats.put("pendingConnections", poolStats.getPending()); stats.put("defaultMaxPerRoute", pool.getDefaultMaxPerRoute()); return stats; }
try { int maxConcurrentDownloads = Integer.parseInt(this.testElement.getConcurrentPool()); pHCCM.setDefaultMaxPerRoute(Math.max(maxConcurrentDownloads, pHCCM.getDefaultMaxPerRoute())); } catch (NumberFormatException nfe) {
if (null == destinationAcceptsMap.putIfAbsent(baseUrl, destinationAccepts)) { connManager.setMaxTotal(connManager.getMaxTotal() + connManager.getDefaultMaxPerRoute());
@Test public void newConnectionManager() throws Exception { HttpClientConnectionManager connectionManager = new DefaultApacheHttpClientConnectionManagerFactory() .newConnectionManager(false, 2, 6); assertEquals(6, ((PoolingHttpClientConnectionManager) connectionManager) .getDefaultMaxPerRoute()); assertEquals(2, ((PoolingHttpClientConnectionManager) connectionManager).getMaxTotal()); Object pool = getField(((PoolingHttpClientConnectionManager) connectionManager), "pool"); assertEquals(new Long(-1), getField(pool, "timeToLive")); TimeUnit timeUnit = getField(pool, "tunit"); assertEquals(TimeUnit.MILLISECONDS, timeUnit); }
@Test public void newConnectionManagerWithTTL() throws Exception { HttpClientConnectionManager connectionManager = new DefaultApacheHttpClientConnectionManagerFactory() .newConnectionManager(false, 2, 6, 56l, TimeUnit.DAYS, null); assertEquals(6, ((PoolingHttpClientConnectionManager) connectionManager) .getDefaultMaxPerRoute()); assertEquals(2, ((PoolingHttpClientConnectionManager) connectionManager).getMaxTotal()); Object pool = getField(((PoolingHttpClientConnectionManager) connectionManager), "pool"); assertEquals(new Long(56), getField(pool, "timeToLive")); TimeUnit timeUnit = getField(pool, "tunit"); assertEquals(TimeUnit.DAYS, timeUnit); }