mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
shared http client
This commit is contained in:
parent
0e341a2a9a
commit
b380b9e5d7
|
@ -9,19 +9,22 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
|
||||||
public class SeaweedUtil {
|
public class SeaweedUtil {
|
||||||
|
|
||||||
static PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
static PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
|
||||||
|
static CloseableHttpClient httpClient;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Increase max total connection to 200
|
// Increase max total connection to 200
|
||||||
cm.setMaxTotal(200);
|
cm.setMaxTotal(200);
|
||||||
// Increase default max connection per route to 20
|
// Increase default max connection per route to 20
|
||||||
cm.setDefaultMaxPerRoute(20);
|
cm.setDefaultMaxPerRoute(20);
|
||||||
}
|
|
||||||
|
|
||||||
public static CloseableHttpClient getClosableHttpClient() {
|
httpClient = HttpClientBuilder.create()
|
||||||
return HttpClientBuilder.create()
|
|
||||||
.setConnectionManager(cm)
|
.setConnectionManager(cm)
|
||||||
.setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE)
|
.setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE)
|
||||||
.setKeepAliveStrategy(DefaultConnectionKeepAliveStrategy.INSTANCE)
|
.setKeepAliveStrategy(DefaultConnectionKeepAliveStrategy.INSTANCE)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CloseableHttpClient getClosableHttpClient() {
|
||||||
|
return httpClient;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue