From 12a53ceef9d25e2ff2f0a2cf0378a98d8c085d87 Mon Sep 17 00:00:00 2001 From: Dominik Riemer Date: Mon, 16 Dec 2024 09:54:38 +0100 Subject: [PATCH] fix: Reuse Influx connection pool --- .../dataexplorer/influx/client/InfluxClientUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/streampipes-data-explorer-influx/src/main/java/org/apache/streampipes/dataexplorer/influx/client/InfluxClientUtils.java b/streampipes-data-explorer-influx/src/main/java/org/apache/streampipes/dataexplorer/influx/client/InfluxClientUtils.java index 9b0d14d1ce..40f67fd780 100644 --- a/streampipes-data-explorer-influx/src/main/java/org/apache/streampipes/dataexplorer/influx/client/InfluxClientUtils.java +++ b/streampipes-data-explorer-influx/src/main/java/org/apache/streampipes/dataexplorer/influx/client/InfluxClientUtils.java @@ -20,12 +20,15 @@ import org.apache.streampipes.dataexplorer.influx.auth.AuthInterceptor; +import okhttp3.ConnectionPool; import okhttp3.OkHttpClient; import java.util.concurrent.TimeUnit; public class InfluxClientUtils { + private static final ConnectionPool connectionPool = new ConnectionPool(10, 10, TimeUnit.MINUTES); + public static OkHttpClient.Builder getHttpClientBuilder(String authToken) { var builder = getHttpClientBuilder() .addInterceptor(new AuthInterceptor(authToken)); @@ -35,6 +38,7 @@ public static OkHttpClient.Builder getHttpClientBuilder(String authToken) { public static OkHttpClient.Builder getHttpClientBuilder() { return new OkHttpClient().newBuilder() + .connectionPool(connectionPool) .connectTimeout(120, TimeUnit.SECONDS) .readTimeout(120, TimeUnit.SECONDS) .writeTimeout(120, TimeUnit.SECONDS);