List of usage examples for org.apache.http.impl.nio.client HttpAsyncClientBuilder setRoutePlanner
public final HttpAsyncClientBuilder setRoutePlanner(final HttpRoutePlanner routePlanner)
From source file:com.facebook.presto.jdbc.QueryExecutor.java
private QueryExecutor(String userAgent, ObjectMapper mapper, HttpHost proxy) { checkNotNull(userAgent, "userAgent is null"); checkNotNull(mapper, "mapper is null"); this.userAgent = userAgent; this.mapper = mapper; HttpClientBuilder builder = HttpClients.custom(); HttpAsyncClientBuilder asyncBuilder = HttpAsyncClients.custom(); if (proxy != null) { DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); builder.setRoutePlanner(routePlanner); asyncBuilder.setRoutePlanner(routePlanner); }/*from w w w.j a v a2s .com*/ this.httpClient = asyncBuilder.build(); this.httpClient.start(); }
From source file:com.guardtime.ksi.service.client.http.apache.ApacheHttpClient.java
/** * Creates asynchronous Apache HTTP client. * * @param settings/*from w w w . j av a 2s . c om*/ * - settings to use to create client * @param conf * - configuration related to async connection * @return instance of {@link CloseableHttpAsyncClient} */ private CloseableHttpAsyncClient createClient(AbstractHttpClientSettings settings, ApacheHttpClientConfiguration conf) { IOReactorConfig ioReactor = IOReactorConfig.custom().setIoThreadCount(conf.getMaxThreadCount()).build(); HttpAsyncClientBuilder httpClientBuilder = HttpAsyncClients.custom().useSystemProperties() // allow POST redirects .setRedirectStrategy(new LaxRedirectStrategy()).setMaxConnTotal(conf.getMaxTotalConnectionCount()) .setMaxConnPerRoute(conf.getMaxRouteConnectionCount()).setDefaultIOReactorConfig(ioReactor) .setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy()) .setDefaultRequestConfig(createDefaultRequestConfig(settings)); if (settings.getProxyUrl() != null) { DefaultProxyRoutePlanner routePlanner = createProxyRoutePlanner(settings, httpClientBuilder); httpClientBuilder.setRoutePlanner(routePlanner); } CloseableHttpAsyncClient httpClient = httpClientBuilder.build(); httpClient.start(); return httpClient; }