diff options
author | lukegleeson <luke.gleeson@est.tech> | 2022-06-28 12:15:33 +0100 |
---|---|---|
committer | lukegleeson <luke.gleeson@est.tech> | 2022-07-04 09:26:30 +0100 |
commit | 4e596846aa6f1b799487c553d6830004489d96a1 (patch) | |
tree | 091fed8ac5403c3ea79a4d75d74d1a15a34649c4 /cps-ncmp-service/src/main/java | |
parent | 7914c8924723092345e8b4d829f15d2a3a5c72c8 (diff) |
Simplified 'External' lock reason Mapping
Refactored LOCKED_MISBEHAVING -> LOCKED_MODULE_SYNC_FAILED
CompositeStateMapper will change internal reason LOCKED_MODULE_SYNC_FAILED to external reason LOCKED_MISBEHAVING for client payloads
Changed openapi description of lock-reason to reflect only enum currently available LOCKED_MISBEHAVING
Issue-ID: CPS-1099
Signed-off-by: lukegleeson <luke.gleeson@est.tech>
Change-Id: I9cda45f6c30b94684ee1c8ad0c49e35a3a824d52
Diffstat (limited to 'cps-ncmp-service/src/main/java')
3 files changed, 12 insertions, 12 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/LockReasonCategory.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/LockReasonCategory.java index 596fcb7f99..16ae881935 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/LockReasonCategory.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/LockReasonCategory.java @@ -21,5 +21,5 @@ package org.onap.cps.ncmp.api.inventory; public enum LockReasonCategory { - LOCKED_MISBEHAVING + LOCKED_MODULE_SYNC_FAILED } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java index 6ec44197d2..0330991fd6 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java @@ -1,5 +1,5 @@ /* - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * Copyright (C) 2022 Nordix Foundation * Modifications Copyright (C) 2022 Bell Canada * ================================================================================ @@ -61,7 +61,7 @@ public class ModuleSyncWatchdog { } catch (final Exception e) { setCompositeStateToLocked().accept(compositeState); syncUtils.updateLockReasonDetailsAndAttempts(compositeState, - LockReasonCategory.LOCKED_MISBEHAVING, e.getMessage()); + LockReasonCategory.LOCKED_MODULE_SYNC_FAILED, e.getMessage()); } inventoryPersistence.saveCmHandleState(cmHandleId, compositeState); log.debug("{} is now in {} state", cmHandleId, compositeState.getCmHandleState().name()); @@ -75,14 +75,14 @@ public class ModuleSyncWatchdog { */ @Scheduled(fixedDelayString = "${timers.locked-modules-sync.sleep-time-ms:300000}") public void executeLockedCmHandlePoll() { - final List<YangModelCmHandle> lockedMisbehavingCmHandles = syncUtils.getLockedMisbehavingYangModelCmHandles(); - for (final YangModelCmHandle moduleSyncFailedCmHandle : lockedMisbehavingCmHandles) { - final CompositeState compositeState = moduleSyncFailedCmHandle.getCompositeState(); + final List<YangModelCmHandle> lockedCmHandles = syncUtils.getModuleSyncFailedCmHandles(); + for (final YangModelCmHandle lockedCmHandle : lockedCmHandles) { + final CompositeState compositeState = lockedCmHandle.getCompositeState(); final boolean isReadyForRetry = syncUtils.isReadyForRetry(compositeState); if (isReadyForRetry) { setCompositeStateToAdvisedAndRetainOldLockReasonDetails(compositeState); - log.debug("Locked misbehaving cm handle {} is being recycled", moduleSyncFailedCmHandle.getId()); - inventoryPersistence.saveCmHandleState(moduleSyncFailedCmHandle.getId(), compositeState); + log.debug("Locked cm handle {} is being resynced", lockedCmHandle.getId()); + inventoryPersistence.saveCmHandleState(lockedCmHandle.getId(), compositeState); } } } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java index 0c3af6aaeb..e742b8c0f7 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java @@ -109,13 +109,13 @@ public class SyncUtils { } /** - * Query data nodes for cm handles with an "LOCKED" cm handle state with reason LOCKED_MISBEHAVING". + * Query data nodes for cm handles with an "LOCKED" cm handle state with reason LOCKED_MODULE_SYNC_FAILED". * - * @return a random yang model cm handle with an ADVISED state, return null if not found + * @return a random LOCKED yang model cm handle, return null if not found */ - public List<YangModelCmHandle> getLockedMisbehavingYangModelCmHandles() { + public List<YangModelCmHandle> getModuleSyncFailedCmHandles() { final List<DataNode> lockedCmHandleAsDataNodeList = inventoryPersistence.getCmHandleDataNodesByCpsPath( - "//lock-reason[@reason=\"LOCKED_MISBEHAVING\"]/ancestor::cm-handles", + "//lock-reason[@reason=\"LOCKED_MODULE_SYNC_FAILED\"]/ancestor::cm-handles", FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS); return lockedCmHandleAsDataNodeList.stream() .map(cmHandle -> YangDataConverter.convertCmHandleToYangModel(cmHandle, |