From: Joseph Keenan Date: Mon, 4 Jul 2022 05:59:03 +0000 (+0000) Subject: Merge "Add Logging to specify next retry" X-Git-Tag: 3.1.0~80 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=8f8331d713970a9610861c31f571e9acd60ade65;hp=b728fc71a7e87d735f98339807678eb5b7912c92;p=cps.git Merge "Add Logging to specify next retry" --- diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java index 0c3af6aae..8c30b590e 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java @@ -151,18 +151,22 @@ public class SyncUtils { * @return if the retry mechanism should be attempted */ public boolean isReadyForRetry(final CompositeState compositeState) { - int timeUntilNextAttempt = 1; + int timeInMinutesUntilNextAttempt = 1; final OffsetDateTime time = OffsetDateTime.parse(compositeState.getLastUpdateTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")); final Matcher matcher = retryAttemptPattern.matcher(compositeState.getLockReason().getDetails()); if (matcher.find()) { - timeUntilNextAttempt = (int) Math.pow(2, Integer.parseInt(matcher.group(1))); + timeInMinutesUntilNextAttempt = (int) Math.pow(2, Integer.parseInt(matcher.group(1))); } else { log.debug("First Attempt: no current attempts found."); } final int timeSinceLastAttempt = (int) Duration.between(time, OffsetDateTime.now()).toMinutes(); - return timeSinceLastAttempt > timeUntilNextAttempt; + if (timeInMinutesUntilNextAttempt >= timeSinceLastAttempt) { + log.info("Time until next attempt is {} minutes: ", + timeInMinutesUntilNextAttempt - timeSinceLastAttempt); + } + return timeSinceLastAttempt > timeInMinutesUntilNextAttempt; } /**