aboutsummaryrefslogtreecommitdiffstats
path: root/models/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'models/src/main/java')
-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