diff options
author | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-08-03 17:49:00 +0100 |
---|---|---|
committer | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-08-04 14:35:55 +0100 |
commit | 2c094b95c86f3315e359d971fbfa0ad60d173053 (patch) | |
tree | bd4b33f1e28ad3fad8769b3a36a51e4f89a63dea /runtime-controlloop/src/main | |
parent | 055fa4ad38a11bb5890b6e0ea280e9b96a1b2a39 (diff) |
Update controlloop messages
Updated controlloop messages according to
https://wiki.onap.org/display/DW/The+CLAMP+Control+Loop+Participant+Protocol
Issue-ID: POLICY-3417
Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech>
Change-Id: Ied32ea5bb63a6b69286d03f1a7b2b86e3acad7a7
Diffstat (limited to 'runtime-controlloop/src/main')
-rw-r--r-- | runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java index dadfe0de2..16dba0f07 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java @@ -21,12 +21,14 @@ package org.onap.policy.clamp.controlloop.runtime.supervision; import java.util.List; +import java.util.Map; import javax.ws.rs.core.Response; import lombok.AllArgsConstructor; import org.apache.commons.collections4.CollectionUtils; import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; @@ -310,39 +312,17 @@ public class SupervisionHandler { private void superviseControlLoops(ParticipantStatus participantStatusMessage) throws PfModelException, ControlLoopException { - if (CollectionUtils.isEmpty(participantStatusMessage.getControlLoops().getControlLoopList())) { - return; - } - - for (ControlLoop controlLoop : participantStatusMessage.getControlLoops().getControlLoopList()) { - if (controlLoop == null) { - exceptionOccured(Response.Status.NOT_FOUND, - "PARTICIPANT_STATUS message references unknown control loop: " + controlLoop); - } - - var dbControlLoop = controlLoopProvider - .getControlLoop(new ToscaConceptIdentifier(controlLoop.getName(), controlLoop.getVersion())); + for (Map.Entry<ToscaConceptIdentifier, ControlLoopInfo> clEntry : + participantStatusMessage.getControlLoopInfoMap().entrySet()) { + var dbControlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier( + clEntry.getKey().getName(), clEntry.getKey().getVersion())); if (dbControlLoop == null) { exceptionOccured(Response.Status.NOT_FOUND, - "PARTICIPANT_STATUS control loop not found in database: " + controlLoop); + "PARTICIPANT_STATUS control loop not found in database: " + clEntry.getKey()); } - - for (ControlLoopElement element : controlLoop.getElements().values()) { - ControlLoopElement dbElement = dbControlLoop.getElements().get(element.getId()); - - if (dbElement == null) { - exceptionOccured(Response.Status.NOT_FOUND, - "PARTICIPANT_STATUS message references unknown control loop element: " + element); - } - - // Replace element entry in the database - dbControlLoop.getElements().put(element.getId(), element); - } - controlLoopProvider.updateControlLoop(dbControlLoop); - } - - for (ControlLoop controlLoop : participantStatusMessage.getControlLoops().getControlLoopList()) { - monitoringProvider.createClElementStatistics(controlLoop.getControlLoopElementStatisticsList(controlLoop)); + dbControlLoop.setState(clEntry.getValue().getState()); + monitoringProvider.createClElementStatistics(clEntry.getValue() + .getControlLoopStatistics().getClElementStatisticsList().getClElementStatistics()); } } |