diff options
author | Bruno Sakoto <bruno.sakoto@bell.ca> | 2022-02-09 16:53:20 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2022-02-09 16:53:20 +0000 |
commit | d3bb89c442eaad9d635deffd34fe5ae680394790 (patch) | |
tree | 495ef5765ccf0d17a18825b2cd73a5622ce32042 /cps-ri/src/main | |
parent | 4125b3266d9cda4a6e37b7efc9caa6bde231405b (diff) | |
parent | 62ac0c3b172ef5dbbc9d22d10bb45186b446d4c9 (diff) |
Merge "Fix for retry mechanism on concurrent CmHandle registration"
Diffstat (limited to 'cps-ri/src/main')
-rwxr-xr-x | cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java | 10 |
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; } } |