Remove excessive registration and de-registration logging 46/141146/3
authorToineSiebelink <toine.siebelink@est.tech>
Mon, 9 Jun 2025 12:01:09 +0000 (13:01 +0100)
committerToineSiebelink <toine.siebelink@est.tech>
Mon, 9 Jun 2025 15:36:12 +0000 (16:36 +0100)
- changed registration logging to debug level places agreed with team
 (we now have instrumentation for all cm handle states to see similar info)

Issue-ID: CPS-2816
Change-Id: I85bd79ef38cda3bf755b4f8e97e61fa4f3d2b4b9
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasks.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncWatchdog.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerImpl.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/lcm/LcmEventsCmHandleStateHandlerImplSpec.groovy

index f8f023e..fcd658a 100644 (file)
@@ -105,7 +105,7 @@ public class ModuleSyncTasks {
             compositeState.setLockReason(null);
             return CmHandleState.READY;
         } catch (final Exception e) {
-            log.warn("Processing of {} failed, reason: {}.", yangModelCmHandle.getId(), e.getMessage());
+            log.debug("Processing of {} failed, reason: {}.", yangModelCmHandle.getId(), e.getMessage());
             final LockReasonCategory lockReasonCategory = inUpgrade
                     ? LockReasonCategory.MODULE_UPGRADE_FAILED
                     : LockReasonCategory.MODULE_SYNC_FAILED;
index 12e013f..2d71f39 100644 (file)
@@ -99,7 +99,7 @@ public class ModuleSyncWatchdog {
                     advisedCmHandleIds.size());
             advisedCmHandleIds.forEach(cmHandleId -> {
                 if (moduleSyncWorkQueue.offer(cmHandleId)) {
-                    log.info("CM handle {} added to the work queue.", cmHandleId);
+                    log.debug("CM handle {} added to the work queue.", cmHandleId);
                 } else {
                     log.warn("Failed to add CM handle {} to the work queue.", cmHandleId);
                 }
@@ -131,7 +131,7 @@ public class ModuleSyncWatchdog {
             if (alreadyAddedToInProgressMap) {
                 log.info("module sync for {} already in progress by other instance", cmHandleId);
             } else {
-                log.info("Adding cmHandle : {} to current batch", cmHandleId);
+                log.debug("Adding cmHandle : {} to current batch", cmHandleId);
                 nextBatch.add(cmHandleId);
             }
         }
index 5bbc3a0..4fed26c 100644 (file)
@@ -163,7 +163,7 @@ public class LcmEventsCmHandleStateHandlerImpl implements LcmEventsCmHandleState
     private static void logCmHandleStateChanges(final Collection<CmHandleTransitionPair> cmHandleTransitionPairs) {
         cmHandleTransitionPairs.stream()
                 .map(CmHandleTransitionPair::getTargetYangModelCmHandle)
-                .forEach(yangModelCmHandle -> log.info("{} is now in {} state", yangModelCmHandle.getId(),
+                .forEach(yangModelCmHandle -> log.debug("{} is now in {} state", yangModelCmHandle.getId(),
                         yangModelCmHandle.getCompositeState().getCmHandleState().name()));
     }
 
index ebf2eee..004cc52 100644 (file)
@@ -24,8 +24,8 @@ import ch.qos.logback.classic.Level
 import ch.qos.logback.classic.Logger
 import ch.qos.logback.classic.spi.ILoggingEvent
 import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.ncmp.api.inventory.models.CompositeState
 import org.onap.cps.ncmp.api.inventory.DataStoreSyncState
+import org.onap.cps.ncmp.api.inventory.models.CompositeState
 import org.onap.cps.ncmp.impl.inventory.InventoryPersistence
 import org.onap.cps.ncmp.impl.inventory.models.YangModelCmHandle
 import org.slf4j.LoggerFactory
@@ -42,11 +42,13 @@ import static org.onap.cps.ncmp.api.inventory.models.LockReasonCategory.MODULE_S
 
 class LcmEventsCmHandleStateHandlerImplSpec extends Specification {
 
-    def logger = Spy(ListAppender<ILoggingEvent>)
+    def logAppender = Spy(ListAppender<ILoggingEvent>)
 
     void setup() {
-        ((Logger) LoggerFactory.getLogger(LcmEventsCmHandleStateHandlerImpl.class)).addAppender(logger)
-        logger.start()
+        def logger = LoggerFactory.getLogger(LcmEventsCmHandleStateHandlerImpl)
+        logger.setLevel(Level.DEBUG)
+        logger.addAppender(logAppender)
+        logAppender.start()
     }
 
     void cleanup() {
@@ -78,9 +80,9 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification {
                     assert cmHandleStatePerCmHandleId.get(cmHandleId).cmHandleState == toCmHandleState
                 }
             }
-        and: 'log message shows state change at INFO level'
-            def loggingEvent = (ILoggingEvent) logger.list[0]
-            assert loggingEvent.level == Level.INFO
+        and: 'log message shows state change at DEBUG level'
+            def loggingEvent = logAppender.list[0]
+            assert loggingEvent.level == Level.DEBUG
             assert loggingEvent.formattedMessage == "${cmHandleId} is now in ${toCmHandleState} state"
         and: 'event service is called to send event'
             1 * mockLcmEventsProducer.sendLcmEvent(cmHandleId, _, _)
@@ -183,8 +185,6 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification {
             1 * mockInventoryPersistence.saveCmHandleStateBatch(EMPTY_MAP)
         and: 'no event will be sent'
             0 * mockLcmEventsProducer.sendLcmEvent(*_)
-        and: 'no log entries are written'
-            assert logger.list.empty
     }
 
     def 'Batch of new cm handles provided'() {
@@ -255,7 +255,7 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification {
         and: 'no events are sent'
             0 * mockLcmEventsProducer.sendLcmEvent(_, _, _)
         and: 'no log entries are written'
-            assert logger.list.empty
+            assert logAppender.list.empty
     }
 
     def setupBatch(type) {
@@ -288,6 +288,6 @@ class LcmEventsCmHandleStateHandlerImplSpec extends Specification {
     }
 
     def getLogMessage(index) {
-        return logger.list[index].formattedMessage
+        return logAppender.list[index].formattedMessage
     }
 }