aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/main
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2021-10-22 13:52:24 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2021-10-22 13:44:03 +0000
commit7ac38590a5c6d80f2aa4d7697ce3735f4a1a8132 (patch)
tree739c19376b36a460be4e44771f1da7499e2ec6a9 /models/src/main
parent962a9d16895c9ae75230cad5c7d8a1d4e453f2ad (diff)
Add support startPhase in all state transitions
Issue-ID: POLICY-3785 Change-Id: I1b5821cc42cdbb63e3172596431dc561ced09c55 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'models/src/main')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java
index 4c3dd4b06..c05311892 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ParticipantUtils.java
@@ -57,6 +57,30 @@ public final class ParticipantUtils {
}
/**
+ * Get the First StartPhase
+ * it depend of the state of the Control Loop
+ * and also from the all startPhase defined into the ToscaServiceTemplate.
+ * @param controlLoop the ControlLoop
+ * @param toscaServiceTemplate the ToscaServiceTemplate
+ * @return the First StartPhase
+ */
+ public static int getFirstStartPhase(ControlLoop controlLoop, ToscaServiceTemplate toscaServiceTemplate) {
+ var minStartPhase = 1000;
+ var maxStartPhase = 0;
+ for (var element : controlLoop.getElements().values()) {
+ ToscaNodeTemplate toscaNodeTemplate = toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates()
+ .get(element.getDefinition().getName());
+ int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties());
+ minStartPhase = Math.min(minStartPhase, startPhase);
+ maxStartPhase = Math.max(maxStartPhase, startPhase);
+ }
+
+ return ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())
+ || ControlLoopState.PASSIVE2RUNNING.equals(controlLoop.getState()) ? minStartPhase
+ : maxStartPhase;
+ }
+
+ /**
* Finds startPhase from a map of properties.
*
* @param properties Map of properties