[TEST] Use a pooling connection manager for REST tests

This commit is contained in:
Lee Hinman 2014-11-28 22:04:01 +01:00
parent 29422c645b
commit 7776b6b4f0
1 changed files with 5 additions and 1 deletions

View File

@ -21,8 +21,10 @@ package org.elasticsearch.test.rest.client;
import com.carrotsearch.randomizedtesting.RandomizedTest; import com.carrotsearch.randomizedtesting.RandomizedTest;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; 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.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.elasticsearch.client.support.Headers; import org.elasticsearch.client.support.Headers;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
@ -38,6 +40,7 @@ import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
/** /**
* REST client used to test the elasticsearch REST layer * REST client used to test the elasticsearch REST layer
@ -46,6 +49,7 @@ import java.util.Map;
public class RestClient implements Closeable { public class RestClient implements Closeable {
private static final ESLogger logger = Loggers.getLogger(RestClient.class); 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 RestSpec restSpec;
private final CloseableHttpClient httpClient; private final CloseableHttpClient httpClient;
@ -218,7 +222,7 @@ public class RestClient implements Closeable {
} }
protected CloseableHttpClient createHttpClient() { protected CloseableHttpClient createHttpClient() {
return HttpClients.createDefault(); return HttpClients.createMinimal(connectionPool);
} }
public InetSocketAddress[] httpAddresses() { public InetSocketAddress[] httpAddresses() {