From 4e596846aa6f1b799487c553d6830004489d96a1 Mon Sep 17 00:00:00 2001 From: lukegleeson Date: Tue, 28 Jun 2022 12:15:33 +0100 Subject: 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 Change-Id: I9cda45f6c30b94684ee1c8ad0c49e35a3a824d52 --- .../onap/cps/ncmp/api/inventory/LockReasonCategory.java | 2 +- .../cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java | 14 +++++++------- .../org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'cps-ncmp-service/src/main/java/org/onap') 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 lockedMisbehavingCmHandles = syncUtils.getLockedMisbehavingYangModelCmHandles(); - for (final YangModelCmHandle moduleSyncFailedCmHandle : lockedMisbehavingCmHandles) { - final CompositeState compositeState = moduleSyncFailedCmHandle.getCompositeState(); + final List 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 getLockedMisbehavingYangModelCmHandles() { + public List getModuleSyncFailedCmHandles() { final List 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, -- cgit 1.2.3-korg