summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2024-11-01 17:35:21 +0000
committerdanielhanrahan <daniel.hanrahan@est.tech>2024-11-04 13:26:23 +0000
commit4b93bb71bed24b4b6c06bdd1d1ceb13f8580eb10 (patch)
tree195ecb5de661f3e38eb7b258085a9d33ff0f450a /cps-ncmp-service
parent45e00010bef158d55aacb99756f09869777908bb (diff)
[Module Sync] Always update states at end of batch
This commit moves the state update code into the 'finally' block, so that state updates are always sent for the handles that finished syncing, even if an exception occurred. This commit also fixes a typo in cmHandleStatePerCmHandle. Issue-ID: CPS-2474 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: Ic25608a5772c0873fe0d0f8aca8d70bcda51d94a
Diffstat (limited to 'cps-ncmp-service')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasks.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasks.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasks.java
index 80cdea8b7b..f00ac608b9 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasks.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasks.java
@@ -58,9 +58,9 @@ public class ModuleSyncTasks {
*/
public CompletableFuture<Void> performModuleSync(final Collection<DataNode> cmHandlesAsDataNodes,
final AtomicInteger batchCounter) {
+ final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle =
+ new HashMap<>(cmHandlesAsDataNodes.size());
try {
- final Map<YangModelCmHandle, CmHandleState> cmHandelStatePerCmHandle
- = new HashMap<>(cmHandlesAsDataNodes.size());
for (final DataNode cmHandleAsDataNode : cmHandlesAsDataNodes) {
final String cmHandleId = String.valueOf(cmHandleAsDataNode.getLeaves().get("id"));
final YangModelCmHandle yangModelCmHandle = YangDataConverter.toYangModelCmHandle(cmHandleAsDataNode);
@@ -74,7 +74,7 @@ public class ModuleSyncTasks {
moduleSyncService.syncAndCreateSchemaSetAndAnchor(yangModelCmHandle);
}
yangModelCmHandle.getCompositeState().setLockReason(null);
- cmHandelStatePerCmHandle.put(yangModelCmHandle, CmHandleState.READY);
+ cmHandleStatePerCmHandle.put(yangModelCmHandle, CmHandleState.READY);
} catch (final Exception e) {
log.warn("Processing of {} module failed due to reason {}.", cmHandleId, e.getMessage());
final LockReasonCategory lockReasonCategory = inUpgrade ? LockReasonCategory.MODULE_UPGRADE_FAILED
@@ -82,12 +82,12 @@ public class ModuleSyncTasks {
moduleOperationsUtils.updateLockReasonWithAttempts(compositeState,
lockReasonCategory, e.getMessage());
setCmHandleStateLocked(yangModelCmHandle, compositeState.getLockReason());
- cmHandelStatePerCmHandle.put(yangModelCmHandle, CmHandleState.LOCKED);
+ cmHandleStatePerCmHandle.put(yangModelCmHandle, CmHandleState.LOCKED);
}
}
- lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandelStatePerCmHandle);
} finally {
batchCounter.getAndDecrement();
+ lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
log.info("Processing module sync batch finished. {} batch(es) active.", batchCounter.get());
}
return CompletableFuture.completedFuture(null);