[TEST] Use a pooling connection manager for REST tests
This commit is contained in:
parent
29422c645b
commit
7776b6b4f0
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue