From 62ac0c3b172ef5dbbc9d22d10bb45186b446d4c9 Mon Sep 17 00:00:00 2001 From: "puthuparambil.aditya" Date: Thu, 3 Feb 2022 16:42:13 +0000 Subject: Fix for retry mechanism on concurrent CmHandle registration Issue-ID: CPS-856 Signed-off-by: puthuparambil.aditya Change-Id: Ie7c0033f2987166315611f8a286ae3978466c75f --- .../org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cps-ri/src/main/java') 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 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 newYangResourcesModuleNameToContentMap, final List 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; } } -- cgit 1.2.3-korg