diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-06-14 13:57:07 +0100 |
---|---|---|
committer | Adheli Tavares <adheli.tavares@est.tech> | 2023-06-15 15:01:34 +0000 |
commit | a2320d29b9373041db88395d9fdda7ea84d38807 (patch) | |
tree | 4088c3e0941bcf4d2988a503471c55db4085986d /participant/participant-intermediary/src/main/java | |
parent | dd44112fcda0951dc76861cacfdabbffc9fe8579 (diff) |
Add support for Prime Deprime Failure Handling in Intermediary
Issue-ID: POLICY-4715
Change-Id: Iab48e6c32c7aedcef9773614a61436398b059a49
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/main/java')
4 files changed, 55 insertions, 21 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java index 592513258..96d96cac9 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java @@ -46,7 +46,6 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp private final AutomationCompositionOutHandler automationCompositionHandler; private final CacheProvider cacheProvider; - @Override public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState newState, LockState lockState, StateChangeResult stateChangeResult, String message) { @@ -69,6 +68,6 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp @Override public void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult, String message) { - // TODO Auto-generated method stub + automationCompositionHandler.updateCompositionState(compositionId, state, stateChangeResult, message); } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java index 0fcd5ecc4..7e713654d 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java @@ -28,6 +28,7 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationComposit import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy; import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeploy; @@ -201,8 +202,7 @@ public class AutomationCompositionHandler { public void handleAutomationCompositionDeploy(AutomationCompositionDeploy deployMsg) { if (deployMsg.getParticipantUpdatesList().isEmpty()) { - LOGGER.warn("No AutomationCompositionElement deploy in message {}", - deployMsg.getAutomationCompositionId()); + LOGGER.warn("No AutomationCompositionElement deploy in message {}", deployMsg.getAutomationCompositionId()); return; } @@ -325,4 +325,31 @@ public class AutomationCompositionHandler { LOGGER.debug("Automation composition element Unlock failed {}", automationComposition.getInstanceId()); } } + + /** + * Handles prime a Composition Definition. + * + * @param compositionId the compositionId + * @param list the list of AutomationCompositionElementDefinition + */ + public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> list) { + try { + listener.prime(compositionId, list); + } catch (PfModelException e) { + LOGGER.debug("Composition prime failed {}", compositionId); + } + } + + /** + * Handles deprime a Composition Definition. + * + * @param compositionId the compositionId + */ + public void deprime(UUID compositionId) { + try { + listener.deprime(compositionId); + } catch (PfModelException e) { + LOGGER.debug("Composition deprime failed {}", compositionId); + } + } } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java index 665baee42..2c34652c8 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java @@ -26,6 +26,7 @@ import java.util.UUID; import lombok.RequiredArgsConstructor; import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; import org.onap.policy.clamp.models.acm.concepts.AcElementDeployAck; +import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementInfo; @@ -36,6 +37,7 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantState; import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeployAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageType; +import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -196,4 +198,25 @@ public class AutomationCompositionOutHandler { elementInfo.setOutProperties(element.getOutProperties()); return elementInfo; } + + /** + * Update Composition State for prime and deprime. + * + * @param compositionId the composition id + * @param state the Composition State + * @param stateChangeResult the indicator if error occurs + * @param message the message + */ + public void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult, + String message) { + var participantPrimeAck = new ParticipantPrimeAck(); + participantPrimeAck.setCompositionId(compositionId); + participantPrimeAck.setMessage(message); + participantPrimeAck.setResult(true); + participantPrimeAck.setCompositionState(state); + participantPrimeAck.setStateChangeResult(stateChangeResult); + participantPrimeAck.setParticipantId(cacheProvider.getParticipantId()); + participantPrimeAck.setState(ParticipantState.ON_LINE); + publisher.sendParticipantPrimeAck(participantPrimeAck); + } } 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 1e5caad15..0e7e193f6 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 @@ -25,7 +25,6 @@ package org.onap.policy.clamp.acm.participant.intermediary.handler; import io.micrometer.core.annotation.Timed; import java.util.ArrayList; import java.util.List; -import java.util.UUID; import lombok.RequiredArgsConstructor; import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessagePublisher; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; @@ -39,7 +38,6 @@ import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDe import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantDeregisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessage; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrime; -import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantPrimeAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegister; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRegisterAck; import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantStatus; @@ -188,25 +186,12 @@ public class ParticipantHandler { } } cacheProvider.addElementDefinition(participantPrimeMsg.getCompositionId(), list); + automationCompositionHandler.prime(participantPrimeMsg.getCompositionId(), list); } else { // deprime cacheProvider.removeElementDefinition(participantPrimeMsg.getCompositionId()); + automationCompositionHandler.deprime(participantPrimeMsg.getCompositionId()); } - sendParticipantPrimeAck(participantPrimeMsg.getMessageId(), participantPrimeMsg.getCompositionId()); - } - - /** - * Method to send ParticipantPrimeAck message to automation composition runtime. - */ - private void sendParticipantPrimeAck(UUID messageId, UUID compositionId) { - var participantPrimeAck = new ParticipantPrimeAck(); - participantPrimeAck.setResponseTo(messageId); - participantPrimeAck.setCompositionId(compositionId); - participantPrimeAck.setMessage("Participant Prime Ack message"); - participantPrimeAck.setResult(true); - participantPrimeAck.setParticipantId(cacheProvider.getParticipantId()); - participantPrimeAck.setState(ParticipantState.ON_LINE); - publisher.sendParticipantPrimeAck(participantPrimeAck); } /** |