From: sourabh_sourabh Date: Thu, 2 Jun 2022 12:54:09 +0000 (+0100) Subject: CPS-1020 : DuplicatedYangResourceException error at parallel cmHandle registration X-Git-Tag: 3.1.0~110^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F129474%2F2;p=cps.git CPS-1020 : DuplicatedYangResourceException error at parallel cmHandle registration - @EnableRetry is added into application. - Added retry count into log to add more information about retry. Issue-ID: CPS-1020 Signed-off-by: sourabh_sourabh Change-Id: I00c58ef17a8c066f98711c1cf8e5e5cb5f22974b --- diff --git a/cps-application/src/main/java/org/onap/cps/Application.java b/cps-application/src/main/java/org/onap/cps/Application.java index ba707e964b..79d5950f68 100644 --- a/cps-application/src/main/java/org/onap/cps/Application.java +++ b/cps-application/src/main/java/org/onap/cps/Application.java @@ -22,7 +22,9 @@ package org.onap.cps; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.retry.annotation.EnableRetry; +@EnableRetry @SpringBootApplication public class Application { diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java index 3719256fcd..cbeb1b76f7 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java @@ -66,6 +66,7 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyIn import org.springframework.dao.DataIntegrityViolationException; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Retryable; +import org.springframework.retry.support.RetrySynchronizationManager; import org.springframework.stereotype.Component; @Slf4j @@ -219,9 +220,12 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ convertToDuplicatedYangResourceException( dataIntegrityViolationException, newYangResourceEntities); convertedException.ifPresent( - e -> log.warn( - "Cannot persist duplicated yang resource. " - + "System will attempt this method up to 5 times.", e)); + e -> { + int retryCount = RetrySynchronizationManager.getContext() == null ? 0 + : RetrySynchronizationManager.getContext().getRetryCount(); + log.warn("Cannot persist duplicated yang resource. System will attempt this method " + + "up to 5 times. Current retry count : {}", ++retryCount, e); + }); throw convertedException.isPresent() ? convertedException.get() : dataIntegrityViolationException; } }