diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2021-09-30 11:28:28 +0100 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2021-10-04 14:26:37 +0100 |
commit | 1ead22e0bf08c7cd95e900267f4ba89e131b7f36 (patch) | |
tree | bfbfc5c8f498fa8ecce3fd719fdd6caae46259a4 /runtime-controlloop/src/main/java/org/onap | |
parent | 7c4cea7c3ee9031092facf20ff8df937d56d2c2e (diff) |
Fix startPhase delay
Issue-ID: POLICY-3624
Change-Id: Ie7e25ddc3796324246f267dd0c92b9bc1fe15aa2
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
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); + } + } } |