summaryrefslogtreecommitdiffstats
path: root/common/src/main
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2020-10-27 08:03:47 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2020-10-27 11:35:23 +0000
commit0f7afcbce63e8935d5e798f7007e1da8cf8774b7 (patch)
tree56c53340955357032c1038b45b8401eac070fbe1 /common/src/main
parent2510a11d6404db223e8b185797ab67c6da3d721d (diff)
Adding configuration to evict expire and Idle
connections and not to resuse connections Change-Id: I2eacfe1ef0fabf322d94c0a318836f1587b51ed8 Issue-ID: SO-3338 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java13
-rw-r--r--common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java6
2 files changed, 15 insertions, 4 deletions
diff --git a/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java b/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java
index 6c2c76e87c..b17b1fe0fe 100644
--- a/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java
+++ b/common/src/main/java/org/onap/so/configuration/rest/HttpClientConnectionConfiguration.java
@@ -38,15 +38,18 @@ public class HttpClientConnectionConfiguration {
@Value(value = "${rest.http.client.configuration.socketTimeOutInSec:180}")
private int socketTimeOutInSeconds;
- @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:600}")
+ @Value(value = "${rest.http.client.configuration.timeToLiveInSeconds:600}")
private int timeToLiveInSeconds;
- @Value(value = "${rest.http.client.configuration.maxConnections:10}")
+ @Value(value = "${rest.http.client.configuration.maxConnections:100}")
private int maxConnections;
- @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:2}")
+ @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:20}")
private int maxConnectionsPerRoute;
+ @Value(value = "${rest.http.client.configuration.evictIdleConnectionsTimeInSec:5}")
+ private int evictIdleConnectionsTimeInSec;
+
/**
* @return the socket connection time out in milliseconds
*/
@@ -82,4 +85,8 @@ public class HttpClientConnectionConfiguration {
return (int) TimeUnit.SECONDS.toMinutes(timeToLiveInSeconds);
}
+ public long getEvictIdleConnectionsTimeInSec() {
+ return evictIdleConnectionsTimeInSec;
+ }
+
}
diff --git a/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java b/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java
index 882ed95cfc..aef2ed165e 100644
--- a/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java
+++ b/common/src/main/java/org/onap/so/configuration/rest/HttpComponentsClientConfiguration.java
@@ -22,6 +22,7 @@ package org.onap.so.configuration.rest;
import java.util.concurrent.TimeUnit;
import org.apache.http.client.config.RequestConfig;
+import org.apache.http.impl.NoConnectionReuseStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
@@ -55,7 +56,10 @@ public class HttpComponentsClientConfiguration {
return HttpClientBuilder.create().setConnectionManager(poolingHttpClientConnectionManager())
.setMaxConnPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute())
.setMaxConnTotal(clientConnectionConfiguration.getMaxConnections())
- .setDefaultRequestConfig(requestConfig()).build();
+ .setDefaultRequestConfig(requestConfig()).setConnectionReuseStrategy(NoConnectionReuseStrategy.INSTANCE)
+ .evictExpiredConnections().evictIdleConnections(
+ clientConnectionConfiguration.getEvictIdleConnectionsTimeInSec(), TimeUnit.SECONDS)
+ .build();
}
@Bean