From 2c094b95c86f3315e359d971fbfa0ad60d173053 Mon Sep 17 00:00:00 2001 From: Sirisha_Manchikanti Date: Tue, 3 Aug 2021 17:49:00 +0100 Subject: 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 Change-Id: Ied32ea5bb63a6b69286d03f1a7b2b86e3acad7a7 --- .../runtime/supervision/SupervisionHandler.java | 40 ++++++---------------- 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'runtime-controlloop/src/main') 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 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()); } } -- cgit 1.2.3-korg