List of usage examples for org.apache.http.config SocketConfig copy
public static Builder copy(SocketConfig socketConfig)
From source file:org.sonatype.nexus.httpclient.HttpClientPlan.java
public HttpClientPlan() { this.client = HttpClientBuilder.create(); this.connection = ConnectionConfig.copy(ConnectionConfig.DEFAULT); this.socket = SocketConfig.copy(SocketConfig.DEFAULT); this.request = RequestConfig.copy(RequestConfig.DEFAULT); this.headers = new HashMap<>(); this.attributes = new HashMap<>(); }
From source file:com.spotify.ffwd.signalfx.SignalFxOutputPlugin.java
@Override public Module module(final Key<PluginSink> key, final String id) { return new OutputPluginModule(id) { @Provides/* w ww . j a v a 2 s.c om*/ Supplier<AggregateMetricSender> sender() { final Collection<OnSendErrorHandler> handlers = ImmutableList.of(metricError -> { log.error(metricError.toString()); }); return () -> { final SignalFxEndpoint endpoint = new SignalFxEndpoint(); final HttpDataPointProtobufReceiverFactory dataPoints = new HttpDataPointProtobufReceiverFactory( endpoint).setVersion(2); BasicHttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager(); SocketConfig socketConfigWithSoTimeout = SocketConfig.copy(connectionManager.getSocketConfig()) .setSoTimeout(soTimeout).build(); connectionManager.setSocketConfig(socketConfigWithSoTimeout); dataPoints.setHttpClientConnectionManager(connectionManager); final EventReceiverFactory events = new HttpEventProtobufReceiverFactory(endpoint); final AuthToken auth = new StaticAuthToken(authToken); return new AggregateMetricSender(sourceName, dataPoints, events, auth, handlers); }; } @Override protected void configure() { final Key<SignalFxPluginSink> sinkKey = Key.get(SignalFxPluginSink.class, Names.named("signalfxSink")); bind(sinkKey).to(SignalFxPluginSink.class).in(Scopes.SINGLETON); install(wrapPluginSink(sinkKey, key)); expose(key); } }; }
From source file:com.gooddata.GoodData.java
private HttpClientBuilder createHttpClientBuilder(final GoodDataSettings settings) { final PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); connectionManager.setDefaultMaxPerRoute(settings.getMaxConnections()); connectionManager.setMaxTotal(settings.getMaxConnections()); final SocketConfig.Builder socketConfig = SocketConfig.copy(SocketConfig.DEFAULT); socketConfig.setSoTimeout(settings.getSocketTimeout()); connectionManager.setDefaultSocketConfig(socketConfig.build()); final RequestConfig.Builder requestConfig = RequestConfig.copy(RequestConfig.DEFAULT); requestConfig.setConnectTimeout(settings.getConnectionTimeout()); requestConfig.setConnectionRequestTimeout(settings.getConnectionRequestTimeout()); requestConfig.setSocketTimeout(settings.getSocketTimeout()); return HttpClientBuilder.create() .setUserAgent(StringUtils.isNotBlank(settings.getUserAgent()) ? String.format("%s %s", settings.getUserAgent(), getUserAgent()) : getUserAgent())//from w w w . j av a2 s . c o m .setConnectionManager(connectionManager).setDefaultRequestConfig(requestConfig.build()); }