Search in sources :

Example 1 with ThrottleRequestFilter

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());
}
Also used : ThrottleRequestFilter(com.ning.http.client.extra.ThrottleRequestFilter) Builder(com.spotify.docker.client.DefaultDockerClient.Builder) AsyncHttpClientConfig(com.ning.http.client.AsyncHttpClientConfig) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) Named(com.google.inject.name.Named) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 2 with ThrottleRequestFilter

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);
    }
}
Also used : ThrottleRequestFilter(com.ning.http.client.extra.ThrottleRequestFilter) HttpLocalDownloadServiceFetcher(com.hubspot.singularity.executor.task.HttpLocalDownloadServiceFetcher) UnixLocalDownloadServiceFetcher(com.hubspot.singularity.executor.task.UnixLocalDownloadServiceFetcher) HttpClient(org.eclipse.jetty.client.HttpClient) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) Builder(com.spotify.docker.client.DefaultDockerClient.Builder) AsyncHttpClientConfig(com.ning.http.client.AsyncHttpClientConfig) HttpClientTransportOverUnixSockets(org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets) AsyncHttpClient(com.ning.http.client.AsyncHttpClient) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)2 Singleton (com.google.inject.Singleton)2 AsyncHttpClient (com.ning.http.client.AsyncHttpClient)2 AsyncHttpClientConfig (com.ning.http.client.AsyncHttpClientConfig)2 ThrottleRequestFilter (com.ning.http.client.extra.ThrottleRequestFilter)2 Builder (com.spotify.docker.client.DefaultDockerClient.Builder)2 Named (com.google.inject.name.Named)1 HttpLocalDownloadServiceFetcher (com.hubspot.singularity.executor.task.HttpLocalDownloadServiceFetcher)1 UnixLocalDownloadServiceFetcher (com.hubspot.singularity.executor.task.UnixLocalDownloadServiceFetcher)1 HttpClient (org.eclipse.jetty.client.HttpClient)1 HttpClientTransportOverUnixSockets (org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets)1