diff options
author | Liam Fallon <liam.fallon@est.tech> | 2021-10-05 13:30:36 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-10-05 13:30:36 +0000 |
commit | c82dcd7379883b473bb36d876bdea44502512e4b (patch) | |
tree | 7ab459f131075498874f94cebbe4d6e598394646 /runtime-controlloop/src/main/java/org/onap | |
parent | 3a194e4bb22c3a2708ed1817e2aba622c8d7765a (diff) | |
parent | 1ead22e0bf08c7cd95e900267f4ba89e131b7f36 (diff) |
Merge "Fix startPhase delay"
Diffstat (limited to 'runtime-controlloop/src/main/java/org/onap')
-rw-r--r-- | runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java index 684711677..df7efbe9c 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java @@ -22,7 +22,9 @@ package org.onap.policy.clamp.controlloop.runtime.supervision; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.commons.lang3.tuple.Pair; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; @@ -53,11 +55,13 @@ import org.springframework.stereotype.Component; public class SupervisionScanner { private static final Logger LOGGER = LoggerFactory.getLogger(SupervisionScanner.class); - private HandleCounter<ToscaConceptIdentifier> controlLoopCounter = new HandleCounter<>(); - private HandleCounter<ToscaConceptIdentifier> participantStatusCounter = new HandleCounter<>(); - private HandleCounter<Pair<ToscaConceptIdentifier, ToscaConceptIdentifier>> participantUpdateCounter = + private final HandleCounter<ToscaConceptIdentifier> controlLoopCounter = new HandleCounter<>(); + private final HandleCounter<ToscaConceptIdentifier> participantStatusCounter = new HandleCounter<>(); + private final HandleCounter<Pair<ToscaConceptIdentifier, ToscaConceptIdentifier>> participantUpdateCounter = new HandleCounter<>(); + private final Map<ToscaConceptIdentifier, Integer> phaseMap = new HashMap<>(); + private final ControlLoopProvider controlLoopProvider; private final PolicyModelsProvider modelsProvider; private final ControlLoopStateChangePublisher controlLoopStateChangePublisher; @@ -224,7 +228,6 @@ public class SupervisionScanner { int startPhase = ParticipantUtils.findStartPhase(toscaNodeTemplate.getProperties()); minSpNotCompleted = Math.min(minSpNotCompleted, startPhase); } - } if (completed) { @@ -239,7 +242,12 @@ public class SupervisionScanner { } else { LOGGER.debug("control loop scan: transition from state {} to {} not completed", controlLoop.getState(), controlLoop.getOrderedState()); - if (counterCheck) { + + if (minSpNotCompleted != phaseMap.getOrDefault(controlLoop.getKey().asIdentifier(), 0) + && ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())) { + phaseMap.put(controlLoop.getKey().asIdentifier(), minSpNotCompleted); + sendControlLoopMsg(controlLoop, minSpNotCompleted); + } else if (counterCheck) { handleCounter(controlLoop, minSpNotCompleted); } } @@ -247,6 +255,7 @@ public class SupervisionScanner { private void clearFaultAndCounter(ControlLoop controlLoop) { controlLoopCounter.clear(controlLoop.getKey().asIdentifier()); + phaseMap.clear(); } private void handleCounter(ControlLoop controlLoop, int startPhase) { @@ -258,17 +267,22 @@ public class SupervisionScanner { if (controlLoopCounter.getDuration(id) > controlLoopCounter.getMaxWaitMs()) { if (controlLoopCounter.count(id)) { - if (ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())) { - LOGGER.debug("retry message ControlLoopUpdate"); - controlLoopUpdatePublisher.send(controlLoop, startPhase); - } else { - LOGGER.debug("retry message ControlLoopStateChange"); - controlLoopStateChangePublisher.send(controlLoop); - } + phaseMap.put(id, startPhase); + sendControlLoopMsg(controlLoop, startPhase); } else { LOGGER.debug("report ControlLoop fault"); controlLoopCounter.setFault(id); } } } + + private void sendControlLoopMsg(ControlLoop controlLoop, int startPhase) { + if (ControlLoopState.UNINITIALISED2PASSIVE.equals(controlLoop.getState())) { + LOGGER.debug("retry message ControlLoopUpdate"); + controlLoopUpdatePublisher.send(controlLoop, startPhase); + } else { + LOGGER.debug("retry message ControlLoopStateChange"); + controlLoopStateChangePublisher.send(controlLoop); + } + } } |