use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project incubator-gobblin by apache.
the class AbstractHttpWriterBuilder method fromConfig.
public B fromConfig(Config config) {
config = config.withFallback(FALLBACK);
RequestConfig requestConfig = RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(config.getInt(REQUEST_TIME_OUT_MS_KEY)).setConnectTimeout(config.getInt(CONNECTION_TIME_OUT_MS_KEY)).setConnectionRequestTimeout(config.getInt(CONNECTION_TIME_OUT_MS_KEY)).build();
getHttpClientBuilder().setDefaultRequestConfig(requestConfig);
if (config.hasPath(STATIC_SVC_ENDPOINT)) {
try {
svcEndpoint = Optional.of(new URI(config.getString(AbstractHttpWriterBuilder.STATIC_SVC_ENDPOINT)));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
String connMgrStr = config.getString(HTTP_CONN_MANAGER);
switch(ConnManager.valueOf(connMgrStr.toUpperCase())) {
case BASIC:
httpConnManager = new BasicHttpClientConnectionManager();
break;
case POOLING:
PoolingHttpClientConnectionManager poolingConnMgr = new PoolingHttpClientConnectionManager();
poolingConnMgr.setMaxTotal(config.getInt(POOLING_CONN_MANAGER_MAX_TOTAL_CONN));
poolingConnMgr.setDefaultMaxPerRoute(config.getInt(POOLING_CONN_MANAGER_MAX_PER_CONN));
httpConnManager = poolingConnMgr;
break;
default:
throw new IllegalArgumentException(connMgrStr + " is not supported");
}
LOG.info("Using " + httpConnManager.getClass().getSimpleName());
return typedSelf();
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project incubator-gobblin by apache.
the class ApacheHttpClient method getHttpConnManager.
private HttpClientConnectionManager getHttpConnManager(Config config) {
HttpClientConnectionManager httpConnManager;
String connMgrStr = config.getString(HTTP_CONN_MANAGER);
switch(ConnManager.valueOf(connMgrStr.toUpperCase())) {
case BASIC:
httpConnManager = new BasicHttpClientConnectionManager();
break;
case POOLING:
PoolingHttpClientConnectionManager poolingConnMgr = new PoolingHttpClientConnectionManager();
poolingConnMgr.setMaxTotal(config.getInt(POOLING_CONN_MANAGER_MAX_TOTAL_CONN));
poolingConnMgr.setDefaultMaxPerRoute(config.getInt(POOLING_CONN_MANAGER_MAX_PER_CONN));
httpConnManager = poolingConnMgr;
break;
default:
throw new IllegalArgumentException(connMgrStr + " is not supported");
}
LOG.info("Using " + httpConnManager.getClass().getSimpleName());
return httpConnManager;
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project iaf by ibissource.
the class HttpSenderBase method open.
public void open() throws SenderException {
connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(getMaxConnections());
log.debug(getLogPrefix() + "set up connectionManager, inactivity checking [" + connectionManager.getValidateAfterInactivity() + "]");
boolean staleChecking = (connectionManager.getValidateAfterInactivity() >= 0);
if (staleChecking != isStaleChecking()) {
log.info(getLogPrefix() + "set up connectionManager, setting stale checking [" + isStaleChecking() + "]");
connectionManager.setValidateAfterInactivity(getStaleTimeout());
}
httpClientBuilder.useSystemProperties();
httpClientBuilder.disableAuthCaching();
httpClientBuilder.setConnectionManager(connectionManager);
if (transformerPool != null) {
try {
transformerPool.open();
} catch (Exception e) {
throw new SenderException(getLogPrefix() + "cannot start TransformerPool", e);
}
}
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project spring-boot by Linda-Tan.
the class RestTemplateConfig method httpClient.
@Bean
public HttpClient httpClient() throws KeyManagementException, NoSuchAlgorithmException {
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", new SSLConnectionSocketFactory(createIgnoreVerifySSL())).build();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry);
connectionManager.setMaxTotal(5);
connectionManager.setDefaultMaxPerRoute(5);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(8000).setConnectTimeout(8000).setConnectionRequestTimeout(8000).build();
return HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).setConnectionManager(connectionManager).build();
}
use of org.apache.http.impl.conn.PoolingHttpClientConnectionManager in project druidry by zapr-oss.
the class DruidJerseyClient method createConnectionManager.
private HttpClientConnectionManager createConnectionManager() {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
int numberOfConnectionsInPool = DEFAULT_CONNECTION_POOL_LIMIT;
if (this.druidConfiguration.getConcurrentConnectionsRequired() != null) {
numberOfConnectionsInPool = this.druidConfiguration.getConcurrentConnectionsRequired();
}
connectionManager.setDefaultMaxPerRoute(numberOfConnectionsInPool);
return connectionManager;
}
Aggregations