Example usage for org.apache.http.impl.conn BasicHttpClientConnectionManager getSocketConfig

List of usage examples for org.apache.http.impl.conn BasicHttpClientConnectionManager getSocketConfig

Introduction

In this page you can find the example usage for org.apache.http.impl.conn BasicHttpClientConnectionManager getSocketConfig.

Prototype

public synchronized SocketConfig getSocketConfig() 

Source Link

Usage

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/*from   w ww .  j a v  a2  s . c  o m*/
        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);
        }
    };
}