summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/java
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2022-02-03 16:42:13 +0000
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>2022-02-09 09:47:25 +0000
commit62ac0c3b172ef5dbbc9d22d10bb45186b446d4c9 (patch)
tree235a44d810587b6d01de8f8cb91cd6d1446b7728 /cps-ri/src/main/java
parentf5cad5a6d75d0072fb3be7347cccd50ecfa120ae (diff)
Fix for retry mechanism on concurrent CmHandle registration
Issue-ID: CPS-856 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: Ie7c0033f2987166315611f8a286ae3978466c75f
Diffstat (limited to 'cps-ri/src/main/java')
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java10
1 files changed, 7 insertions, 3 deletions
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 3e39a05c51..86d5de6d0f 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
@@ -134,10 +134,10 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
@Transactional
// A retry is made to store the schema set if it fails because of duplicated yang resource exception that
// can occur in case of specific concurrent requests.
- @Retryable(value = DuplicatedYangResourceException.class, maxAttempts = 2, backoff = @Backoff(delay = 500))
+ @Retryable(value = DuplicatedYangResourceException.class, maxAttempts = 5, backoff =
+ @Backoff(random = true, delay = 200, maxDelay = 2000, multiplier = 2))
public void storeSchemaSet(final String dataspaceName, final String schemaSetName,
final Map<String, String> yangResourcesNameToContentMap) {
-
final var dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
final var yangResourceEntities = synchronizeYangResources(yangResourcesNameToContentMap);
final var schemaSetEntity = new SchemaSetEntity();
@@ -153,6 +153,10 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
@Override
@Transactional
+ // A retry is made to store the schema set if it fails because of duplicated yang resource exception that
+ // can occur in case of specific concurrent requests.
+ @Retryable(value = DuplicatedYangResourceException.class, maxAttempts = 5, backoff =
+ @Backoff(random = true, delay = 200, maxDelay = 2000, multiplier = 2))
public void storeSchemaSetFromModules(final String dataspaceName, final String schemaSetName,
final Map<String, String> newYangResourcesModuleNameToContentMap,
final List<ModuleReference> moduleReferences) {
@@ -219,7 +223,7 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
convertedException.ifPresent(
e -> log.warn(
"Cannot persist duplicated yang resource. "
- + "A total of 2 attempts to store the schema set are planned.", e));
+ + "System will attempt this method up to 5 times.", e));
throw convertedException.isPresent() ? convertedException.get() : dataIntegrityViolationException;
}
}