Skip to content

Commit

Permalink
Expose ability to override maxConnectionIdleTime via configuration pr…
Browse files Browse the repository at this point in the history
…operties
  • Loading branch information
nathan-poquette authored and VanRoy committed Jul 18, 2018
1 parent 174a55b commit 7bba925
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import io.searchbox.client.JestClient;
Expand Down Expand Up @@ -110,6 +111,7 @@ private JestClient createJestClient(String uri) {
HttpClientConfig.Builder builder = new HttpClientConfig.Builder(uri)
.maxTotalConnection(properties.getMaxTotalConnection())
.defaultMaxTotalConnectionPerRoute(properties.getDefaultMaxTotalConnectionPerRoute())
.maxConnectionIdleTime(properties.getMaxConnectionIdleTime(), TimeUnit.MILLISECONDS)
.readTimeout(properties.getReadTimeout())
.multiThreaded(properties.getMultiThreaded());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ElasticsearchJestProperties {
private int maxTotalConnection = 50;
private int defaultMaxTotalConnectionPerRoute = 50;
private int readTimeout = 5000;
private long maxConnectionIdleTime = 0L; // Idle connection reaping disabled by default
private Boolean multiThreaded = true;

/**
Expand Down Expand Up @@ -77,6 +78,14 @@ public void setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
}

public long getMaxConnectionIdleTime() {
return maxConnectionIdleTime;
}

public void setMaxConnectionIdleTime(long maxConnectionIdleTime) {
this.maxConnectionIdleTime = maxConnectionIdleTime;
}

public Boolean getMultiThreaded() {
return multiThreaded;
}
Expand Down

0 comments on commit 7bba925

Please sign in to comment.