From f010d3432b500258121a190ecf94d757c881390e Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Wed, 5 Jun 2024 14:32:37 +0100 Subject: Remove Map in ACM-R for timeout Deploy/Undeploy Issue-ID: POLICY-5040 Change-Id: I6aa5e93fc63cc865648096512487994fb2f48a54 Signed-off-by: FrancescoFioraEst --- .../models/acm/concepts/AutomationComposition.java | 8 ++++++- .../concepts/JpaAutomationComposition.java | 27 +++++++++++++++++++++- .../policy/clamp/models/acm/utils/AcmUtils.java | 4 ++-- 3 files changed, 35 insertions(+), 4 deletions(-) (limited to 'models/src/main/java') diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java index 0cf1f99ec..eb5b6dc9b 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,10 @@ public class AutomationComposition extends ToscaEntity implements Comparable elements; private StateChangeResult stateChangeResult; @@ -69,6 +73,8 @@ public class AutomationComposition extends ToscaEntity implements Comparable(this.elements.size())); @@ -199,6 +212,8 @@ public class JpaAutomationComposition extends Validated this.restarting = automationComposition.getRestarting(); this.deployState = automationComposition.getDeployState(); this.lockState = automationComposition.getLockState(); + this.lastMsg = TimestampHelper.toTimestamp(automationComposition.getLastMsg()); + this.phase = automationComposition.getPhase(); this.description = automationComposition.getDescription(); this.stateChangeResult = automationComposition.getStateChangeResult(); this.elements = new ArrayList<>(automationComposition.getElements().size()); @@ -229,6 +244,16 @@ public class JpaAutomationComposition extends Validated return result; } + result = lastMsg.compareTo(other.lastMsg); + if (result != 0) { + return result; + } + + result = ObjectUtils.compare(phase, other.phase); + if (result != 0) { + return result; + } + result = ObjectUtils.compare(version, other.version); if (result != 0) { return result; diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java index 0293bd3c5..5f523ad27 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java @@ -29,7 +29,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Queue; import java.util.UUID; import java.util.function.Function; import java.util.function.UnaryOperator; @@ -71,7 +70,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class AcmUtils { public static final String ENTRY = "entry "; - private static StringToMapConverter MAP_CONVERTER = new StringToMapConverter(); + private static final StringToMapConverter MAP_CONVERTER = new StringToMapConverter(); /** * Get the Policy information in the service template for the deploy message to participants. @@ -379,6 +378,7 @@ public final class AcmUtils { final DeployState deployState, final LockState lockState) { automationComposition.setDeployState(deployState); automationComposition.setLockState(lockState); + automationComposition.setLastMsg(TimestampHelper.now()); if (MapUtils.isEmpty(automationComposition.getElements())) { return; -- cgit 1.2.3-korg