summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java/org/onap
diff options
context:
space:
mode:
authorToine Siebelink <toine.siebelink@est.tech>2023-01-12 16:31:07 +0000
committerGerrit Code Review <gerrit@onap.org>2023-01-12 16:31:07 +0000
commitef2b1518cf984f34b0640eb16ed44b26c9192efe (patch)
tree49845b66f163e455bf679382a9beae7065409cc4 /cps-ncmp-service/src/main/java/org/onap
parentec769e3d938d2a5b626ddd2be11a44ac4471c74a (diff)
parent078ce32b996a8f0421d8f30f9d10d9755cee28d7 (diff)
Merge "Updating CmHandleStates using batch operation"
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap')
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java29
1 files changed, 22 insertions, 7 deletions
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 d00d2119b1..5aad404e61 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
@@ -93,8 +93,12 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
final DmiPluginRegistration dmiPluginRegistration) {
dmiPluginRegistration.validateDmiPluginRegistration();
final DmiPluginRegistrationResponse dmiPluginRegistrationResponse = new DmiPluginRegistrationResponse();
- dmiPluginRegistrationResponse.setRemovedCmHandles(
- parseAndRemoveCmHandlesInDmiRegistration(dmiPluginRegistration.getRemovedCmHandles()));
+
+ if (!dmiPluginRegistration.getRemovedCmHandles().isEmpty()) {
+ dmiPluginRegistrationResponse.setRemovedCmHandles(
+ parseAndRemoveCmHandlesInDmiRegistration(dmiPluginRegistration.getRemovedCmHandles()));
+ }
+
if (!dmiPluginRegistration.getCreatedCmHandles().isEmpty()) {
dmiPluginRegistrationResponse.setCreatedCmHandles(
parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(dmiPluginRegistration));
@@ -321,15 +325,13 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
final List<String> tobeRemovedCmHandles) {
final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses =
new ArrayList<>(tobeRemovedCmHandles.size());
+
+ setState(tobeRemovedCmHandles, CmHandleState.DELETING);
+
for (final String cmHandleId : tobeRemovedCmHandles) {
try {
- final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId);
- lcmEventsCmHandleStateHandler.updateCmHandleState(yangModelCmHandle,
- CmHandleState.DELETING);
deleteCmHandleFromDbAndModuleSyncMap(cmHandleId);
cmHandleRegistrationResponses.add(CmHandleRegistrationResponse.createSuccessResponse(cmHandleId));
- lcmEventsCmHandleStateHandler.updateCmHandleState(yangModelCmHandle,
- CmHandleState.DELETED);
} catch (final DataNodeNotFoundException dataNodeNotFoundException) {
log.error("Unable to find dataNode for cmHandleId : {} , caused by : {}",
cmHandleId, dataNodeNotFoundException.getMessage());
@@ -347,9 +349,22 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
CmHandleRegistrationResponse.createFailureResponse(cmHandleId, exception));
}
}
+
+ setState(tobeRemovedCmHandles, CmHandleState.DELETED);
+
return cmHandleRegistrationResponses;
}
+ private void setState(final List<String> tobeRemovedCmHandles, final CmHandleState cmHandleState) {
+ final Map<YangModelCmHandle, CmHandleState> cmHandleIdsToBeRemoved = new HashMap<>();
+ for (final String cmHandleId : tobeRemovedCmHandles) {
+ cmHandleIdsToBeRemoved.put(
+ inventoryPersistence.getYangModelCmHandle(cmHandleId),
+ cmHandleState);
+ }
+ lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleIdsToBeRemoved);
+ }
+
private void deleteCmHandleFromDbAndModuleSyncMap(final String cmHandleId) {
inventoryPersistence.deleteSchemaSetWithCascade(cmHandleId);
inventoryPersistence.deleteListOrListElement("/dmi-registry/cm-handles[@id='" + cmHandleId + "']");