From b380b9e5d76c3c1b7170cf4abe6cdb5db71a48c0 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 20 Jul 2020 18:27:11 -0700 Subject: [PATCH] shared http client --- .../src/main/java/seaweedfs/client/SeaweedUtil.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java index e2835b718..c465d935f 100644 --- a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java +++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java @@ -9,19 +9,22 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; public class SeaweedUtil { static PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); + static CloseableHttpClient httpClient; static { // Increase max total connection to 200 cm.setMaxTotal(200); // Increase default max connection per route to 20 cm.setDefaultMaxPerRoute(20); - } - public static CloseableHttpClient getClosableHttpClient() { - return HttpClientBuilder.create() + httpClient = HttpClientBuilder.create() .setConnectionManager(cm) .setConnectionReuseStrategy(DefaultConnectionReuseStrategy.INSTANCE) .setKeepAliveStrategy(DefaultConnectionKeepAliveStrategy.INSTANCE) .build(); } + + public static CloseableHttpClient getClosableHttpClient() { + return httpClient; + } }