summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2023-02-09 15:52:33 +0000
committerDaniel Hanrahan <daniel.hanrahan@est.tech>2023-02-09 16:26:52 +0000
commit105432686d7b840a0378fadcc32abb73976006bf (patch)
tree4c96ecca571bf1bccad9aae04c6339b06d2e3c67 /cps-ncmp-service/src/main/java
parentdb90c8758d43b1daab09c760a3fe3102d772d7df (diff)
Use getDataNodes (plural) in CmHandle deregistration
Issue-ID: CPS-1426 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: I0ad79bf36840cdecc13898e185dc618cedafd529
Diffstat (limited to 'cps-ncmp-service/src/main/java')
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java27
1 files changed, 12 insertions, 15 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 59b960af65..e71b72ab86 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
@@ -327,36 +327,33 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
final List<String> tobeRemovedCmHandles) {
final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses =
new ArrayList<>(tobeRemovedCmHandles.size());
- final Map<String, YangModelCmHandle> cmHandleIdToYangModelCmHandleMap = tobeRemovedCmHandles.stream()
- .collect(Collectors.toMap(cmHandleId -> cmHandleId, inventoryPersistence::getYangModelCmHandle));
+ final Collection<YangModelCmHandle> yangModelCmHandles =
+ inventoryPersistence.getYangModelCmHandles(tobeRemovedCmHandles);
- final Collection<YangModelCmHandle> yangModelCmHandles = cmHandleIdToYangModelCmHandleMap.values();
updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETING);
+ final Set<String> notDeletedCmHandles = new HashSet<>();
for (final List<String> tobeRemovedCmHandleBatch : Lists.partition(tobeRemovedCmHandles, DELETE_BATCH_SIZE)) {
try {
batchDeleteCmHandlesFromDbAndModuleSyncMap(tobeRemovedCmHandleBatch);
tobeRemovedCmHandleBatch.forEach(cmHandleId ->
cmHandleRegistrationResponses.add(CmHandleRegistrationResponse.createSuccessResponse(cmHandleId)));
- } catch (final Exception batchException) {
+ } catch (final RuntimeException batchException) {
log.error("Unable to de-register cm-handle batch, retrying on each cm handle");
for (final String cmHandleId : tobeRemovedCmHandleBatch) {
final CmHandleRegistrationResponse cmHandleRegistrationResponse =
deleteCmHandleAndGetCmHandleRegistrationResponse(cmHandleId);
cmHandleRegistrationResponses.add(cmHandleRegistrationResponse);
+ if (cmHandleRegistrationResponse.getStatus() != CmHandleRegistrationResponse.Status.SUCCESS) {
+ notDeletedCmHandles.add(cmHandleId);
+ }
}
}
}
- final Collection<YangModelCmHandle> deletedYangModelCmHandles =
- cmHandleRegistrationResponses.stream()
- .filter(cmHandleRegistrationResponse ->
- cmHandleRegistrationResponse.getStatus().equals(CmHandleRegistrationResponse.Status.SUCCESS))
- .map(CmHandleRegistrationResponse::getCmHandle)
- .map(cmHandleIdToYangModelCmHandleMap::get)
- .collect(Collectors.toList());
- updateCmHandleStateBatch(deletedYangModelCmHandles, CmHandleState.DELETED);
+ yangModelCmHandles.removeIf(yangModelCmHandle -> notDeletedCmHandles.contains(yangModelCmHandle.getId()));
+ updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETED);
return cmHandleRegistrationResponses;
}
@@ -383,9 +380,9 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
private void updateCmHandleStateBatch(final Collection<YangModelCmHandle> yangModelCmHandles,
final CmHandleState cmHandleState) {
- final Map<YangModelCmHandle, CmHandleState> cmHandleIdsToBeRemoved = new HashMap<>();
- yangModelCmHandles.forEach(yangModelCmHandle -> cmHandleIdsToBeRemoved.put(yangModelCmHandle, cmHandleState));
- lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleIdsToBeRemoved);
+ final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle = new HashMap<>(yangModelCmHandles.size());
+ yangModelCmHandles.forEach(yangModelCmHandle -> cmHandleStatePerCmHandle.put(yangModelCmHandle, cmHandleState));
+ lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
}
private void deleteCmHandleFromDbAndModuleSyncMap(final String cmHandleId) {