set connection timeout as well as read timeout 82/117082/3
authorBenjamin, Max (mb388a) <mb388a@att.com>
Sat, 23 Jan 2021 21:07:59 +0000 (16:07 -0500)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Mon, 1 Feb 2021 22:43:52 +0000 (17:43 -0500)
set connection timeout as well as read timeout
correct dependency version in openstack pom
limit timeout test to a single retry
add connection timeout property for A&AI client

Issue-ID: SO-3491
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I576c143822ba45fc79648fd0a1edb6ccd3aff8b2

adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java
asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java
common/src/main/java/org/onap/so/client/RestClient.java
common/src/main/java/org/onap/so/client/RestProperties.java
common/src/test/java/org/onap/so/client/RestClientTest.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java
pom.xml
so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-bpmn-flows/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/bpmn/flows/extclients/aai/AaiPropertiesImpl.java

index cd32cc2..79d5824 100644 (file)
@@ -34,6 +34,7 @@ public class AaiClientPropertiesImpl implements AAIProperties {
     private String auth;
     private String key;
     private Long readTimeout;
+    private Long connectionTimeout;
     private boolean enableCaching;
     private Long cacheMaxAge;
     private static final String SYSTEM_NAME = "MSO";
@@ -43,7 +44,8 @@ public class AaiClientPropertiesImpl implements AAIProperties {
         aaiEndpoint = context.getEnvironment().getProperty("aai.endpoint");
         this.auth = context.getEnvironment().getProperty("aai.auth");
         this.key = context.getEnvironment().getProperty("mso.msoKey");
-        this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000));
+        this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, 60000L);
+        this.connectionTimeout = context.getEnvironment().getProperty("aai.connectionTimeout", Long.class, 60000L);
         this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false);
         this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L);
     }
@@ -78,6 +80,11 @@ public class AaiClientPropertiesImpl implements AAIProperties {
         return this.readTimeout;
     }
 
+    @Override
+    public Long getConnectionTimeout() {
+        return this.connectionTimeout;
+    }
+
     @Override
     public boolean isCachingEnabled() {
         return this.enableCaching;
index ace0ff1..46bdfe0 100644 (file)
@@ -34,6 +34,7 @@ public class AaiClientPropertiesImpl implements AAIProperties {
     private String auth;
     private String key;
     private Long readTimeout;
+    private Long connectionTimeout;
     private boolean enableCaching;
     private Long cacheMaxAge;
     private static final String SYSTEM_NAME = "MSO";
@@ -43,7 +44,8 @@ public class AaiClientPropertiesImpl implements AAIProperties {
         aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint");
         this.auth = context.getEnvironment().getProperty("aai.auth");
         this.key = context.getEnvironment().getProperty("mso.msoKey");
-        this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000));
+        this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, 60000L);
+        this.connectionTimeout = context.getEnvironment().getProperty("aai.connectionTimeout", Long.class, 60000L);
         this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false);
         this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L);
     }
@@ -80,6 +82,11 @@ public class AaiClientPropertiesImpl implements AAIProperties {
         return this.readTimeout;
     }
 
