diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-01-26 09:20:12 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-01-26 09:24:36 +0100 |
commit | dec5fd736f9d3b02f4885407ae8def2360846014 (patch) | |
tree | a5237dc3fbf991b41b7313e96d53d1ccc41f0361 /metrics-proxy | |
parent | b6e0d375b0f4c3096cd9299e81154451e8387006 (diff) |
Revert apache 5.1 -> 5.2
Diffstat (limited to 'metrics-proxy')
2 files changed, 11 insertions, 6 deletions
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(); |