Merge "Allow Module Re-Sync"
authorToine Siebelink <toine.siebelink@est.tech>
Fri, 1 Jul 2022 08:08:14 +0000 (08:08 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 1 Jul 2022 08:08:14 +0000 (08:08 +0000)
1  2 
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java

@@@ -55,15 -53,19 +55,16 @@@ public class ModuleSyncWatchdog 
              final String cmHandleId = advisedCmHandle.getId();
              final CompositeState compositeState = inventoryPersistence.getCmHandleState(cmHandleId);
              try {
+                 moduleSyncService.deleteSchemaSetIfExists(advisedCmHandle);
                  moduleSyncService.syncAndCreateSchemaSetAndAnchor(advisedCmHandle);
 -                compositeState.setCmHandleState(CmHandleState.READY);
 +                setCompositeStateToReadyWithInitialDataStoreSyncState().accept(compositeState);
              } catch (final Exception e) {
 -                compositeState.setCmHandleState(CmHandleState.LOCKED);
 +                setCompositeStateToLocked().accept(compositeState);
                  syncUtils.updateLockReasonDetailsAndAttempts(compositeState,
 -                    LockReasonCategory.LOCKED_MISBEHAVING,
 -                    e.getMessage());
 +                        LockReasonCategory.LOCKED_MISBEHAVING, e.getMessage());
              }
 -            compositeState.setLastUpdateTimeNow();
              inventoryPersistence.saveCmHandleState(cmHandleId, compositeState);
 -            log.info("{} is now in {} state", cmHandleId,
 -                advisedCmHandle.getCompositeState().getCmHandleState());
 +            log.debug("{} is now in {} state", cmHandleId, compositeState.getCmHandleState().name());
              advisedCmHandle = syncUtils.getAnAdvisedCmHandle();
          }
          log.debug("No Cm-Handles currently found in an ADVISED state");