Skip to content

Commit

Permalink
make global http client worker threads configurable (apache#3514)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhxiaogg authored and gianm committed Sep 29, 2016
1 parent d0ea841 commit 78b06a7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<dependency>
<groupId>com.metamx</groupId>
<artifactId>http-client</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>com.metamx</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public HttpClient get()
final HttpClientConfig.Builder builder = HttpClientConfig
.builder()
.withNumConnections(config.getNumConnections())
.withReadTimeout(config.getReadTimeout());
.withReadTimeout(config.getReadTimeout())
.withWorkerCount(config.getNumMaxThreads());

if (getSslContextBinding() != null) {
builder.withSslContext(getSslContextBinding().getProvider().get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.druid.guice.annotations.Global;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;

import java.lang.annotation.Annotation;

Expand Down Expand Up @@ -116,6 +117,9 @@ public HttpClient get()

httpClient.setIdleTimeout(config.getReadTimeout().getMillis());
httpClient.setMaxConnectionsPerDestination(config.getNumConnections());
final QueuedThreadPool pool = new QueuedThreadPool(config.getNumMaxThreads());
pool.setName(JettyHttpClientModule.class.getSimpleName() + "-threadPool-" + pool.hashCode());
httpClient.setExecutor(pool);

final Lifecycle lifecycle = getLifecycleProvider().get();

Expand Down

0 comments on commit 78b06a7

Please sign in to comment.