+    @Override
+    public Long getConnectionTimeout() {
+        return this.connectionTimeout;
+    }
+
     @Override
     public boolean isCachingEnabled() {
         return this.enableCaching;
index 98a14fc..b6227aa 100644 (file)
@@ -35,6 +35,7 @@ public class AAIPropertiesImpl implements AAIProperties {
     public static final String AAI_AUTH = "aai.auth";
     public static final String AAI_ENDPOINT = "aai.endpoint";
     public static final String AAI_READ_TIMEOUT = "aai.readTimeout";
+    public static final String AAI_CONNECTION_TIMEOUT = "aai.connectionTimeout";
     public static final String AAI_ENABLE_CACHING = "aai.caching.enable";
     public static final String AAI_CACHE_MAX_AGE = "aai.caching.maxAge";
 
@@ -70,6 +71,11 @@ public class AAIPropertiesImpl implements AAIProperties {
         return Long.valueOf(reader.getVariable(AAI_READ_TIMEOUT, "60000"));
     }
 
+    @Override
+    public Long getConnectionTimeout() {
+        return Long.valueOf(reader.getVariable(AAI_CONNECTION_TIMEOUT, "60000"));
+    }
+
     @Override
     public boolean isCachingEnabled() {
         return Boolean.parseBoolean(reader.getVariable(AAI_ENABLE_CACHING, "false"));
index be0a0f3..f201c7c 100644 (file)
@@ -193,7 +193,8 @@ public abstract class RestClient {
         if (props.isCachingEnabled()) {
             enableCaching(builder);
         }
-        return builder.readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS);
+        return builder.connectTimeout(props.getConnectionTimeout(), TimeUnit.MILLISECONDS)
+                .readTimeout(props.getReadTimeout(), TimeUnit.MILLISECONDS);
     }
 
     protected ClientBuilder enableCaching(ClientBuilder builder) {
index a7a0ef6..79e006b 100644 (file)
@@ -50,6 +50,15 @@ public interface RestProperties {
         return Long.valueOf(60000);
     }
 
+    /**
+     * Time in milliseconds
+     * 
+     * @return
+     */
+    public default Long getConnectionTimeout() {
+        return Long.valueOf(60000);
+    }
+
     public default boolean isCachingEnabled() {
         return false;
     }
index d40576b..57abf87 100644 (file)
@@ -101,6 +101,12 @@ public class RestClientTest {
 
         RestProperties props = new RestProperties() {
 
+
+            @Override
+            public Integer getRetries() {
+                return Integer.valueOf(0);
+            }
+
             @Override
             public URL getEndpoint() throws MalformedURLException {
                 return new URL(String.format("http://localhost:%s", wireMockRule.port()));
index 1492baf..e330d21 100644 (file)
@@ -34,6 +34,7 @@ public class AaiClientPropertiesImpl implements AAIProperties {
     private String auth;
     private String key;
     private Long readTimeout;
+    private Long connectionTimeout;
     private boolean enableCaching;
     private Long cacheMaxAge;
 
@@ -43,7 +44,8 @@ public class AaiClientPropertiesImpl implements AAIProperties {
         aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint");
         this.auth = context.getEnvironment().getProperty("aai.auth");
         this.key = context.getEnvironment().getProperty("mso.msoKey");
-        this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000));
+        this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, 60000L);
+        this.connectionTimeout = context.getEnvironment().getProperty("aai.connectionTimeout", Long.class, 60000L);
         this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false);
         this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L);
     }
@@ -78,6 +80,11 @@ public class AaiClientPropertiesImpl implements AAIProperties {
         return this.readTimeout;
     }
 
+    @Override
+    public Long getConnectionTimeout() {
+        return this.connectionTimeout;
+    }
+
     @Override
     public boolean isCachingEnabled() {
         return this.enableCaching;
diff --git a/pom.xml b/pom.xml
index e994986..797390a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
           </exclusion>
         </exclusions>
       </dependency>
+      <dependency>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-rt-rs-service-description-openapi-v3</artifactId>
+        <version>${cxf.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>org.jboss.spec.javax.rmi</groupId>
+            <artifactId>jboss-rmi-api_1.0_spec</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
       <dependency>
         <groupId>org.onap.aaf.authz</groupId>
         <artifactId>aaf-cadi-client</artifactId>
index 0aa14c7..25a43a8 100644 (file)
@@ -35,6 +35,7 @@ public class AaiPropertiesImpl implements AAIProperties {
     private final String encryptionKey;
     private final String aaiVersion;
     private final Long readTimeout;
+    private final Long connectionTimeout;
     private final boolean enableCaching;
     private final Long cacheMaxAge;
 
@@ -44,7 +45,8 @@ public class AaiPropertiesImpl implements AAIProperties {
         this.encryptedBasicAuth = context.getEnvironment().getProperty("aai.auth");
         this.encryptionKey = context.getEnvironment().getProperty("mso.key");
         this.aaiVersion = context.getEnvironment().getProperty("aai.version");
-        this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000));
+        this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, 60000L);
+        this.connectionTimeout = context.getEnvironment().getProperty("aai.connectionTimeout", Long.class, 60000L);
         this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false);
         this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L);
     }
@@ -85,6 +87,11 @@ public class AaiPropertiesImpl implements AAIProperties {
         return this.readTimeout;
     }
 
+    @Override
+    public Long getConnectionTimeout() {
+        return this.connectionTimeout;
+    }
+
     @Override
     public boolean isCachingEnabled() {
         return this.enableCaching;