summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylanB95EST <dylan.byrne@est.tech>2022-07-01 16:38:14 +0100
committerDylanB95EST <dylan.byrne@est.tech>2022-07-01 17:18:13 +0100
commit6718d14c253bc0194e70dfe2464d295d1ee9096e (patch)
treee8eef7e4526c1ca668f753a5fac88596948a8108
parent7914c8924723092345e8b4d829f15d2a3a5c72c8 (diff)
Add Logging to specify next retry
Adding logging to specify the next time in minutes until the retry mechanism will attempt to unlock the cm handle if it is not yet ready to be unlocked Issue-ID: CPS-1076 Change-Id: Ic2b011966c779f13ad8380ebfd7d4b4354e6b3e1 Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/SyncUtils.java10
1 files changed, 7 insertions, 3 deletions
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 0c3af6aaeb..8c30b590ee 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;
}
/**