From 62f6da46ddfa744f0dae7cd673e4aeb9b84e9bb6 Mon Sep 17 00:00:00 2001 From: Sirisha_Manchikanti Date: Mon, 13 Sep 2021 14:52:59 +0100 Subject: Update participant state and health in DB Update the state and health-status of a participant in database to TERMINATED and OFF_LINE respectively when there is a ParticipantDeregister message from any of the participants. Issue-ID: POLICY-3578 Signed-off-by: Sirisha_Manchikanti Change-Id: I9c6c028be4c15922717795e2a53cb53d02579dcc --- .../runtime/supervision/SupervisionHandler.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'runtime-controlloop/src') 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 a426cac4a..dbc2c4ea6 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 @@ -34,6 +34,8 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop 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.concepts.ParticipantHealthStatus; +import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantState; import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider; import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; @@ -159,6 +161,22 @@ public class SupervisionHandler { @MessageIntercept public void handleParticipantMessage(ParticipantDeregister participantDeregisterMessage) { LOGGER.debug("Participant Deregister received {}", participantDeregisterMessage); + try { + var participantList = + participantProvider.getParticipants(participantDeregisterMessage.getParticipantId().getName(), + participantDeregisterMessage.getParticipantId().getVersion()); + + if (participantList != null) { + for (Participant participant : participantList) { + participant.setParticipantState(ParticipantState.TERMINATED); + participant.setHealthStatus(ParticipantHealthStatus.OFF_LINE); + } + participantProvider.updateParticipants(participantList); + } + } catch (PfModelException pfme) { + LOGGER.warn("Model exception occured {}", participantDeregisterMessage.getParticipantId()); + } + participantDeregisterAckPublisher.send(participantDeregisterMessage.getMessageId()); } -- cgit 1.2.3-korg