From 2b846c06a5c163cf6252e1d2d7517739f5a43ce9 Mon Sep 17 00:00:00 2001 From: Remigiusz Janeczek Date: Thu, 19 Nov 2020 16:30:01 +0100 Subject: Fix CbsClientFactory to allow retry on Mono from createCbsClient Issue-ID: DCAEGEN2-2516 Signed-off-by: Remigiusz Janeczek Change-Id: Id6e58625f3c6bd4aa7dcb1bb167839e0ed31ef93 (cherry picked from commit c610bf0763522c2de5b68c9a7670a9bd269ad262) --- pom.xml | 2 +- rest-services/cbs-client/pom.xml | 2 +- .../services/cbs/client/api/CbsClientFactory.java | 17 +++--- .../cbs/client/api/CbsClientFactoryTest.java | 64 ++++++++++++++++++++++ rest-services/dmaap-client/pom.xml | 2 +- rest-services/http-client/pom.xml | 2 +- rest-services/model/pom.xml | 2 +- rest-services/pom.xml | 2 +- security/crypt-password/pom.xml | 2 +- security/pom.xml | 2 +- security/ssl/pom.xml | 2 +- services/external-schema-manager/pom.xml | 2 +- services/hv-ves-client/pom.xml | 2 +- services/hv-ves-client/producer/api/pom.xml | 2 +- services/hv-ves-client/producer/ct/pom.xml | 2 +- services/hv-ves-client/producer/impl/pom.xml | 2 +- services/hv-ves-client/producer/pom.xml | 2 +- services/hv-ves-client/protobuf/pom.xml | 2 +- services/pom.xml | 2 +- standardization/api-custom-header/pom.xml | 2 +- standardization/moher-api/healthstate/pom.xml | 2 +- standardization/moher-api/metrics/pom.xml | 2 +- standardization/moher-api/pom.xml | 2 +- standardization/moher-api/server-adapters/pom.xml | 2 +- .../server-adapters/reactor-netty/pom.xml | 2 +- .../server-adapters/spring-webflux/pom.xml | 2 +- standardization/pom.xml | 2 +- version.properties | 2 +- 28 files changed, 100 insertions(+), 33 deletions(-) create mode 100644 rest-services/cbs-client/src/test/java/org/onap/dcaegen2/services/sdk/rest/services/cbs/client/api/CbsClientFactoryTest.java diff --git a/pom.xml b/pom.xml index 1b5bd037..61b5664b 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.onap.dcaegen2.services sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT dcaegen2-services-sdk Common SDK repo for all DCAE Services 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 @@ org.onap.dcaegen2.services.sdk dcaegen2-services-sdk-rest-services - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT org.onap.dcaegen2.services.sdk.rest.services 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 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 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 = 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 @@ org.onap.dcaegen2.services.sdk dcaegen2-services-sdk-rest-services - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT org.onap.dcaegen2.services.sdk.rest.services 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 @@ org.onap.dcaegen2.services.sdk dcaegen2-services-sdk-rest-services - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT org.onap.dcaegen2.services.sdk.rest.services 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 @@ org.onap.dcaegen2.services.sdk dcaegen2-services-sdk-rest-services - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT org.onap.dcaegen2.services.sdk.rest.services 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 @@ org.onap.dcaegen2.services sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT org.onap.dcaegen2.services.sdk diff --git a/security/crypt-password/pom.xml b/security/crypt-password/pom.xml index da037983..02344326 100644 --- a/security/crypt-password/pom.xml +++ b/security/crypt-password/pom.xml @@ -6,7 +6,7 @@ org.onap.dcaegen2.services.sdk.security dcaegen2-services-sdk-security - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT 4.0.0 diff --git a/security/pom.xml b/security/pom.xml index 173c7c8f..70a451b9 100644 --- a/security/pom.xml +++ b/security/pom.xml @@ -7,7 +7,7 @@ org.onap.dcaegen2.services sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT org.onap.dcaegen2.services.sdk.security diff --git a/security/ssl/pom.xml b/security/ssl/pom.xml index febb8977..f62e0aa1 100644 --- a/security/ssl/pom.xml +++ b/security/ssl/pom.xml @@ -6,7 +6,7 @@ org.onap.dcaegen2.services.sdk.security dcaegen2-services-sdk-security - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT ssl diff --git a/services/external-schema-manager/pom.xml b/services/external-schema-manager/pom.xml index 3925e34d..f25af85d 100644 --- a/services/external-schema-manager/pom.xml +++ b/services/external-schema-manager/pom.xml @@ -7,7 +7,7 @@ org.onap.dcaegen2.services.sdk dcaegen2-services-sdk-services - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT dcaegen2-services-sdk-services-external-schema-manager diff --git a/services/hv-ves-client/pom.xml b/services/hv-ves-client/pom.xml index 31bb04f7..bfcdc490 100644 --- a/services/hv-ves-client/pom.xml +++ b/services/hv-ves-client/pom.xml @@ -26,7 +26,7 @@ org.onap.dcaegen2.services.sdk dcaegen2-services-sdk-services - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT dcaegen2-services-sdk-services-hvvesclient diff --git a/services/hv-ves-client/producer/api/pom.xml b/services/hv-ves-client/producer/api/pom.xml index d65c52b8..f45a7c64 100644 --- a/services/hv-ves-client/producer/api/pom.xml +++ b/services/hv-ves-client/producer/api/pom.xml @@ -26,7 +26,7 @@ org.onap.dcaegen2.services.sdk hvvesclient-producer - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT hvvesclient-producer-api diff --git a/services/hv-ves-client/producer/ct/pom.xml b/services/hv-ves-client/producer/ct/pom.xml index 38ecb4e6..89a963cd 100644 --- a/services/hv-ves-client/producer/ct/pom.xml +++ b/services/hv-ves-client/producer/ct/pom.xml @@ -26,7 +26,7 @@ org.onap.dcaegen2.services.sdk hvvesclient-producer - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT hvvesclient-producer-ct diff --git a/services/hv-ves-client/producer/impl/pom.xml b/services/hv-ves-client/producer/impl/pom.xml index a4bed9d0..547b9f69 100644 --- a/services/hv-ves-client/producer/impl/pom.xml +++ b/services/hv-ves-client/producer/impl/pom.xml @@ -26,7 +26,7 @@ org.onap.dcaegen2.services.sdk hvvesclient-producer - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT hvvesclient-producer-impl diff --git a/services/hv-ves-client/producer/pom.xml b/services/hv-ves-client/producer/pom.xml index 7d831606..8e310252 100644 --- a/services/hv-ves-client/producer/pom.xml +++ b/services/hv-ves-client/producer/pom.xml @@ -26,7 +26,7 @@ org.onap.dcaegen2.services.sdk dcaegen2-services-sdk-services-hvvesclient - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT hvvesclient-producer diff --git a/services/hv-ves-client/protobuf/pom.xml b/services/hv-ves-client/protobuf/pom.xml index fade894e..5fe47d07 100644 --- a/services/hv-ves-client/protobuf/pom.xml +++ b/services/hv-ves-client/protobuf/pom.xml @@ -26,7 +26,7 @@ dcaegen2-services-sdk-services-hvvesclient org.onap.dcaegen2.services.sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT High Volume VES Collector Client :: Protobuf diff --git a/services/pom.xml b/services/pom.xml index dea1ed86..4490b568 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -26,7 +26,7 @@ org.onap.dcaegen2.services sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT org.onap.dcaegen2.services.sdk diff --git a/standardization/api-custom-header/pom.xml b/standardization/api-custom-header/pom.xml index e50f61ee..6c8c255f 100644 --- a/standardization/api-custom-header/pom.xml +++ b/standardization/api-custom-header/pom.xml @@ -7,7 +7,7 @@ org.onap.dcaegen2.services.sdk dcaegen2-services-sdk-standardization - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT .. diff --git a/standardization/moher-api/healthstate/pom.xml b/standardization/moher-api/healthstate/pom.xml index 77f0f8f6..39c8a0eb 100644 --- a/standardization/moher-api/healthstate/pom.xml +++ b/standardization/moher-api/healthstate/pom.xml @@ -25,7 +25,7 @@ dcaegen2-sdk-moher-api org.onap.dcaegen2.services.sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT Monitoring and Healthcheck :: Health state diff --git a/standardization/moher-api/metrics/pom.xml b/standardization/moher-api/metrics/pom.xml index 542f6f44..4dae6aca 100644 --- a/standardization/moher-api/metrics/pom.xml +++ b/standardization/moher-api/metrics/pom.xml @@ -26,7 +26,7 @@ dcaegen2-sdk-moher-api org.onap.dcaegen2.services.sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT Monitoring and Healthcheck :: Metrics diff --git a/standardization/moher-api/pom.xml b/standardization/moher-api/pom.xml index c8db9572..d4f9cbf2 100644 --- a/standardization/moher-api/pom.xml +++ b/standardization/moher-api/pom.xml @@ -26,7 +26,7 @@ dcaegen2-services-sdk-standardization org.onap.dcaegen2.services.sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT Monitoring and Healthcheck diff --git a/standardization/moher-api/server-adapters/pom.xml b/standardization/moher-api/server-adapters/pom.xml index e53bc5e7..e0beee4d 100644 --- a/standardization/moher-api/server-adapters/pom.xml +++ b/standardization/moher-api/server-adapters/pom.xml @@ -25,7 +25,7 @@ dcaegen2-sdk-moher-api org.onap.dcaegen2.services.sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT Monitoring and Healthcheck :: Server Adapters diff --git a/standardization/moher-api/server-adapters/reactor-netty/pom.xml b/standardization/moher-api/server-adapters/reactor-netty/pom.xml index 45b24132..2051e1d8 100644 --- a/standardization/moher-api/server-adapters/reactor-netty/pom.xml +++ b/standardization/moher-api/server-adapters/reactor-netty/pom.xml @@ -25,7 +25,7 @@ dcaegen2-sdk-moher-server-adapters org.onap.dcaegen2.services.sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT Monitoring and Healthcheck :: Server Adapters :: Reactor Netty diff --git a/standardization/moher-api/server-adapters/spring-webflux/pom.xml b/standardization/moher-api/server-adapters/spring-webflux/pom.xml index c58c50dc..43f5552a 100644 --- a/standardization/moher-api/server-adapters/spring-webflux/pom.xml +++ b/standardization/moher-api/server-adapters/spring-webflux/pom.xml @@ -25,7 +25,7 @@ dcaegen2-sdk-moher-server-adapters org.onap.dcaegen2.services.sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT Monitoring and Healthcheck :: Server Adapters :: Spring Webflux diff --git a/standardization/pom.xml b/standardization/pom.xml index 3b16fcfd..8572218b 100644 --- a/standardization/pom.xml +++ b/standardization/pom.xml @@ -8,7 +8,7 @@ org.onap.dcaegen2.services sdk - 1.4.3-SNAPSHOT + 1.4.4-SNAPSHOT .. diff --git a/version.properties b/version.properties index 44b6acf6..9e50923f 100644 --- a/version.properties +++ b/version.properties @@ -1,6 +1,6 @@ major=1 minor=4 -patch=3 +patch=4 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg