summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2023-12-28 16:17:47 +0100
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-04-05 17:01:53 +0200
commit598c2469a004c50a1b29882e02e2fab7a8407d8b (patch)
tree3533fe0fa5b25e5e66b7d4294e734d40da316520 /src/main
parent19f034b2554895285f12979b0f36c1629f9af984 (diff)
Make rest-client request timeout in model-loader configurable
- this reduces the test execution time, when test cases run into timouts Issue-ID: AAI-3703 Change-Id: Ie683f55e5ce8d59b10d2788aea6933854dcb7e99 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java14
-rw-r--r--src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java19
-rw-r--r--src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java2
3 files changed, 22 insertions, 13 deletions
diff --git a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
index a49288d..7da90d9 100644
--- a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
+++ b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
@@ -27,12 +27,12 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Optional;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jetty.util.security.Password;
import org.onap.sdc.api.consumer.IConfiguration;
-
/**
* Properties for the Model Loader
*
@@ -97,6 +97,8 @@ public class ModelLoaderConfig implements IConfiguration {
protected static final String PROP_DEBUG_INGEST_SIMULATOR = PREFIX_DEBUG + "INGEST_SIMULATOR";
protected static final String FILESEP =
(System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
+ protected static final String PROP_AAI_CLIENT_CONNECT_TIMEOUT_MS = PREFIX_AAI + "RESTCLIENT_CONNECT_TIMEOUT";
+ protected static final String PROP_AAI_CLIENT_READ_TIMEOUT_MS = PREFIX_AAI + "RESTCLIENT_READ_TIMEOUT";
private static String configHome;
private Properties modelLoaderProperties = null;
@@ -401,4 +403,14 @@ public class ModelLoaderConfig implements IConfiguration {
}
}
+ public int getClientConnectTimeoutMs() {
+ String connectTimeout = Optional.ofNullable(get(PROP_AAI_CLIENT_CONNECT_TIMEOUT_MS)).orElse("120000");
+ return Integer.parseInt(connectTimeout);
+ }
+
+ public int getClientReadTimeoutMs() {
+ String connectTimeout = Optional.ofNullable(get(PROP_AAI_CLIENT_READ_TIMEOUT_MS)).orElse("120000");
+ return Integer.parseInt(connectTimeout);
+ }
+
}
diff --git a/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java b/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java
index 29c0c70..40aeacc 100644
--- a/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java
+++ b/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java
@@ -156,24 +156,19 @@ public class AaiRestClient {
private RestClient setupClient() {
RestClient restClient = new RestClient();
+ restClient.validateServerHostname(false)
+ .validateServerCertChain(false)
+ .connectTimeoutMs(config.getClientConnectTimeoutMs())
+ .readTimeoutMs(config.getClientReadTimeoutMs());
//Use certs only if SSL is enabled
if (config.useHttpsWithAAI())
{// @formatter:off
- restClient.validateServerHostname(false)
- .validateServerCertChain(false)
- .clientCertFile(config.getAaiKeyStorePath())
- .clientCertPassword(config.getAaiKeyStorePassword())
- .connectTimeoutMs(120000)
- .readTimeoutMs(120000);
+ restClient
+ .clientCertFile(config.getAaiKeyStorePath())
+ .clientCertPassword(config.getAaiKeyStorePassword());
// @formatter:on
}
- else {
- restClient.validateServerHostname(false)
- .validateServerCertChain(false)
- .connectTimeoutMs(120000)
- .readTimeoutMs(120000);
- }
if (useBasicAuth()) {
restClient.authenticationMode(RestAuthenticationMode.SSL_BASIC);
diff --git a/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java b/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java
index 88967b2..c76996f 100644
--- a/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java
+++ b/src/main/java/org/onap/aai/modelloader/restclient/HttpsBabelServiceClient.java
@@ -130,6 +130,8 @@ public class HttpsBabelServiceClient implements BabelServiceClient {
}
client = Client.create(new DefaultClientConfig());
+ client.setConnectTimeout(config.getClientConnectTimeoutMs());
+ client.setReadTimeout(config.getClientReadTimeoutMs());
logger.debug(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Jersey client created");
}