diff options
53 files changed, 394 insertions, 164 deletions
diff --git a/checkstyle/pom.xml b/checkstyle/pom.xml index 95794b1655..f794dc2026 100644 --- a/checkstyle/pom.xml +++ b/checkstyle/pom.xml @@ -26,7 +26,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.cps</groupId> <artifactId>checkstyle</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <profiles> <profile> diff --git a/cps-application/pom.xml b/cps-application/pom.xml index 6466bcfe47..e7ba2c5916 100644 --- a/cps-application/pom.xml +++ b/cps-application/pom.xml @@ -28,7 +28,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> @@ -70,18 +70,6 @@ <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> </dependency> <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-http</artifactId> - </dependency> - <dependency> - <groupId>jakarta.servlet</groupId> - <artifactId>jakarta.servlet-api</artifactId> - </dependency> - <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency> diff --git a/cps-application/src/main/resources/application.yml b/cps-application/src/main/resources/application.yml index e56e0e13cb..207341ccde 100644 --- a/cps-application/src/main/resources/application.yml +++ b/cps-application/src/main/resources/application.yml @@ -64,7 +64,7 @@ spring: liquibase: change-log: classpath:changelog/changelog-master.yaml - labels: ${LIQUIBASE_LABELS} + label-filter: ${LIQUIBASE_LABELS} servlet: multipart: @@ -200,7 +200,6 @@ ncmp: parallelism-level: 10 model-loader: - subscription: true maximum-attempt-count: 20 # Custom Hazelcast Config. diff --git a/cps-bom/pom.xml b/cps-bom/pom.xml index ecd442cf43..da315d315e 100644 --- a/cps-bom/pom.xml +++ b/cps-bom/pom.xml @@ -25,7 +25,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.cps</groupId> <artifactId>cps-bom</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <packaging>pom</packaging> <description>This artifact contains dependencyManagement declarations of all published CPS components.</description> diff --git a/cps-dependencies/pom.xml b/cps-dependencies/pom.xml index 2f1a4d2d8f..c3f038dd6d 100644 --- a/cps-dependencies/pom.xml +++ b/cps-dependencies/pom.xml @@ -27,7 +27,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.cps</groupId> <artifactId>cps-dependencies</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <packaging>pom</packaging> <name>${project.groupId}:${project.artifactId}</name> @@ -85,7 +85,7 @@ <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> - <version>3.1.2</version> + <version>3.2.2</version> <type>pom</type> <scope>import</scope> </dependency> @@ -97,11 +97,6 @@ <scope>import</scope> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <version>6.0.11</version> - </dependency> - <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.1.2</version> @@ -172,8 +167,8 @@ </dependency> <dependency> <groupId>io.hypersistence</groupId> - <artifactId>hypersistence-utils-hibernate-60</artifactId> - <version>3.5.0</version> + <artifactId>hypersistence-utils-hibernate-63</artifactId> + <version>3.7.3</version> </dependency> <dependency> <groupId>io.micrometer</groupId> @@ -226,26 +221,11 @@ <version>${groovy.version}</version> </dependency> <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - <version>${jetty-version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-http</artifactId> - <version>${jetty-version}</version> - </dependency> - <dependency> <groupId>org.jetbrains</groupId> <artifactId>annotations</artifactId> <version>22.0.0</version> </dependency> <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-api</artifactId> - <version>5.10.0</version> - </dependency> - <dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> <version>4.21.0</version> diff --git a/cps-events/pom.xml b/cps-events/pom.xml index 662d150a5e..7db3338154 100644 --- a/cps-events/pom.xml +++ b/cps-events/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-events/pom.xml b/cps-ncmp-events/pom.xml index 6e638438cc..c14504d6ac 100644 --- a/cps-ncmp-events/pom.xml +++ b/cps-ncmp-events/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-app/pom.xml b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-app/pom.xml index 25d4939eb6..ab6d8f8a0b 100644 --- a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-app/pom.xml +++ b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-app/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-ncmp-rest-stub</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> </parent> <artifactId>cps-ncmp-rest-stub-app</artifactId> diff --git a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/pom.xml b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/pom.xml index 1a8e89b68e..ebe4d7fe2a 100644 --- a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/pom.xml +++ b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/pom.xml @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-ncmp-rest-stub</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> </parent> <artifactId>cps-ncmp-rest-stub-service</artifactId> @@ -46,14 +46,6 @@ <groupId>org.onap.cps</groupId> <artifactId>cps-ncmp-rest</artifactId> </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - </dependency> - <dependency> - <groupId>jakarta.servlet</groupId> - <artifactId>jakarta.servlet-api</artifactId> - </dependency> <!-- T E S T - D E P E N D E N C I E S --> <dependency> <groupId>org.spockframework</groupId> diff --git a/cps-ncmp-rest-stub/pom.xml b/cps-ncmp-rest-stub/pom.xml index a35a886628..74dd34aa90 100644 --- a/cps-ncmp-rest-stub/pom.xml +++ b/cps-ncmp-rest-stub/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-rest/lombok.config b/cps-ncmp-rest/lombok.config index 0736fc58c6..e4122df33c 100644 --- a/cps-ncmp-rest/lombok.config +++ b/cps-ncmp-rest/lombok.config @@ -18,3 +18,4 @@ config.stopBubbling = true lombok.addLombokGeneratedAnnotation = true +lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier diff --git a/cps-ncmp-rest/pom.xml b/cps-ncmp-rest/pom.xml index f363c01f66..ae3650e1a0 100644 --- a/cps-ncmp-rest/pom.xml +++ b/cps-ncmp-rest/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java index 6ec24448d7..73bd8d72b0 100755 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java @@ -39,6 +39,7 @@ import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.onap.cps.ncmp.api.NetworkCmProxyDataService; +import org.onap.cps.ncmp.api.impl.config.embeddedcache.TrustLevelCacheConfig; import org.onap.cps.ncmp.api.impl.exception.InvalidDatastoreException; import org.onap.cps.ncmp.api.impl.inventory.CompositeState; import org.onap.cps.ncmp.api.impl.operations.DatastoreType; @@ -62,6 +63,7 @@ import org.onap.cps.ncmp.rest.model.RestOutputCmHandlePublicProperties; import org.onap.cps.ncmp.rest.util.DeprecationHelper; import org.onap.cps.spi.model.ModuleDefinition; import org.onap.cps.utils.JsonObjectMapper; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.util.StringUtils; @@ -83,6 +85,7 @@ public class NetworkCmProxyController implements NetworkCmProxyApi { private final NcmpCachedResourceRequestHandler ncmpCachedResourceRequestHandler; private final NcmpPassthroughResourceRequestHandler ncmpPassthroughResourceRequestHandler; private final DataOperationRequestMapper dataOperationRequestMapper; + @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_CM_HANDLE_BEAN_NAME) private final Map<String, TrustLevel> trustLevelPerCmHandle; /** diff --git a/cps-ncmp-service/lombok.config b/cps-ncmp-service/lombok.config index 1fba85bb7b..6776ef0f51 100644 --- a/cps-ncmp-service/lombok.config +++ b/cps-ncmp-service/lombok.config @@ -18,3 +18,4 @@ config.stopBubbling = true lombok.addLombokGeneratedAnnotation = true +lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier diff --git a/cps-ncmp-service/pom.xml b/cps-ncmp-service/pom.xml index 9beb6b7b0f..d6ea71b952 100644 --- a/cps-ncmp-service/pom.xml +++ b/cps-ncmp-service/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java index 08afde49a1..ab83486bd7 100755 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java @@ -51,6 +51,7 @@ import org.apache.commons.lang3.StringUtils; import org.onap.cps.api.CpsDataService; import org.onap.cps.ncmp.api.NetworkCmProxyCmHandleQueryService; import org.onap.cps.ncmp.api.NetworkCmProxyDataService; +import org.onap.cps.ncmp.api.impl.config.embeddedcache.TrustLevelCacheConfig; import org.onap.cps.ncmp.api.impl.events.lcm.LcmEventsCmHandleStateHandler; import org.onap.cps.ncmp.api.impl.inventory.CmHandleQueries; import org.onap.cps.ncmp.api.impl.inventory.CmHandleState; @@ -84,6 +85,7 @@ import org.onap.cps.spi.exceptions.DataValidationException; import org.onap.cps.spi.model.ModuleDefinition; import org.onap.cps.spi.model.ModuleReference; import org.onap.cps.utils.JsonObjectMapper; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -102,6 +104,7 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private final LcmEventsCmHandleStateHandler lcmEventsCmHandleStateHandler; private final CpsDataService cpsDataService; private final IMap<String, Object> moduleSyncStartedOnCmHandles; + @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_DMI_PLUGIN_BEAN_NAME) private final Map<String, TrustLevel> trustLevelPerDmiPlugin; private final TrustLevelManager trustLevelManager; private final AlternateIdChecker alternateIdChecker; diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java index 171db52998..f12cc9c822 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/TrustLevelCacheConfig.java @@ -30,6 +30,10 @@ import org.springframework.context.annotation.Configuration; @Configuration public class TrustLevelCacheConfig extends HazelcastCacheConfig { + public static final String TRUST_LEVEL_PER_DMI_PLUGIN_BEAN_NAME = "trustLevelPerDmiPlugin"; + + public static final String TRUST_LEVEL_PER_CM_HANDLE_BEAN_NAME = "trustLevelPerCmHandle"; + private static final MapConfig trustLevelPerCmHandleCacheConfig = createMapConfig("trustLevelPerCmHandleCacheConfig"); @@ -41,7 +45,7 @@ public class TrustLevelCacheConfig extends HazelcastCacheConfig { * * @return configured map of cm handle name as keys to trust-level for values. */ - @Bean + @Bean(TRUST_LEVEL_PER_CM_HANDLE_BEAN_NAME) public Map<String, TrustLevel> trustLevelPerCmHandle() { return createHazelcastInstance("hazelcastInstanceTrustLevelPerCmHandleMap", trustLevelPerCmHandleCacheConfig).getMap("trustLevelPerCmHandle"); @@ -52,7 +56,7 @@ public class TrustLevelCacheConfig extends HazelcastCacheConfig { * * @return configured map of dmi-plugin name as keys to trust-level for values. */ - @Bean + @Bean(TRUST_LEVEL_PER_DMI_PLUGIN_BEAN_NAME) public Map<String, TrustLevel> trustLevelPerDmiPlugin() { return createHazelcastInstance("hazelcastInstanceTrustLevelPerDmiPluginMap", trustLevelPerDmiPluginCacheConfig).getMap("trustLevelPerDmiPlugin"); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDelta.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDelta.java new file mode 100644 index 0000000000..8a4beb9560 --- /dev/null +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDelta.java @@ -0,0 +1,75 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2024 Nordix Foundation + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.ncmp.api.impl.events.cmsubscription; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import lombok.RequiredArgsConstructor; +import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionPredicate; +import org.onap.cps.ncmp.api.impl.events.cmsubscription.service.CmNotificationSubscriptionPersistenceService; +import org.onap.cps.ncmp.api.impl.operations.DatastoreType; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class CmNotificationSubscriptionDelta { + + private final CmNotificationSubscriptionPersistenceService cmNotificationSubscriptionPersistenceService; + + /** + * Get the delta for a given predicates list. + * + * @param dmiCmNotificationSubscriptionPredicates list of DmiCmNotificationSubscriptionPredicates + * @return delta list of DmiCmNotificationSubscriptionPredicates + */ + public List<DmiCmNotificationSubscriptionPredicate> getDelta( + final List<DmiCmNotificationSubscriptionPredicate> dmiCmNotificationSubscriptionPredicates) { + final List<DmiCmNotificationSubscriptionPredicate> delta = new ArrayList<>(); + + for (final DmiCmNotificationSubscriptionPredicate cmNotificationSubscriptionPredicate: + dmiCmNotificationSubscriptionPredicates) { + + final Set<String> targetCmHandleIds = new HashSet<>(); + final Set<String> xpaths = new HashSet<>(); + final DatastoreType datastoreType = cmNotificationSubscriptionPredicate.getDatastoreType(); + + for (final String cmHandleId : cmNotificationSubscriptionPredicate.getTargetCmHandleIds()) { + for (final String xpath : cmNotificationSubscriptionPredicate.getXpaths()) { + if (!cmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(datastoreType, + cmHandleId, xpath)) { + xpaths.add(xpath); + targetCmHandleIds.add(cmHandleId); + + } + } + } + + final DmiCmNotificationSubscriptionPredicate predicateDelta = + new DmiCmNotificationSubscriptionPredicate(targetCmHandleIds, datastoreType, xpaths); + + delta.add(predicateDelta); + } + return delta; + } + +} diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java index bc798afeed..d3bde011b3 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java @@ -37,9 +37,6 @@ public class CmNotificationSubscriptionNcmpInEventConsumer { @Value("${notification.enabled:true}") private boolean notificationFeatureEnabled; - @Value("${ncmp.model-loader.subscription:false}") - private boolean subscriptionModelLoaderEnabled; - /** * Consume the specified event. * @@ -51,10 +48,8 @@ public class CmNotificationSubscriptionNcmpInEventConsumer { final CloudEvent cloudEvent = subscriptionEventConsumerRecord.value(); final CmNotificationSubscriptionNcmpInEvent cmNotificationSubscriptionNcmpInEvent = toTargetEvent(cloudEvent, CmNotificationSubscriptionNcmpInEvent.class); - if (subscriptionModelLoaderEnabled) { - log.info("Subscription with name {} to be mapped to hazelcast object...", - cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId()); - } + log.info("Subscription with name {} to be mapped to hazelcast object...", + cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId()); if ("subscriptionCreated".equals(cloudEvent.getType()) && cmNotificationSubscriptionNcmpInEvent != null) { log.info("Subscription for ClientID {} with name {} ...", cloudEvent.getSource(), cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId()); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionDmiInEventMapper.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionDmiInEventMapper.java index 2aa27164ef..489401f26e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionDmiInEventMapper.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionDmiInEventMapper.java @@ -71,9 +71,9 @@ public class CmNotificationSubscriptionDmiInEventMapper { final ScopeFilter scopeFilter = new ScopeFilter(); scopeFilter.setDatastore(ScopeFilter.Datastore.fromValue( dmiCmNotificationSubscriptionPredicate.getDatastoreType().getDatastoreName())); - scopeFilter.setXpathFilter(dmiCmNotificationSubscriptionPredicate.getXpaths()); + scopeFilter.setXpathFilter(dmiCmNotificationSubscriptionPredicate.getXpaths().stream().toList()); predicate.setScopeFilter(scopeFilter); - predicate.setTargetFilter(dmiCmNotificationSubscriptionPredicate.getTargetCmHandleIds()); + predicate.setTargetFilter(dmiCmNotificationSubscriptionPredicate.getTargetCmHandleIds().stream().toList()); predicates.add(predicate); }); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/model/DmiCmNotificationSubscriptionPredicate.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/model/DmiCmNotificationSubscriptionPredicate.java index 65365808d2..9c4c3f64e3 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/model/DmiCmNotificationSubscriptionPredicate.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/model/DmiCmNotificationSubscriptionPredicate.java @@ -20,17 +20,19 @@ package org.onap.cps.ncmp.api.impl.events.cmsubscription.model; -import java.util.List; +import java.util.Set; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import org.onap.cps.ncmp.api.impl.operations.DatastoreType; @Getter @Setter +@AllArgsConstructor public class DmiCmNotificationSubscriptionPredicate { - private List<String> targetCmHandleIds; + private Set<String> targetCmHandleIds; private DatastoreType datastoreType; - private List<String> xpaths; + private Set<String> xpaths; } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java index 2d7ad698c5..a43da294c1 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/CmHandleQueriesImpl.java @@ -34,12 +34,14 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; +import org.onap.cps.ncmp.api.impl.config.embeddedcache.TrustLevelCacheConfig; import org.onap.cps.ncmp.api.impl.inventory.enums.PropertyType; import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel; import org.onap.cps.spi.CpsDataPersistenceService; import org.onap.cps.spi.FetchDescendantsOption; import org.onap.cps.spi.model.DataNode; import org.onap.cps.spi.utils.CpsValidator; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @RequiredArgsConstructor @@ -49,7 +51,11 @@ public class CmHandleQueriesImpl implements CmHandleQueries { private static final String DESCENDANT_PATH = "//"; private static final String ANCESTOR_CM_HANDLES = "/ancestor::cm-handles"; private final CpsDataPersistenceService cpsDataPersistenceService; + + @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_DMI_PLUGIN_BEAN_NAME) private final Map<String, TrustLevel> trustLevelPerDmiPlugin; + + @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_CM_HANDLE_BEAN_NAME) private final Map<String, TrustLevel> trustLevelPerCmHandle; private final CpsValidator cpsValidator; diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevelManager.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevelManager.java index 22f18cd243..4c606a9c01 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevelManager.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/TrustLevelManager.java @@ -24,10 +24,12 @@ import java.util.Collection; import java.util.Map; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.onap.cps.ncmp.api.impl.config.embeddedcache.TrustLevelCacheConfig; import org.onap.cps.ncmp.api.impl.events.avc.ncmptoclient.AvcEventPublisher; import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence; import org.onap.cps.ncmp.api.impl.operations.RequiredDmiService; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @Slf4j @@ -35,7 +37,10 @@ import org.springframework.stereotype.Service; @RequiredArgsConstructor public class TrustLevelManager { + @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_CM_HANDLE_BEAN_NAME) private final Map<String, TrustLevel> trustLevelPerCmHandle; + + @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_DMI_PLUGIN_BEAN_NAME) private final Map<String, TrustLevel> trustLevelPerDmiPlugin; private final InventoryPersistence inventoryPersistence; diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginWatchDog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginWatchDog.java index 6ae7ff3d4e..78eaf3e6bf 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginWatchDog.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginWatchDog.java @@ -26,8 +26,10 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.onap.cps.ncmp.api.NetworkCmProxyDataService; import org.onap.cps.ncmp.api.impl.client.DmiRestClient; +import org.onap.cps.ncmp.api.impl.config.embeddedcache.TrustLevelCacheConfig; import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel; import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevelManager; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -40,6 +42,8 @@ public class DmiPluginWatchDog { private final NetworkCmProxyDataService networkCmProxyDataService; private final TrustLevelManager trustLevelManager; + + @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_DMI_PLUGIN_BEAN_NAME) private final Map<String, TrustLevel> trustLevelPerDmiPlugin; /** diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java index 7cee87a2a0..4c31719a29 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java @@ -32,7 +32,6 @@ import org.onap.cps.api.CpsModuleService; import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException; import org.onap.cps.ncmp.api.impl.operations.DatastoreType; import org.onap.cps.spi.exceptions.AlreadyDefinedException; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Slf4j @@ -45,24 +44,16 @@ public class CmDataSubscriptionModelLoader extends AbstractModelLoader { private static final String REGISTRY_DATANODE_NAME = "datastores"; public CmDataSubscriptionModelLoader(final CpsDataspaceService cpsDataspaceService, - final CpsModuleService cpsModuleService, - final CpsAnchorService cpsAnchorService, - final CpsDataService cpsDataService) { + final CpsModuleService cpsModuleService, final CpsAnchorService cpsAnchorService, + final CpsDataService cpsDataService) { super(cpsDataspaceService, cpsModuleService, cpsAnchorService, cpsDataService); } - @Value("${ncmp.model-loader.subscription:true}") - private boolean subscriptionModelLoaderEnabled; - @Override public void onboardOrUpgradeModel() { - if (subscriptionModelLoaderEnabled) { - waitUntilDataspaceIsAvailable(NCMP_DATASPACE_NAME); - onboardSubscriptionModels(); - log.info("Subscription Models onboarded successfully"); - } else { - log.info("Subscription Model Loader is disabled"); - } + waitUntilDataspaceIsAvailable(NCMP_DATASPACE_NAME); + onboardSubscriptionModels(); + log.info("Subscription Models onboarded successfully"); } private void onboardSubscriptionModels() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/CmNotificationSubscriptionCacheConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/CmNotificationSubscriptionCacheConfigSpec.groovy index a3f41c8ef4..86273bbd2e 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/CmNotificationSubscriptionCacheConfigSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/CmNotificationSubscriptionCacheConfigSpec.groovy @@ -49,7 +49,7 @@ class CmNotificationSubscriptionCacheConfigSpec extends Specification { given: 'a cm subscription properties' def subscriptionId = 'sub123' def dmiPluginName = 'dummydmi' - def cmSubscriptionPredicate = new DmiCmNotificationSubscriptionPredicate(targetCmHandleIds: ['cmhandle1', 'cmhandle2'], datastoreType: DatastoreType.PASSTHROUGH_RUNNING, xpaths: ['/a/b/c']) + def cmSubscriptionPredicate = new DmiCmNotificationSubscriptionPredicate(['cmhandle1', 'cmhandle2'].toSet(), DatastoreType.PASSTHROUGH_RUNNING, ['/a/b/c'].toSet()) def cmSubscriptionCacheObject = new DmiCmNotificationSubscriptionDetails(dmiCmNotificationSubscriptionPredicates: [cmSubscriptionPredicate], cmNotificationSubscriptionStatus: CmNotificationSubscriptionStatus.PENDING) when: 'the cache is populated' cmNotificationSubscriptionCache.put(subscriptionId, [(dmiPluginName): cmSubscriptionCacheObject]) diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDeltaSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDeltaSpec.groovy new file mode 100644 index 0000000000..e50652689a --- /dev/null +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionDeltaSpec.groovy @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (c) 2024 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.cps.ncmp.api.impl.events.cmsubscription + +import org.onap.cps.ncmp.api.impl.events.cmsubscription.model.DmiCmNotificationSubscriptionPredicate +import org.onap.cps.ncmp.api.impl.events.cmsubscription.service.CmNotificationSubscriptionPersistenceService +import org.onap.cps.ncmp.api.impl.operations.DatastoreType +import spock.lang.Specification + +class CmNotificationSubscriptionDeltaSpec extends Specification { + + def mockCmNotificationSubscriptionPersistenceService = Mock(CmNotificationSubscriptionPersistenceService) + def objectUnderTest = new CmNotificationSubscriptionDelta(mockCmNotificationSubscriptionPersistenceService) + + def 'Find Delta of given list of predicates'() { + given: 'A list of predicates' + def predicateList = [new DmiCmNotificationSubscriptionPredicate(['ch-1','ch-2'].toSet(), DatastoreType.PASSTHROUGH_OPERATIONAL, ['a/1/','b/2'].toSet())] + and: '3 positive responses and 1 negative.' + mockCmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(DatastoreType.PASSTHROUGH_OPERATIONAL, 'ch-1', 'a/1/') >>> true + mockCmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(DatastoreType.PASSTHROUGH_OPERATIONAL, 'ch-1', 'b/2') >>> true + mockCmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(DatastoreType.PASSTHROUGH_OPERATIONAL, 'ch-2', 'a/1/') >>> true + mockCmNotificationSubscriptionPersistenceService.isOngoingCmNotificationSubscription(DatastoreType.PASSTHROUGH_OPERATIONAL, 'ch-2', 'b/2') >>> false + when: 'getDelta is called' + def result = objectUnderTest.getDelta(predicateList) + then: 'verify correct delta is returned' + assert result.size() == 1 + assert result[0].targetCmHandleIds[0] == 'ch-2' + assert result[0].xpaths[0] == 'b/2' + + } + +} diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy index 6a3d4bef7b..1074229489 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy @@ -71,8 +71,6 @@ class CmNotificationSubscriptionNcmpInEventConsumerSpec extends MessagingBaseSpe def consumerRecord = new ConsumerRecord<String, CloudEvent>('topic-name', 0, 0, 'event-key', testCloudEventSent) and: 'notifications are enabled' objectUnderTest.notificationFeatureEnabled = true - and: 'subscription model loader is enabled' - objectUnderTest.subscriptionModelLoaderEnabled = true when: 'the valid event is consumed' objectUnderTest.consumeSubscriptionEvent(consumerRecord) then: 'an event is logged with level INFO' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionDmiInEventMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionDmiInEventMapperSpec.groovy index 44a7470459..763aedaa05 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionDmiInEventMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/mapper/CmNotificationSubscriptionDmiInEventMapperSpec.groovy @@ -43,8 +43,8 @@ class CmNotificationSubscriptionDmiInEventMapperSpec extends Specification { def 'Check for Cm Notification Subscription DMI In Event mapping'() { given: 'a collection of cm subscription predicates' - def dmiCmNotificationSubscriptionPredicates = [new DmiCmNotificationSubscriptionPredicate(targetCmHandleIds: ['ch-1'], datastoreType: PASSTHROUGH_RUNNING, xpaths: ['/ch-1']), - new DmiCmNotificationSubscriptionPredicate(targetCmHandleIds: ['ch-2'], datastoreType: PASSTHROUGH_OPERATIONAL, xpaths: ['/ch-2'])] + def dmiCmNotificationSubscriptionPredicates = [new DmiCmNotificationSubscriptionPredicate(['ch-1'].toSet(), PASSTHROUGH_RUNNING, ['/ch-1'].toSet()), + new DmiCmNotificationSubscriptionPredicate(['ch-2'].toSet(), PASSTHROUGH_OPERATIONAL, ['/ch-2'].toSet())] when: 'we try to map the values' def result = objectUnderTest.toCmNotificationSubscriptionDmiInEvent(dmiCmNotificationSubscriptionPredicates) then: 'it contains correct cm notification subscription cmhandle object' diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy index bde9961c2f..f3b405b117 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy @@ -20,24 +20,23 @@ package org.onap.cps.ncmp.init -import org.onap.cps.api.CpsAnchorService -import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException -import org.onap.cps.spi.exceptions.AlreadyDefinedException - -import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME - import ch.qos.logback.classic.Level import ch.qos.logback.classic.Logger import ch.qos.logback.core.read.ListAppender -import org.onap.cps.api.CpsDataspaceService +import org.onap.cps.api.CpsAnchorService import org.onap.cps.api.CpsDataService +import org.onap.cps.api.CpsDataspaceService import org.onap.cps.api.CpsModuleService +import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException +import org.onap.cps.spi.exceptions.AlreadyDefinedException import org.onap.cps.spi.model.Dataspace import org.slf4j.LoggerFactory import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.annotation.AnnotationConfigApplicationContext import spock.lang.Specification +import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME + class CmDataSubscriptionModelLoaderSpec extends Specification { def mockCpsDataspaceService = Mock(CpsDataspaceService) @@ -67,9 +66,7 @@ class CmDataSubscriptionModelLoaderSpec extends Specification { } def 'Onboard subscription model via application ready event.'() { - given:'model loader is enabled' - objectUnderTest.subscriptionModelLoaderEnabled = true - and: 'dataspace is ready for use' + given: 'dataspace is ready for use' mockCpsDataspaceService.getDataspace(NCMP_DATASPACE_NAME) >> new Dataspace('') when: 'the application is ready' objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent)) @@ -81,14 +78,14 @@ class CmDataSubscriptionModelLoaderSpec extends Specification { 1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '{"datastores":{}}', _) and: 'the data service is called once to create datastore for Passthrough-operational' 1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '/datastores', - '{"datastore":[{"name":"ncmp-datastore:passthrough-operational","cm-handles":{}}]}', _, _) + '{"datastore":[{"name":"ncmp-datastore:passthrough-operational","cm-handles":{}}]}', _, _) and: 'the data service is called once to create datastore for Passthrough-running' 1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '/datastores', - '{"datastore":[{"name":"ncmp-datastore:passthrough-running","cm-handles":{}}]}', _, _) + '{"datastore":[{"name":"ncmp-datastore:passthrough-running","cm-handles":{}}]}', _, _) } def 'Create node for datastore with already defined exception.'() { - given:'the data service throws an Already Defined exception' + given: 'the data service throws an Already Defined exception' mockCpsDataService.saveData(*_) >> { throw AlreadyDefinedException.forDataNodes([], 'some context') } when: 'attempt to create datastore' objectUnderTest.createDatastore('some datastore') @@ -110,16 +107,4 @@ class CmDataSubscriptionModelLoaderSpec extends Specification { assert thrown.details.contains('test message') } - def 'Subscription model loader disabled.' () { - given: 'model loader is disabled' - objectUnderTest.subscriptionModelLoaderEnabled = false - when: 'application is ready' - objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent)) - then: 'no interaction with admin service' - 0 * mockCpsDataspaceService.getDataspace(_) - then: 'a message is logged that the function is disabled' - def logs = loggingListAppender.list.toString() - assert logs.contains('Subscription Model Loader is disabled') - } - } diff --git a/cps-ncmp-service/src/test/resources/application.yml b/cps-ncmp-service/src/test/resources/application.yml index a4bb4e8124..a3283ff40f 100644 --- a/cps-ncmp-service/src/test/resources/application.yml +++ b/cps-ncmp-service/src/test/resources/application.yml @@ -50,8 +50,6 @@ ncmp: async-executor: parallelism-level: 3 - model-loader: - subscription: true # Custom Hazelcast Config. hazelcast: diff --git a/cps-parent/pom.xml b/cps-parent/pom.xml index 6e7554bf5e..b5a9ad1428 100644 --- a/cps-parent/pom.xml +++ b/cps-parent/pom.xml @@ -32,7 +32,7 @@ <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <packaging>pom</packaging> <properties> @@ -118,7 +118,7 @@ <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - <version>3.1.2</version> + <version>3.2.2</version> <executions> <execution> <goals> diff --git a/cps-path-parser/pom.xml b/cps-path-parser/pom.xml index e6e00dcf3c..da0265ced6 100644 --- a/cps-path-parser/pom.xml +++ b/cps-path-parser/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml index 022c3b8ebd..f8ec757493 100644 --- a/cps-rest/pom.xml +++ b/cps-rest/pom.xml @@ -28,7 +28,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/cps-ri/pom.xml b/cps-ri/pom.xml index 2fd369b2a4..2801d64a35 100644 --- a/cps-ri/pom.xml +++ b/cps-ri/pom.xml @@ -26,7 +26,7 @@ <parent>
<groupId>org.onap.cps</groupId>
<artifactId>cps-parent</artifactId>
- <version>3.4.4-SNAPSHOT</version>
+ <version>3.4.5-SNAPSHOT</version>
<relativePath>../cps-parent/pom.xml</relativePath>
</parent>
@@ -71,7 +71,7 @@ <!-- Add Hibernate support for Postgres datatype JSONB and Postgres arrays -->
<dependency>
<groupId>io.hypersistence</groupId>
- <artifactId>hypersistence-utils-hibernate-60</artifactId>
+ <artifactId>hypersistence-utils-hibernate-63</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java index 1e42702ab5..b449a789b0 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java @@ -69,6 +69,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource; import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException; import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyInfo; import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.retry.RetryContext; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Retryable; import org.springframework.retry.support.RetrySynchronizationManager; @@ -277,8 +278,8 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ dataIntegrityViolationException, newYangResourceEntities); convertedException.ifPresent( e -> { - int retryCount = RetrySynchronizationManager.getContext() == null ? 0 - : RetrySynchronizationManager.getContext().getRetryCount(); + final RetryContext context = RetrySynchronizationManager.getContext(); + int retryCount = context == null ? 0 : context.getRetryCount(); log.warn("Cannot persist duplicated yang resource. System will attempt this method " + "up to 5 times. Current retry count : {}", ++retryCount, e); }); diff --git a/cps-service/pom.xml b/cps-service/pom.xml index de716dfa58..93a4d3de04 100644 --- a/cps-service/pom.xml +++ b/cps-service/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> @@ -142,11 +142,6 @@ </dependency> <!-- T E S T D E P E N D E N C I E S --> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy</artifactId> <scope>test</scope> diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-app/pom.xml b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-app/pom.xml index eca8871c6b..053ac1bba5 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-app/pom.xml +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-app/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>dmi-plugin-demo-and-csit-stub</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> </parent> <artifactId>dmi-plugin-demo-and-csit-stub-app</artifactId> @@ -103,15 +103,5 @@ <artifactId>dmi-plugin-demo-and-csit-stub-service</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-server</artifactId> - <version>11.0.16</version> - </dependency> - <dependency> - <groupId>jakarta.servlet</groupId> - <artifactId>jakarta.servlet-api</artifactId> - <version>6.0.0</version> - </dependency> </dependencies> </project>
\ No newline at end of file diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml index d3142f821a..47ad877cc0 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml @@ -1,6 +1,6 @@ <!-- ============LICENSE_START======================================================= - Copyright (C) 2023 Nordix Foundation + Copyright (C) 2023-2024 Nordix Foundation ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>dmi-plugin-demo-and-csit-stub</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> </parent> <artifactId>dmi-plugin-demo-and-csit-stub-service</artifactId> @@ -38,6 +38,10 @@ <scope>compile</scope> </dependency> <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1.1</version> @@ -48,4 +52,4 @@ <artifactId>cps-ncmp-rest</artifactId> </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java index 772eb050c6..1819dcc47b 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java @@ -89,7 +89,7 @@ public class DmiRestStubController { * @return ResponseEntity response entity having module response as json string. */ @PostMapping("/v1/ch/{cmHandleId}/modules") - public ResponseEntity<String> getModuleReferences(@PathVariable final String cmHandleId, + public ResponseEntity<String> getModuleReferences(@PathVariable("cmHandleId") final String cmHandleId, @RequestBody final Object moduleReferencesRequest) { delay(moduleReferencesDelayMs); final String moduleResponseContent = getModuleResourceResponse(cmHandleId, @@ -108,7 +108,7 @@ public class DmiRestStubController { */ @PostMapping("/v1/ch/{cmHandleId}/moduleResources") public ResponseEntity<String> retrieveModuleResources( - @PathVariable final String cmHandleId, + @PathVariable("cmHandleId") final String cmHandleId, @RequestBody final Object moduleResourcesReadRequest) { delay(moduleResourcesDelayMs); final String moduleResourcesResponseContent = getModuleResourceResponse(cmHandleId, @@ -118,6 +118,30 @@ public class DmiRestStubController { } /** + * Get resource data from passthrough operational or running for a cm handle. + * + * @param cmHandleId The identifier for a network function, network element, subnetwork, + * or any other cm object by managed Network CM Proxy + * @param datastoreName datastore name + * @param resourceIdentifier resource identifier + * @param options options + * @param topic client given topic name + * @return (@ code ResponseEntity) response entity + */ + @PostMapping("/v1/ch/{cmHandleId}/data/ds/{datastoreName}") + public ResponseEntity<String> getResourceDataForCmHandle( + @PathVariable("cmHandleId") final String cmHandleId, + @PathVariable("datastoreName") final String datastoreName, + @RequestParam(value = "resourceIdentifier") final String resourceIdentifier, + @RequestParam(value = "options", required = false) final String options, + @RequestParam(value = "topic", required = false) final String topic) { + delay(dataForCmHandleDelayMs); + final String sampleJson = ResourceFileReaderUtil.getResourceFileContent(applicationContext.getResource( + ResourceLoader.CLASSPATH_URL_PREFIX + "data/operational/ietf-network-topology-sample-rfc8345.json")); + return ResponseEntity.ok(sampleJson); + } + + /** * This method is not implemented for ONAP DMI plugin. * * @param topic client given topic name @@ -126,12 +150,10 @@ public class DmiRestStubController { * @return (@ code ResponseEntity) response entity */ @PostMapping("/v1/data") - public ResponseEntity<Void> getResourceDataForCmHandleDataOperation(@RequestParam(value = "topic") - final String topic, - @RequestParam(value = "requestId") - final String requestId, - @RequestBody final DmiDataOperationRequest - dmiDataOperationRequest) { + public ResponseEntity<Void> getResourceDataForCmHandleDataOperation( + @RequestParam(value = "topic") final String topic, + @RequestParam(value = "requestId") final String requestId, + @RequestBody final DmiDataOperationRequest dmiDataOperationRequest) { delay(dataForCmHandleDelayMs); try { log.info("Request received from the NCMP to DMI Plugin: {}", diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml index de097a67b4..0847d40844 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (C) 2023 Nordix Foundation +# Copyright (C) 2023-2024 Nordix Foundation # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,9 @@ # ============LICENSE_END========================================================= server: port: 8092 + jetty: + threads: + max: 25 rest: api: @@ -36,6 +39,12 @@ spring: value-serializer: io.cloudevents.kafka.CloudEventSerializer client-id: cps-core +management: + endpoints: + web: + exposure: + include: health + app: ncmp: async-m2m: diff --git a/dmi-plugin-demo-and-csit-stub/pom.xml b/dmi-plugin-demo-and-csit-stub/pom.xml index 9fb40e3cdc..a16a95474f 100644 --- a/dmi-plugin-demo-and-csit-stub/pom.xml +++ b/dmi-plugin-demo-and-csit-stub/pom.xml @@ -22,7 +22,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 9ccb64b95b..de427af13f 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -56,9 +56,6 @@ services: DMI_PASSWORD: ${DMI_PASSWORD:-cpsr0cks!} KAFKA_BOOTSTRAP_SERVER: kafka:29092 notification.enabled: 'true' - notification.async.executor.time-out-value-in-ms: 2000 - NCMP_TIMERS_ADVISED-MODULES-SYNC_SLEEP-TIME-MS: ${ADVISED_MODULES_SYNC_SLEEP_TIME_MS:-30000} - NCMP_TIMERS_CM-HANDLE-DATA-SYNC_SLEEP-TIME-MS: ${CMHANDLE_DATA_SYNC_SLEEP_TIME_MS:-30000} JAVA_TOOL_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 restart: unless-stopped depends_on: diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 779a347332..49dc463c1a 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -16,6 +16,35 @@ CPS Release Notes .. * * * NEW DELHI * * * .. ========================= +Version: 3.4.5 +============== + +Release Data +------------ + ++--------------------------------------+--------------------------------------------------------+ +| **CPS Project** | | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Docker images** | onap/cps-and-ncmp:3.4.5 | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Release designation** | 3.4.5 New Delhi | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Release date** | Not yet released | +| | | ++--------------------------------------+--------------------------------------------------------+ + +Bug Fixes +--------- +3.4.5 + + +Features +-------- + + Version: 3.4.4 ============== @@ -32,16 +61,19 @@ Release Data | **Release designation** | 3.4.4 New Delhi | | | | +--------------------------------------+--------------------------------------------------------+ -| **Release date** | Not yet released | +| **Release date** | 2024 February 23 | | | | +--------------------------------------+--------------------------------------------------------+ Bug Fixes --------- 3.4.4 + - `CPS-2027 <https://jira.onap.org/browse/CPS-2027>`_ Upgrade Yang modules using module set tag functionalities fix Features -------- + - `CPS-2057 <https://jira.onap.org/browse/CPS-2057>`_ Leaf lists are sorted by default if Yang model does not specify order. + - `CPS-2087 <https://jira.onap.org/browse/CPS-2087>`_ Performance improvement of CPS Path Queries. Version: 3.4.3 diff --git a/integration-test/pom.xml b/integration-test/pom.xml index 3d0125a699..5a40ed2a35 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/integration-test/src/test/resources/application.yml b/integration-test/src/test/resources/application.yml index d1307cd6c0..f77cb02f7a 100644 --- a/integration-test/src/test/resources/application.yml +++ b/integration-test/src/test/resources/application.yml @@ -195,7 +195,6 @@ ncmp: parallelism-level: 1 model-loader: - subscription: true maximum-attempt-count: 20 servlet: diff --git a/jacoco-report/pom.xml b/jacoco-report/pom.xml index 60aa6b4654..c95b73a603 100644 --- a/jacoco-report/pom.xml +++ b/jacoco-report/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.cps</groupId> <artifactId>cps-parent</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <relativePath>../cps-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> @@ -32,7 +32,7 @@ <groupId>org.onap.cps</groupId>
<artifactId>cps-aggregator</artifactId>
- <version>3.4.4-SNAPSHOT</version>
+ <version>3.4.5-SNAPSHOT</version>
<packaging>pom</packaging>
<name>cps</name>
diff --git a/releases/3.4.4-container.yaml b/releases/3.4.4-container.yaml new file mode 100644 index 0000000000..01170f7044 --- /dev/null +++ b/releases/3.4.4-container.yaml @@ -0,0 +1,8 @@ +distribution_type: container +container_release_tag: 3.4.4 +project: cps +log_dir: cps-maven-docker-stage-master/935/ +ref: 8c37c03acae232829ee4e3aab636800741159de9 +containers: + - name: 'cps-and-ncmp' + version: '3.4.4-20240223T140746Z' diff --git a/releases/3.4.4.yaml b/releases/3.4.4.yaml new file mode 100644 index 0000000000..642770af67 --- /dev/null +++ b/releases/3.4.4.yaml @@ -0,0 +1,4 @@ +distribution_type: maven +log_dir: cps-maven-stage-master/943/ +project: cps +version: 3.4.4 diff --git a/spotbugs/pom.xml b/spotbugs/pom.xml index 4a15e4e3df..7b38301f90 100644 --- a/spotbugs/pom.xml +++ b/spotbugs/pom.xml @@ -25,7 +25,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.cps</groupId> <artifactId>spotbugs</artifactId> - <version>3.4.4-SNAPSHOT</version> + <version>3.4.5-SNAPSHOT</version> <properties> <nexusproxy>https://nexus.onap.org</nexusproxy> diff --git a/test-tools/perf-test-ncmp-passthrough-read.sh b/test-tools/perf-test-ncmp-passthrough-read.sh new file mode 100755 index 0000000000..21b031ce95 --- /dev/null +++ b/test-tools/perf-test-ncmp-passthrough-read.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# +# Copyright 2024 Nordix Foundation. +# +# 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. +# + +# This script measures the performance of NCMP data passthrough operations: +# NCMP endpoint tested: /ncmp/v1/ch/{cmHandleId}/data/ds/{datastoreName} + +set -o errexit # Exit on most errors +set -o nounset # Disallow expansion of unset variables +set -o pipefail # Use last non-zero exit code in a pipeline +#set -o xtrace # Uncomment for debugging + +############################ +# Configuration parameters # +############################ +CPS_HOST=localhost +CPS_PORT=8883 +CPS_USERNAME=cpsuser +CPS_PASSWORD=cpsr0cks! +PARALLEL_REQUESTS=12 +WARMUP_REQUESTS=600 +MEASUREMENT_REQUESTS=240 + +SCRIPT_DIR=$(dirname -- "${BASH_SOURCE[0]}") +# Read DMI delay from docker-compose.yml +DMI_DATA_DELAY=$(grep 'DATA_FOR_CM_HANDLE_DELAY_MS:' "$SCRIPT_DIR"/../docker-compose/docker-compose.yml | grep -oE '[0-9]+') + +function cmHandleExists() { + local cmHandleId=$1 + curl --silent --fail --output /dev/null --user "$CPS_USERNAME:$CPS_PASSWORD" --basic "http://$CPS_HOST:$CPS_PORT/ncmp/v1/ch/$cmHandleId" +} + +function failIfCmHandlesNotFound() { + # Just check to see if last needed CM-handle exists + local MAX_NEEDED_CM_HANDLES=$((WARMUP_REQUESTS > MEASUREMENT_REQUESTS ? WARMUP_REQUESTS : MEASUREMENT_REQUESTS)) + local cmHandleId="ch-$MAX_NEEDED_CM_HANDLES" + if ! cmHandleExists "$cmHandleId"; then + echo "ERROR: CM-handles not registered ($cmHandleId not found)" >&2 + echo "Note: this test assumes CM-handles have IDs ch-1, ch-2... ch-$MAX_NEEDED_CM_HANDLES" >&2 + exit 1 + fi +} + +function warnIfLessThan20kCmHandlesFound() { + local cmHandleId='ch-20000' + if ! cmHandleExists "$cmHandleId"; then + echo "WARNING: testing with less than 20,000 CM-handles is not recommended ($cmHandleId not found)" >&2 + fi +} + +function measureAverageResponseTimeInMillis() { + local totalRequests=$1 + curl --show-error --fail --fail-early \ + --output /dev/null --write-out '%{time_total}\n' \ + --parallel --parallel-max $PARALLEL_REQUESTS --parallel-immediate \ + --user "$CPS_USERNAME:$CPS_PASSWORD" --basic \ + --request POST "http://$CPS_HOST:$CPS_PORT/ncmp/v1/ch/ch-[1-$totalRequests]/data/ds/ncmp-datastore%3Apassthrough-operational?resourceIdentifier=x&include-descendants=true" | + awk '{ sum += $1; n++ } END { if (n > 0) print (sum / n) * 1000; }' +} + +# Sanity checks +failIfCmHandlesNotFound +warnIfLessThan20kCmHandlesFound + +# Do JVM warmup +echo "Warming up ($WARMUP_REQUESTS requests, ignoring results)" +measureAverageResponseTimeInMillis "$WARMUP_REQUESTS" > /dev/null + +# Measure performance +echo "Measuring average time of $MEASUREMENT_REQUESTS total requests, sending $PARALLEL_REQUESTS requests in parallel" +ncmpResponseTime=$(measureAverageResponseTimeInMillis "$MEASUREMENT_REQUESTS") +ncmpOverhead=$(echo "$ncmpResponseTime - $DMI_DATA_DELAY" | bc) + +# Report performance +echo "Average response time from NCMP: $ncmpResponseTime ms" +echo "Average response time from DMI: $DMI_DATA_DELAY ms" +echo "NCMP overhead: $ncmpOverhead ms" diff --git a/version.properties b/version.properties index 369d363418..daf40354a4 100644 --- a/version.properties +++ b/version.properties @@ -22,7 +22,7 @@ major=3 minor=4 -patch=4 +patch=5 base_version=${major}.${minor}.${patch} |