diff options
author | Liam Fallon <liam.fallon@est.tech> | 2021-09-08 09:00:36 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-09-08 09:00:36 +0000 |
commit | 22b02a0536c4cad7fb6d1a838df197415682fef2 (patch) | |
tree | 936b7454011a17f8d20fc26a281996b5b0a19b23 /participant/participant-intermediary/src | |
parent | b35be71f283c75d937619651ef086047349e93f4 (diff) | |
parent | 1df4475d60d9c6d46087f8284dd2e0697d59c071 (diff) |
Merge "Fix parsing of type heirarchy for nodetypes"
Diffstat (limited to 'participant/participant-intermediary/src')
5 files changed, 34 insertions, 11 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java index 4dd978f0f..58378fa41 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ControlLoopElementListener.java @@ -25,6 +25,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState; import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; /** @@ -39,8 +40,8 @@ public interface ControlLoopElementListener { * @param newState the state to which the control loop element is changing to * @throws PfModelException in case of a model exception */ - public void controlLoopElementStateChange(UUID controlLoopElementId, ControlLoopState currentState, - ControlLoopOrderedState newState) throws PfModelException; + public void controlLoopElementStateChange(ToscaConceptIdentifier controlLoopId, UUID controlLoopElementId, + ControlLoopState currentState, ControlLoopOrderedState newState) throws PfModelException; /** * Handle an update on a control loop element. @@ -49,7 +50,7 @@ public interface ControlLoopElementListener { * @param controlLoopElementDefinition toscaNodeTemplate * @throws PfModelException from Policy framework */ - public void controlLoopElementUpdate(ControlLoopElement element, + public void controlLoopElementUpdate(ToscaConceptIdentifier controlLoopId, ControlLoopElement element, ToscaNodeTemplate controlLoopElementDefinition) throws PfModelException; /** diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java index 7292f8ddc..3859e0c39 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java @@ -116,7 +116,8 @@ public interface ParticipantIntermediaryApi { * @param newState the state of the control loop element * @return ControlLoopElement updated control loop element */ - ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState currentState, + ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId, + UUID id, ControlLoopOrderedState currentState, ControlLoopState newState, ParticipantMessageType messageType); /** diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java index f8ef8d506..1f79d7179 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java @@ -122,9 +122,11 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp } @Override - public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState currentState, + public ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId, + UUID id, ControlLoopOrderedState currentState, ControlLoopState newState, ParticipantMessageType messageType) { - return participantHandler.getControlLoopHandler().updateControlLoopElementState(id, currentState, newState); + return participantHandler.getControlLoopHandler().updateControlLoopElementState(controlLoopId, + id, currentState, newState); } @Override diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java index 9cd032a54..6e1b31cfe 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java @@ -45,6 +45,7 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener; import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher; import org.onap.policy.clamp.controlloop.participant.intermediary.parameters.ParticipantParameters; +import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate; @@ -96,7 +97,8 @@ public class ControlLoopHandler { * @param newState the ordered state * @return controlLoopElement the updated controlloop element */ - public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState orderedState, + public ControlLoopElement updateControlLoopElementState(ToscaConceptIdentifier controlLoopId, + UUID id, ControlLoopOrderedState orderedState, ControlLoopState newState) { if (id == null) { @@ -104,15 +106,24 @@ public class ControlLoopHandler { } ControlLoopElement clElement = elementsOnThisParticipant.get(id); + for (var controlLoop : controlLoopMap.values()) { + var element = controlLoop.getElements().get(id); + if (element != null) { + element.setState(newState); + } + } + if (clElement != null) { var controlLoopStateChangeAck = new ControlLoopAck(ParticipantMessageType.CONTROLLOOP_STATECHANGE_ACK); controlLoopStateChangeAck.setParticipantId(participantId); controlLoopStateChangeAck.setParticipantType(participantType); + controlLoopStateChangeAck.setControlLoopId(controlLoopId); clElement.setOrderedState(orderedState); clElement.setState(newState); controlLoopStateChangeAck.getControlLoopResultMap().put(clElement.getId(), - new ControlLoopElementAck(true, "Control loop element {} state changed to {}\", id, newState)")); + new ControlLoopElementAck(newState, true, + "Control loop element {} state changed to {}\", id, newState)")); LOGGER.debug("Control loop element {} state changed to {}", id, newState); controlLoopStateChangeAck.setMessage("ControlLoopElement state changed to {} " + newState); controlLoopStateChangeAck.setResult(true); @@ -219,6 +230,11 @@ public class ControlLoopHandler { return; } + if (updateMsg.getParticipantUpdatesList().isEmpty()) { + LOGGER.warn("No ControlLoopElement updates in message {}", updateMsg.getControlLoopId()); + return; + } + List<ControlLoopElement> clElements = storeElementsOnThisParticipant(updateMsg.getParticipantUpdatesList()); try { @@ -226,7 +242,8 @@ public class ControlLoopHandler { ToscaNodeTemplate clElementNodeTemplate = getClElementNodeTemplate( clElementDefinitions, element.getDefinition()); for (ControlLoopElementListener clElementListener : listeners) { - clElementListener.controlLoopElementUpdate(element, clElementNodeTemplate); + clElementListener.controlLoopElementUpdate(updateMsg.getControlLoopId(), + element, clElementNodeTemplate); } } } catch (PfModelException e) { @@ -284,7 +301,8 @@ public class ControlLoopHandler { for (ControlLoopElementListener clElementListener : listeners) { try { for (ControlLoopElement element : controlLoop.getElements().values()) { - clElementListener.controlLoopElementStateChange(element.getId(), element.getState(), orderedState); + clElementListener.controlLoopElementStateChange(controlLoop.getDefinition(), + element.getId(), element.getState(), orderedState); } } catch (PfModelException e) { LOGGER.debug("Control loop element update failed {}", controlLoop.getDefinition()); diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java index 072a2ebc1..19641b0d5 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java @@ -301,6 +301,7 @@ public class ParticipantHandler { } else { // This message is to decommision the controlloop clElementDefsOnThisParticipant.clear(); + this.state = ParticipantState.TERMINATED; } sendParticipantUpdateAck(participantUpdateMsg.getMessageId()); } @@ -315,7 +316,7 @@ public class ParticipantHandler { participantUpdateAck.setResult(true); participantUpdateAck.setParticipantId(participantId); participantUpdateAck.setParticipantType(participantType); - + participantUpdateAck.setState(state); publisher.sendParticipantUpdateAck(participantUpdateAck); } |