From 3971c419e094cb149c3e01781343d6265af64db6 Mon Sep 17 00:00:00 2001 From: Sirisha_Manchikanti Date: Fri, 20 Aug 2021 17:21:11 +0100 Subject: Updated handling of ack messages Issue-ID: POLICY-3417 Signed-off-by: Sirisha_Manchikanti Change-Id: I5784debf2e17fd1018b3feb7c9e2ae08d5f93d23 --- .../runtime/supervision/SupervisionHandler.java | 21 +++++++ .../comm/ControlLoopStateChangeAckListener.java | 67 ++++++++++++++++++++++ .../comm/ControlLoopUpdateAckListener.java | 67 ++++++++++++++++++++++ .../comm/ControlLoopUpdatePublisher.java | 4 -- .../comm/ParticipantUpdatePublisher.java | 6 +- 5 files changed, 158 insertions(+), 7 deletions(-) create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java create mode 100644 runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java (limited to 'runtime-controlloop/src/main/java/org/onap') 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 7cc5d7fee..561d4fdf5 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 @@ -31,6 +31,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant; 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; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus; @@ -189,6 +190,26 @@ public class SupervisionHandler { participantUpdateMessage.getParticipantType(), false); } + /** + * Handle a ControlLoop update acknowledge message from a participant. + * + * @param controlLoopAckMessage the ControlLoopAck message received from a participant + */ + @MessageIntercept + public void handleControlLoopUpdateAckMessage(ControlLoopAck controlLoopAckMessage) { + LOGGER.debug("ControlLoop Update Ack message received {}", controlLoopAckMessage); + } + + /** + * Handle a ControlLoop statechange acknowledge message from a participant. + * + * @param controlLoopAckMessage the ControlLoopAck message received from a participant + */ + @MessageIntercept + public void handleControlLoopStateChangeAckMessage(ControlLoopAck controlLoopAckMessage) { + LOGGER.debug("ControlLoop StateChange Ack message received {}", controlLoopAckMessage); + } + /** * Supervise a control loop, performing whatever actions need to be performed on the control loop. * diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java new file mode 100644 index 000000000..dd08b7a0f --- /dev/null +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopStateChangeAckListener.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.runtime.supervision.comm; + +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener; +import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Listener for ControlLoopStateChangeAck messages sent by participants. + */ +@Component +public class ControlLoopStateChangeAckListener extends ScoListener implements Listener { + private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopStateChangeAckListener.class); + + private final SupervisionHandler supervisionHandler; + + /** + * Constructs the object. + */ + public ControlLoopStateChangeAckListener(SupervisionHandler supervisionHandler) { + super(ControlLoopAck.class); + this.supervisionHandler = supervisionHandler; + } + + @Override + public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, + final ControlLoopAck controlLoopStateChangeAckMessage) { + LOGGER.debug("ControlLoopStateChangeAck received from participant - {}", controlLoopStateChangeAckMessage); + supervisionHandler.handleControlLoopStateChangeAckMessage(controlLoopStateChangeAckMessage); + } + + @Override + public ScoListener getScoListener() { + return this; + } + + @Override + public String getType() { + return ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK.name(); + } +} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java new file mode 100644 index 000000000..2f14dc8f5 --- /dev/null +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdateAckListener.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.clamp.controlloop.runtime.supervision.comm; + +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopAck; +import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.controlloop.runtime.config.messaging.Listener; +import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler; +import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; +import org.onap.policy.common.endpoints.listeners.ScoListener; +import org.onap.policy.common.utils.coder.StandardCoderObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * Listener for ControlLoopUpdateAck messages sent by participants. + */ +@Component +public class ControlLoopUpdateAckListener extends ScoListener implements Listener { + private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopUpdateAckListener.class); + + private final SupervisionHandler supervisionHandler; + + /** + * Constructs the object. + */ + public ControlLoopUpdateAckListener(SupervisionHandler supervisionHandler) { + super(ControlLoopAck.class); + this.supervisionHandler = supervisionHandler; + } + + @Override + public void onTopicEvent(final CommInfrastructure infra, final String topic, final StandardCoderObject sco, + final ControlLoopAck controlLoopUpdateAckMessage) { + LOGGER.debug("ControlLoopUpdateAck message received from participant - {}", controlLoopUpdateAckMessage); + supervisionHandler.handleControlLoopUpdateAckMessage(controlLoopUpdateAckMessage); + } + + @Override + public ScoListener getScoListener() { + return this; + } + + @Override + public String getType() { + return ParticipantMessageType.CONTROLLOOP_UPDATE_ACK.name(); + } +} diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java index be9a2a27d..35219bb68 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ControlLoopUpdatePublisher.java @@ -22,17 +22,13 @@ package org.onap.policy.clamp.controlloop.runtime.supervision.comm; import java.time.Instant; import java.util.ArrayList; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; import java.util.UUID; import lombok.AllArgsConstructor; 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.ParticipantDefinition; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java index d5dc4a6d0..d239f38cb 100644 --- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java +++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java @@ -49,9 +49,9 @@ import org.springframework.stereotype.Component; public class ParticipantUpdatePublisher extends AbstractParticipantPublisher { private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdatePublisher.class); - private static final String CONTROL_LOOP_ELEMENT = "ControlLoopElement"; - private final PolicyModelsProvider modelsProvider; + private static final String CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.ControlLoopElement"; private static final Coder CODER = new StandardCoder(); + private final PolicyModelsProvider modelsProvider; /** * Send ParticipantUpdate to Participant. @@ -60,7 +60,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher