Merge "Merge 2 'query' end points in NCMP"
authorToine Siebelink <toine.siebelink@est.tech>
Wed, 8 Jun 2022 10:03:11 +0000 (10:03 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 8 Jun 2022 10:03:11 +0000 (10:03 +0000)
cps-application/src/main/java/org/onap/cps/Application.java
cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java

index ba707e9..79d5950 100644 (file)
@@ -22,7 +22,9 @@ package org.onap.cps;
 \r
 import org.springframework.boot.SpringApplication;\r
 import org.springframework.boot.autoconfigure.SpringBootApplication;\r
+import org.springframework.retry.annotation.EnableRetry;\r
 \r
+@EnableRetry\r
 @SpringBootApplication\r
 public class Application {\r
 \r
index 3719256..cbeb1b7 100755 (executable)
@@ -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;
             }
         }