diff options
author | 2022-02-15 18:23:05 +0000 | |
---|---|---|
committer | 2022-02-28 15:25:58 +0000 | |
commit | e0643ab5130dde375c229989e216341e623a9c55 (patch) | |
tree | ae0d551c6f904950a1263dd73b2ada099d636b34 /cps-service/src/main/java/org | |
parent | 87de1fc8454fb1d93dfda7c5193783f16974cdaf (diff) |
CPS-887 Decreasing performance of cmHandle registration
- Creating temporary table module references from the
node
- Query returning new moduleReferences for node to be added to CPS
- Modified registration for node to use new implementation (incl. tests)
- Refactored some interface to use collection instead of list
- Modified SQL statements to use String.format()
- Fixed tests
Issue-ID: CPS-887
Signed-off-by: JosephKeenan <joseph.keenan@est.tech>
Change-Id: I58b17d29e8b9d6f7a644d33bf6cf8bf46f892580
Diffstat (limited to 'cps-service/src/main/java/org')
3 files changed, 41 insertions, 19 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java index 1dccf49c9..6ae28fe9c 100644 --- a/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java +++ b/cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation + * Copyright (C) 2020-2022 Nordix Foundation * Modifications Copyright (C) 2020-2021 Pantheon.tech * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.cps.api; import java.util.Collection; -import java.util.List; import java.util.Map; import org.checkerframework.checker.nullness.qual.NonNull; import org.onap.cps.spi.CascadeDeleteAllowed; @@ -48,16 +47,14 @@ public interface CpsModuleService { /** * Create a schema set from new modules and existing modules. - * - * @param dataspaceName Dataspace name - * @param schemaSetName schema set name - * @param newYangResourcesModuleNameToContentMap YANG resources map where key is a module name and value is content - * @param moduleReferences List of YANG resources module references of the modules - * needed for this handle that are already in CPS + * @param dataspaceName Dataspace name + * @param schemaSetName schema set name + * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content + * @param moduleReferences List of YANG resources module references of the modules */ void createSchemaSetFromModules(@NonNull String dataspaceName, @NonNull String schemaSetName, - @NonNull Map<String, String> newYangResourcesModuleNameToContentMap, - @NonNull List<ModuleReference> moduleReferences); + @NonNull Map<String, String> newModuleNameToContentMap, + Collection<ModuleReference> moduleReferences); /** * Read schema set in the given dataspace. @@ -96,4 +93,14 @@ public interface CpsModuleService { * @return a list of ModuleReference objects */ Collection<ModuleReference> getYangResourcesModuleReferences(String dataspaceName, String anchorName); + + /** + * Identify previously unknown Yang Resource module references. + * + * @param moduleReferencesToCheck the moduleReferencesToCheck + * @returns collection of module references + */ + Collection<ModuleReference> identifyNewModuleReferences( + Collection<ModuleReference> moduleReferencesToCheck); + } diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java index ffcc5a22f..7267f22b5 100644 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2021 Nordix Foundation + * Copyright (C) 2020-2022 Nordix Foundation * Modifications Copyright (C) 2020-2021 Pantheon.tech * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ @@ -23,7 +23,6 @@ package org.onap.cps.api.impl; import java.util.Collection; -import java.util.List; import java.util.Map; import lombok.AllArgsConstructor; import org.onap.cps.api.CpsAdminService; @@ -57,10 +56,10 @@ public class CpsModuleServiceImpl implements CpsModuleService { @Override public void createSchemaSetFromModules(final String dataspaceName, final String schemaSetName, - final Map<String, String> newYangResourcesModuleNameToContentMap, - final List<ModuleReference> moduleReferences) { + final Map<String, String> newModuleNameToContentMap, + final Collection<ModuleReference> moduleReferences) { cpsModulePersistenceService.storeSchemaSetFromModules(dataspaceName, schemaSetName, - newYangResourcesModuleNameToContentMap, moduleReferences); + newModuleNameToContentMap, moduleReferences); } @@ -102,4 +101,11 @@ public class CpsModuleServiceImpl implements CpsModuleService { private boolean isCascadeDeleteProhibited(final CascadeDeleteAllowed cascadeDeleteAllowed) { return CascadeDeleteAllowed.CASCADE_DELETE_PROHIBITED == cascadeDeleteAllowed; } + + @Override + public Collection<ModuleReference> identifyNewModuleReferences( + final Collection<ModuleReference> moduleReferencesToCheck) { + return cpsModulePersistenceService.identifyNewModuleReferences(moduleReferencesToCheck); + } + } diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java index e08273441..4306df78d 100755 --- a/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java +++ b/cps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation + * Copyright (C) 2020-2022 Nordix Foundation * Modifications Copyright (C) 2020-2022 Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,6 @@ package org.onap.cps.spi; import java.util.Collection; -import java.util.List; import java.util.Map; import org.onap.cps.spi.model.ModuleReference; @@ -45,11 +44,11 @@ public interface CpsModulePersistenceService { * * @param dataspaceName Dataspace name * @param schemaSetName Schema set name - * @param newYangResourcesModuleNameToContentMap YANG resources map where key is a module name and value is content + * @param newModuleNameToContentMap YANG resources map where key is a module name and value is content * @param moduleReferences List of YANG resources module references */ void storeSchemaSetFromModules(String dataspaceName, String schemaSetName, - Map<String, String> newYangResourcesModuleNameToContentMap, List<ModuleReference> moduleReferences); + Map<String, String> newModuleNameToContentMap, Collection<ModuleReference> moduleReferences); /** * Deletes Schema Set. @@ -98,4 +97,14 @@ public interface CpsModulePersistenceService { * Remove unused Yang Resource Modules. */ void deleteUnusedYangResourceModules(); + + /** + * Identify new module references from those returned by a node compared to what is in CPS already. + * + * @param moduleReferencesToCheck the module references ot check + * @returns Collection of {@link ModuleReference} of previously unknown module references + */ + Collection<ModuleReference> identifyNewModuleReferences( + Collection<ModuleReference> moduleReferencesToCheck); + } |