use of com.ning.http.client.extra.ThrottleRequestFilter in project Singularity by HubSpot.
the class SingularityExecutorModule method providesHttpClient.
@Provides
@Singleton
@Named(LOCAL_DOWNLOAD_HTTP_CLIENT)
public AsyncHttpClient providesHttpClient(SingularityExecutorConfiguration configuration) {
AsyncHttpClientConfig.Builder configBldr = new AsyncHttpClientConfig.Builder();
configBldr.setRequestTimeoutInMs((int) configuration.getLocalDownloadServiceTimeoutMillis());
configBldr.setIdleConnectionTimeoutInMs((int) configuration.getLocalDownloadServiceTimeoutMillis());
configBldr.addRequestFilter(new ThrottleRequestFilter(configuration.getLocalDownloadServiceMaxConnections()));
return new AsyncHttpClient(configBldr.build());
}
use of com.ning.http.client.extra.ThrottleRequestFilter in project Singularity by HubSpot.
the class SingularityExecutorModule method provideDownloadFetcher.
@Provides
@Singleton
public LocalDownloadServiceFetcher provideDownloadFetcher(SingularityS3Configuration s3Configuration, SingularityExecutorConfiguration executorConfiguration, ObjectMapper objectMapper) {
if (s3Configuration.getLocalDownloadSocket().isPresent()) {
HttpClient httpClient = new HttpClient(new HttpClientTransportOverUnixSockets(s3Configuration.getLocalDownloadSocket().get()), null);
return new UnixLocalDownloadServiceFetcher(httpClient, objectMapper, executorConfiguration, s3Configuration);
} else {
AsyncHttpClientConfig.Builder configBldr = new AsyncHttpClientConfig.Builder();
configBldr.setRequestTimeout((int) executorConfiguration.getLocalDownloadServiceTimeoutMillis());
configBldr.setPooledConnectionIdleTimeout((int) executorConfiguration.getLocalDownloadServiceTimeoutMillis());
configBldr.addRequestFilter(new ThrottleRequestFilter(executorConfiguration.getLocalDownloadServiceMaxConnections()));
return new HttpLocalDownloadServiceFetcher(new AsyncHttpClient(configBldr.build()), objectMapper, executorConfiguration, s3Configuration);
}
}
Aggregations