From 026cfefbe02cfc87c04f13d4b5ce7085f3ee360b Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Wed, 4 Jan 2023 17:04:37 +0000 Subject: Refactor register deregister a Participant and Supervise Participants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor register deregister a Participant and Supervise Participants using ON_LINE/OFF_LINE as Participant Status. Issue-ID: POLICY-4497 Change-Id: If9c5b92131c99132c18340e56334fb9453745526 Signed-off-by: FrancescoFioraEst --- .../intermediary/handler/ParticipantHandler.java | 29 +++------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'participant') diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java index b442b9967..6edf1ffd4 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2022 Nordix Foundation. + * Copyright (C) 2021-2023 Nordix Foundation. * ================================================================================ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -29,13 +29,11 @@ import java.util.List; import java.util.Map; import java.util.UUID; import lombok.Getter; -import lombok.Setter; import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; import org.onap.policy.clamp.acm.participant.intermediary.parameters.ParticipantParameters; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo; import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition; -import org.onap.policy.clamp.models.acm.concepts.ParticipantHealthStatus; import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionUpdate; @@ -70,12 +68,6 @@ public class ParticipantHandler { private final AutomationCompositionHandler automationCompositionHandler; private final ParticipantMessagePublisher publisher; - @Setter - private ParticipantState state = ParticipantState.UNKNOWN; - - @Setter - private ParticipantHealthStatus healthStatus = ParticipantHealthStatus.UNKNOWN; - private final Map> acElementDefsMap = new HashMap<>(); /** @@ -169,21 +161,9 @@ public class ParticipantHandler { public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) { LOGGER.debug("ParticipantRegisterAck message received as responseTo {}", participantRegisterAckMsg.getResponseTo()); - statusToPassive(); publisher.sendParticipantStatus(makeHeartbeat(false)); } - private void statusToPassive() { - if (ParticipantHealthStatus.UNKNOWN.equals(this.healthStatus)) { - this.healthStatus = ParticipantHealthStatus.HEALTHY; - } - - if (ParticipantState.UNKNOWN.equals(this.state) || ParticipantState.TERMINATED.equals(this.state)) { - this.state = ParticipantState.PASSIVE; - } - - } - /** * Method to send ParticipantDeregister message to automation composition runtime. */ @@ -218,7 +198,6 @@ public class ParticipantHandler { acElementDefsMap.putIfAbsent(participantUpdateMsg.getCompositionId(), new ArrayList<>()); if (!participantUpdateMsg.getParticipantDefinitionUpdates().isEmpty()) { - statusToPassive(); // This message is to commission the automation composition for (var participantDefinition : participantUpdateMsg.getParticipantDefinitionUpdates()) { if (participantDefinition.getParticipantType().equals(participantType)) { @@ -230,7 +209,6 @@ public class ParticipantHandler { } else { // This message is to decommission the automation composition acElementDefsMap.get(participantUpdateMsg.getCompositionId()).clear(); - this.state = ParticipantState.TERMINATED; } sendParticipantUpdateAck(participantUpdateMsg.getMessageId()); } @@ -245,7 +223,7 @@ public class ParticipantHandler { participantUpdateAck.setResult(true); participantUpdateAck.setParticipantId(participantId); participantUpdateAck.setParticipantType(participantType); - participantUpdateAck.setState(state); + participantUpdateAck.setState(ParticipantState.ON_LINE); publisher.sendParticipantUpdateAck(participantUpdateAck); } @@ -263,8 +241,7 @@ public class ParticipantHandler { var heartbeat = new ParticipantStatus(); heartbeat.setParticipantId(participantId); heartbeat.setParticipantType(participantType); - heartbeat.setHealthStatus(healthStatus); - heartbeat.setState(state); + heartbeat.setState(ParticipantState.ON_LINE); heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList()); if (responseToParticipantStatusReq) { -- cgit 1.2.3-korg