diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-01-05 10:34:07 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-01-25 10:48:48 +0100 |
commit | d8a3a7bf6d9685db965833064876d8ed02ed0699 (patch) | |
tree | 40a5491e1187a075d1a9c0b000bb9de2f215560e /metrics-proxy | |
parent | f8338e1ea64c58a7986f929a4c3c229b92a8cfde (diff) |
VespaHttpClientBuilder follow builder pattern and add connect and socket timeout to builder.
Diffstat (limited to 'metrics-proxy')
-rw-r--r-- | metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/HttpMetricFetcher.java | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/HttpMetricFetcher.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/HttpMetricFetcher.java index f766bebe4a2..d0cabef12b4 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/HttpMetricFetcher.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/service/HttpMetricFetcher.java @@ -7,8 +7,6 @@ import org.apache.hc.client5.http.classic.methods.HttpGet; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; -import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; -import org.apache.hc.core5.http.io.SocketConfig; import org.apache.hc.core5.util.Timeout; import java.io.IOException; @@ -81,19 +79,14 @@ public abstract class HttpMetricFetcher { } } - @SuppressWarnings("deprecation") private static CloseableHttpClient createHttpClient() { - return VespaHttpClientBuilder.create(registry -> { - var mgr = new PoolingHttpClientConnectionManager(registry); - mgr.setDefaultSocketConfig(SocketConfig.custom() - .setSoTimeout(Timeout.ofMilliseconds(SOCKET_TIMEOUT)) - .build()); - return mgr; - }) + return VespaHttpClientBuilder.custom() + .setConnectTimeout(Timeout.ofMilliseconds(CONNECTION_TIMEOUT)) + .setSocketTimeout(Timeout.ofMilliseconds(CONNECTION_TIMEOUT)) + .build() .setUserAgent("metrics-proxy-http-client") .setDefaultRequestConfig(RequestConfig.custom() .setConnectionRequestTimeout(Timeout.ofMilliseconds(SOCKET_TIMEOUT)) - .setConnectTimeout(Timeout.ofMilliseconds(CONNECTION_TIMEOUT)) .setResponseTimeout(Timeout.ofMilliseconds(SOCKET_TIMEOUT)) .build()) .build(); |