summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-09-13 14:52:59 +0100
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-09-13 15:02:07 +0100
commit62f6da46ddfa744f0dae7cd673e4aeb9b84e9bb6 (patch)
tree61ddddc84d99d072aaabd524537a3a91db5783a5 /runtime-controlloop
parent859749a4143c104f6bd63392c8d2cb2839408029 (diff)
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 <sirisha.manchikanti@est.tech> Change-Id: I9c6c028be4c15922717795e2a53cb53d02579dcc
Diffstat (limited to 'runtime-controlloop')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java18
1 files changed, 18 insertions, 0 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 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());
}