From dec5fd736f9d3b02f4885407ae8def2360846014 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Thu, 26 Jan 2023 09:20:12 +0100 Subject: Revert apache 5.1 -> 5.2 --- .../http/application/ApplicationMetricsRetriever.java | 2 +- .../ai/vespa/metricsproxy/service/HttpMetricFetcher.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'metrics-proxy/src/main/java') diff --git a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetriever.java b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetriever.java index 3baed3e1b04..d4f04cdb3fc 100644 --- a/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetriever.java +++ b/metrics-proxy/src/main/java/ai/vespa/metricsproxy/http/application/ApplicationMetricsRetriever.java @@ -28,6 +28,7 @@ import java.util.concurrent.TimeoutException; import java.util.concurrent.CancellationException; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; import static ai.vespa.metricsproxy.http.ValuesFetcher.defaultMetricsConsumerId; @@ -187,7 +188,6 @@ public class ApplicationMetricsRetriever extends AbstractComponent implements Ru .toList(); } - @SuppressWarnings("deprecation") static CloseableHttpAsyncClient createHttpClient() { return VespaAsyncHttpClientBuilder.create() .setIOReactorConfig(IOReactorConfig.custom() 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 75853ec9eda..790b3298a81 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,6 +7,8 @@ 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; @@ -44,7 +46,6 @@ public abstract class HttpMetricFetcher { log.log(Level.FINE, () -> "Fetching metrics from " + u + " with timeout " + CONNECTION_TIMEOUT); } - @SuppressWarnings("deprecation") CloseableHttpResponse getResponse() throws IOException { log.log(Level.FINE, () -> "Connecting to url " + url + " for service '" + service + "'"); return httpClient.execute(new HttpGet(url)); @@ -80,13 +81,17 @@ public abstract class HttpMetricFetcher { } private static CloseableHttpClient createHttpClient() { - return VespaHttpClientBuilder.custom() - .connectTimeout(Timeout.ofMilliseconds(CONNECTION_TIMEOUT)) - .socketTimeout(Timeout.ofMilliseconds(CONNECTION_TIMEOUT)) - .apacheBuilder() + return VespaHttpClientBuilder.create(registry -> { + var mgr = new PoolingHttpClientConnectionManager(registry); + mgr.setDefaultSocketConfig(SocketConfig.custom() + .setSoTimeout(Timeout.ofMilliseconds(SOCKET_TIMEOUT)) + .build()); + return mgr; + }) .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(); -- cgit v1.2.3