aboutsummaryrefslogtreecommitdiffstats
path: root/rest-services
diff options
context:
space:
mode:
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2020-11-19 16:30:01 +0100
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>2021-01-11 15:25:18 +0000
commit2b846c06a5c163cf6252e1d2d7517739f5a43ce9 (patch)
tree8b5a77bd5f61581bd4f28d9f74a69c7a840ebcbf /rest-services
parente43e052f71357eddf98c0117d5ae566a64b11ccf (diff)
Fix CbsClientFactory to allow retry on Mono from createCbsClient7.0.0-ONAPguilin
Issue-ID: DCAEGEN2-2516 Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com> Change-Id: Id6e58625f3c6bd4aa7dcb1bb167839e0ed31ef93 (cherry picked from commit c610bf0763522c2de5b68c9a7670a9bd269ad262)
Diffstat (limited to 'rest-services')
-rw-r--r--rest-services/cbs-client/pom.xml2
-rw-r--r--rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java17
-rw-r--r--rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactoryTest.java64
-rw-r--r--rest-services/dmaap-client/pom.xml2
-rw-r--r--rest-services/http-client/pom.xml2
-rw-r--r--rest-services/model/pom.xml2
-rw-r--r--rest-services/pom.xml2
7 files changed, 79 insertions, 12 deletions
diff --git a/rest-services/cbs-client/pom.xml b/rest-services/cbs-client/pom.xml
index a638cd27..66600f6c 100644
--- a/rest-services/cbs-client/pom.xml
+++ b/rest-services/cbs-client/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.4.3-SNAPSHOT</version>
+ <version>1.4.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java
index 00aad603..7e625182 100644
--- a/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java
+++ b/rest-services/cbs-client/src/main/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactory.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* DCAEGEN2-SERVICES-SDK
* ================================================================================
- * Copyright (C) 2019 Nokia. All rights reserved.
+ * Copyright (C) 2019-2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,12 +54,9 @@ public class CbsClientFactory {
* @since 1.1.2
*/
public static @NotNull Mono<CbsClient> createCbsClient(CbsClientConfiguration configuration) {
- return Mono.defer(() -> {
- final RxHttpClient httpClient = buildHttpClient(configuration.trustStoreKeys());
- final CbsLookup cbsLookup = new CbsLookup();
- return cbsLookup.lookup(configuration)
- .map(addr -> new CbsClientImpl(httpClient, configuration.appName(), addr, configuration.protocol()));
- });
+ return Mono.fromCallable(() -> buildHttpClient(configuration.trustStoreKeys()))
+ .cache()
+ .flatMap(httpClient -> createCbsClientMono(httpClient, configuration));
}
private static RxHttpClient buildHttpClient(TrustStoreKeys trustStoreKeys) {
@@ -67,4 +64,10 @@ public class CbsClientFactory {
? RxHttpClientFactory.create(trustStoreKeys)
: RxHttpClientFactory.create();
}
+
+ private static Mono<CbsClient> createCbsClientMono(RxHttpClient httpClient,
+ CbsClientConfiguration configuration) {
+ return new CbsLookup().lookup(configuration)
+ .map(addr -> new CbsClientImpl(httpClient, configuration.appName(), addr, configuration.protocol()));
+ }
}
diff --git a/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactoryTest.java b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactoryTest.java
new file mode 100644
index 00000000..43577f4a
--- /dev/null
+++ b/rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactoryTest.java
@@ -0,0 +1,64 @@
+/*
+ * ============LICENSE_START====================================
+ * DCAEGEN2-SERVICES-SDK
+ * =========================================================
+ * Copyright (C) 2020 Nokia. All rights reserved.
+ * =========================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=====================================
+ */
+
+package org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api;
+
+
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.net.URISyntaxException;
+import java.nio.file.Paths;
+import org.junit.jupiter.api.Test;
+import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.ImmutableCbsClientConfiguration;
+import org.onap.dcaegen2.services.sdk.security.ssl.ImmutableTrustStoreKeys;
+import org.onap.dcaegen2.services.sdk.security.ssl.Passwords;
+import org.onap.dcaegen2.services.sdk.security.ssl.SecurityKeysStore;
+import reactor.core.publisher.Mono;
+
+class CbsClientFactoryTest {
+
+ @Test
+ void shouldAllowMultipleSubscriptions() throws URISyntaxException {
+ //given
+ ImmutableCbsClientConfiguration sampleConfiguration = ImmutableCbsClientConfiguration.builder()
+ .protocol("https")
+ .appName("dcae-component")
+ .trustStoreKeys(ImmutableTrustStoreKeys.builder()
+ .trustStore(SecurityKeysStore.fromPath(
+ Paths.get(CbsClientFactoryTest.class.getResource("/test-certs/trust.jks").toURI())))
+ .trustStorePassword(Passwords.fromResource("/test-certs/trust.pass"))
+ .build())
+ .hostname("config-binding-service")
+ .port(10443)
+ .build();
+
+ //when
+ Mono<CbsClient> cbsClient = CbsClientFactory.createCbsClient(sampleConfiguration);
+
+ //then
+ assertThatCode(() -> {
+ CbsClient client1 = cbsClient.block();
+ CbsClient client2 = cbsClient.block();
+ assertThat(client1).isNotNull();
+ assertThat(client2).isNotNull();
+ }).doesNotThrowAnyException();
+ }
+}
diff --git a/rest-services/dmaap-client/pom.xml b/rest-services/dmaap-client/pom.xml
index f57d3a10..9eb118b1 100644
--- a/rest-services/dmaap-client/pom.xml
+++ b/rest-services/dmaap-client/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.4.3-SNAPSHOT</version>
+ <version>1.4.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/http-client/pom.xml b/rest-services/http-client/pom.xml
index 22e35dc2..64ac6037 100644
--- a/rest-services/http-client/pom.xml
+++ b/rest-services/http-client/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.4.3-SNAPSHOT</version>
+ <version>1.4.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/model/pom.xml b/rest-services/model/pom.xml
index ceb553a6..bd91a8ce 100644
--- a/rest-services/model/pom.xml
+++ b/rest-services/model/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>
<artifactId>dcaegen2-services-sdk-rest-services</artifactId>
- <version>1.4.3-SNAPSHOT</version>
+ <version>1.4.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId>
diff --git a/rest-services/pom.xml b/rest-services/pom.xml
index fa0f3431..de360272 100644
--- a/rest-services/pom.xml
+++ b/rest-services/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>org.onap.dcaegen2.services</groupId>
<artifactId>sdk</artifactId>
- <version>1.4.3-SNAPSHOT</version>
+ <version>1.4.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.dcaegen2.services.sdk</groupId>