summaryrefslogtreecommitdiffstats
path: root/cps-service/src/main/java/org
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2023-02-14 13:24:40 +0000
committerdanielhanrahan <daniel.hanrahan@est.tech>2023-02-15 14:19:42 +0000
commite28b62148676d189bdd11b78d8d78419d548e358 (patch)
tree13974274471b6328bc22474358949c87e210687b /cps-service/src/main/java/org
parent9575b84ab4e2db885d8761a98eaae9ff3a06aa81 (diff)
Bulk delete schemasets in CM handle deregistration
- Batch delete schema sets in single query - Call deleteUnusedYangResourceModules once per batch, not per CM handle - Results for deregistering 10k: 14 mins before; 6 mins after Issue-ID: CPS-1423 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: Ia3a86a0dc88677323e2f386253a99022a7f02603
Diffstat (limited to 'cps-service/src/main/java/org')
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/CpsModuleService.java14
-rw-r--r--cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java20
-rwxr-xr-xcps-service/src/main/java/org/onap/cps/spi/CpsModulePersistenceService.java10
-rw-r--r--cps-service/src/main/java/org/onap/cps/spi/utils/CpsValidator.java9
4 files changed, 47 insertions, 6 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 b1f90d686b..5ff08c9ac8 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-2022 Nordix Foundation
+ * Copyright (C) 2020-2023 Nordix Foundation
* Modifications Copyright (C) 2020-2021 Pantheon.tech
* Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
@@ -80,13 +80,21 @@ public interface CpsModuleService {
* @param dataspaceName dataspace name
* @param schemaSetName schema set name
* @param cascadeDeleteAllowed indicates the allowance to remove associated anchors and data if exist
- * @throws DataInUseException if cascadeDeleteAllowed is set to CASCADE_DELETE_PROHIBITED and there
- * is associated anchor record exists in database
+ * @throws DataInUseException if cascadeDeleteAllowed is set to CASCADE_DELETE_PROHIBITED and there
+ * is associated anchor record exists in database
*/
void deleteSchemaSet(String dataspaceName, String schemaSetName,
CascadeDeleteAllowed cascadeDeleteAllowed);
/**
+ * Deletes Schema Sets with cascade.
+ *
+ * @param dataspaceName dataspace name
+ * @param schemaSetNames schema set names
+ */
+ void deleteSchemaSetsWithCascade(String dataspaceName, Collection<String> schemaSetNames);
+
+ /**
* Retrieve module references for the given dataspace name.
*
* @param dataspaceName dataspace name
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 ccd0fcc289..e71e6ce662 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
@@ -95,7 +95,7 @@ public class CpsModuleServiceImpl implements CpsModuleService {
@Override
@Transactional
public void deleteSchemaSet(final String dataspaceName, final String schemaSetName,
- final CascadeDeleteAllowed cascadeDeleteAllowed) {
+ final CascadeDeleteAllowed cascadeDeleteAllowed) {
cpsValidator.validateNameCharacters(dataspaceName, schemaSetName);
final Collection<Anchor> anchors = cpsAdminService.getAnchors(dataspaceName, schemaSetName);
if (!anchors.isEmpty() && isCascadeDeleteProhibited(cascadeDeleteAllowed)) {
@@ -110,6 +110,24 @@ public class CpsModuleServiceImpl implements CpsModuleService {
}
@Override
+ @Transactional
+ public void deleteSchemaSetsWithCascade(final String dataspaceName, final Collection<String> schemaSetNames) {
+ cpsValidator.validateNameCharacters(dataspaceName);
+ cpsValidator.validateNameCharacters(schemaSetNames);
+ for (final String schemaSetName : schemaSetNames) {
+ final Collection<Anchor> anchors = cpsAdminService.getAnchors(dataspaceName, schemaSetName);
+ for (final Anchor anchor : anchors) {
+ cpsAdminService.deleteAnchor(dataspaceName, anchor.getName());
+ }
+ }
+ cpsModulePersistenceService.deleteUnusedYangResourceModules();
+ cpsModulePersistenceService.deleteSchemaSets(dataspaceName, schemaSetNames);
+ for (final String schemaSetName : schemaSetNames) {
+ yangTextSchemaSourceSetCache.removeFromCache(dataspaceName, schemaSetName);
+ }
+ }
+
+ @Override
public Collection<ModuleReference> getYangResourceModuleReferences(final String dataspaceName) {
cpsValidator.validateNameCharacters(dataspaceName);
return cpsModulePersistenceService.getYangResourceModuleReferences(dataspaceName);
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 f5dc8ac3a3..40d4002b97 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-2022 Nordix Foundation
+ * Copyright (C) 2020-2023 Nordix Foundation
* Modifications Copyright (C) 2020-2022 Bell Canada.
* Modifications Copyright (C) 2022 TechMahindra Ltd.
* ================================================================================
@@ -70,6 +70,14 @@ public interface CpsModulePersistenceService {
void deleteSchemaSet(String dataspaceName, String schemaSetName);
/**
+ * Deletes Schema Sets.
+ *
+ * @param dataspaceName dataspace name
+ * @param schemaSetNames schema set names
+ */
+ void deleteSchemaSets(String dataspaceName, Collection<String> schemaSetNames);
+
+ /**
* Returns YANG resources per specific dataspace / schemaSetName.
*
* @param dataspaceName dataspace name
diff --git a/cps-service/src/main/java/org/onap/cps/spi/utils/CpsValidator.java b/cps-service/src/main/java/org/onap/cps/spi/utils/CpsValidator.java
index c7ce8fc926..231094cf16 100644
--- a/cps-service/src/main/java/org/onap/cps/spi/utils/CpsValidator.java
+++ b/cps-service/src/main/java/org/onap/cps/spi/utils/CpsValidator.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation
+ * Copyright (C) 2022-2023 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,4 +28,11 @@ public interface CpsValidator {
* @param names names of data to be validated
*/
void validateNameCharacters(final String... names);
+
+ /**
+ * Validate characters in names within cps.
+ *
+ * @param names names of data to be validated
+ */
+ void validateNameCharacters(final Iterable<String> names);
}