From 7776b6b4f0fc105d9261c1140c683c70e7fc0979 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 28 Nov 2014 22:04:01 +0100 Subject: [PATCH] [TEST] Use a pooling connection manager for REST tests --- .../java/org/elasticsearch/test/rest/client/RestClient.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/test/rest/client/RestClient.java b/src/test/java/org/elasticsearch/test/rest/client/RestClient.java index 63fbd589879..793ed3530af 100644 --- a/src/test/java/org/elasticsearch/test/rest/client/RestClient.java +++ b/src/test/java/org/elasticsearch/test/rest/client/RestClient.java @@ -21,8 +21,10 @@ package org.elasticsearch.test.rest.client; import com.carrotsearch.randomizedtesting.RandomizedTest; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.elasticsearch.client.support.Headers; import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.ESLogger; @@ -38,6 +40,7 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.util.List; import java.util.Map; +import java.util.concurrent.TimeUnit; /** * REST client used to test the elasticsearch REST layer @@ -46,6 +49,7 @@ import java.util.Map; public class RestClient implements Closeable { private static final ESLogger logger = Loggers.getLogger(RestClient.class); + private static final HttpClientConnectionManager connectionPool = new PoolingHttpClientConnectionManager(15, TimeUnit.SECONDS); private final RestSpec restSpec; private final CloseableHttpClient httpClient; @@ -218,7 +222,7 @@ public class RestClient implements Closeable { } protected CloseableHttpClient createHttpClient() { - return HttpClients.createDefault(); + return HttpClients.createMinimal(connectionPool); } public InetSocketAddress[] httpAddresses() {