summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src/main/java/org
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-08-03 14:10:30 +0100
committerFrancescoFioraEst <francesco.fiora@est.tech>2023-08-03 15:56:26 +0100
commit99416bab41ce90c7931fcf92b042296ba8b9e2e0 (patch)
tree5a887c1a5dd25ff97068e260d78123832ce7a5b0 /participant/participant-intermediary/src/main/java/org
parent11f667ee4453fcd4013b67257550e65d075f2b0c (diff)
Add support for composition outProperties in ACM intermediary
Issue-ID: POLICY-4783 Change-Id: Ib0c89298a29a3524787e11ff7e25d3d22d01b534 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src/main/java/org')
-rwxr-xr-x[-rw-r--r--]participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java19
-rwxr-xr-x[-rw-r--r--]participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java41
-rwxr-xr-xparticipant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java68
-rwxr-xr-xparticipant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java24
4 files changed, 126 insertions, 26 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
index 8b800a8fd..bca5f4830 100644..100755
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
@@ -26,9 +26,11 @@ import java.util.UUID;
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.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
/**
* This interface is used by participant implementations to use the participant intermediary.
@@ -56,6 +58,14 @@ public interface ParticipantIntermediaryApi {
Map<UUID, AutomationComposition> getAutomationCompositions();
/**
+ * Get a copy of the AutomationComposition by automationCompositionId.
+ *
+ * @param automationCompositionId the ID of the automation composition to update the state on
+ * @return get the AutomationComposition
+ */
+ AutomationComposition getAutomationComposition(UUID automationCompositionId);
+
+ /**
* Get a copy of the AutomationCompositionElement by automationCompositionId and elementId.
*
* @param automationCompositionId the ID of the automation composition to update the state on
@@ -64,6 +74,13 @@ public interface ParticipantIntermediaryApi {
*/
AutomationCompositionElement getAutomationCompositionElement(UUID automationCompositionId, UUID elementId);
+ Map<UUID, Map<ToscaConceptIdentifier, AutomationCompositionElementDefinition>> getAcElementsDefinitions();
+
+ Map<ToscaConceptIdentifier, AutomationCompositionElementDefinition> getAcElementsDefinitions(UUID compositionId);
+
+ AutomationCompositionElementDefinition getAcElementDefinition(UUID compositionId,
+ ToscaConceptIdentifier elementId);
+
/**
* Send Automation Composition Element update Info to AC-runtime.
*
@@ -76,6 +93,8 @@ public interface ParticipantIntermediaryApi {
void sendAcElementInfo(UUID automationCompositionId, UUID id, String useState, String operationalState,
Map<String, Object> outProperties);
+ void sendAcDefinitionInfo(UUID compositionId, ToscaConceptIdentifier elementId, Map<String, Object> outProperties);
+
void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult,
String message);
}
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 ca5f08793..5cdbacab6 100644..100755
--- 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
@@ -30,10 +30,12 @@ import org.onap.policy.clamp.acm.participant.intermediary.handler.CacheProvider;
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.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.models.base.PfUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.springframework.stereotype.Component;
/**
@@ -81,4 +83,43 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
var element = automationComposition.getElements().get(elementId);
return element != null ? new AutomationCompositionElement(element) : null;
}
+
+ @Override
+ public void sendAcDefinitionInfo(UUID compositionId, ToscaConceptIdentifier elementId,
+ Map<String, Object> outProperties) {
+ automationCompositionHandler.sendAcDefinitionInfo(compositionId, elementId, outProperties);
+ }
+
+ @Override
+ public AutomationComposition getAutomationComposition(UUID automationCompositionId) {
+ var automationComposition = cacheProvider.getAutomationCompositions().get(automationCompositionId);
+ return automationComposition != null ? new AutomationComposition(automationComposition) : null;
+ }
+
+ @Override
+ public Map<UUID, Map<ToscaConceptIdentifier, AutomationCompositionElementDefinition>> getAcElementsDefinitions() {
+ return PfUtils.mapMap(cacheProvider.getAcElementsDefinitions(),
+ map -> PfUtils.mapMap(map, AutomationCompositionElementDefinition::new));
+ }
+
+ @Override
+ public Map<ToscaConceptIdentifier, AutomationCompositionElementDefinition> getAcElementsDefinitions(
+ UUID compositionId) {
+ var acElementDefinitions = cacheProvider.getAcElementsDefinitions().get(compositionId);
+ if (acElementDefinitions == null) {
+ return null;
+ }
+ return PfUtils.mapMap(acElementDefinitions, AutomationCompositionElementDefinition::new);
+ }
+
+ @Override
+ public AutomationCompositionElementDefinition getAcElementDefinition(UUID compositionId,
+ ToscaConceptIdentifier elementId) {
+ var acElementDefinitions = cacheProvider.getAcElementsDefinitions().get(compositionId);
+ if (acElementDefinitions == null) {
+ return null;
+ }
+ var acElementDefinition = acElementDefinitions.get(elementId);
+ return acElementDefinition != null ? new AutomationCompositionElementDefinition(acElementDefinition) : null;
+ }
}
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 bd5f1427e..3023cddda 100755
--- 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
@@ -29,16 +29,19 @@ 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.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementInfo;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
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.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -159,29 +162,27 @@ public class AutomationCompositionOutHandler {
var automationComposition = cacheProvider.getAutomationComposition(automationCompositionId);
if (automationComposition == null) {
LOGGER.error("Cannot update Automation composition element state, Automation composition id {} not present",
- automationComposition);
+ automationCompositionId);
return;
}
var element = automationComposition.getElements().get(elementId);
if (element == null) {
var msg = "Cannot update Automation composition element state, AC Element id {} not present";
- LOGGER.error(msg, automationComposition);
+ LOGGER.error(msg, elementId);
return;
}
element.setOperationalState(operationalState);
element.setUseState(useState);
element.setOutProperties(outProperties);
- var statusMsg = new ParticipantStatus();
- statusMsg.setParticipantId(cacheProvider.getParticipantId());
- statusMsg.setState(ParticipantState.ON_LINE);
- statusMsg.setParticipantSupportedElementType(cacheProvider.getSupportedAcElementTypes());
var acInfo = new AutomationCompositionInfo();
acInfo.setAutomationCompositionId(automationCompositionId);
acInfo.setDeployState(automationComposition.getDeployState());
acInfo.setLockState(automationComposition.getLockState());
acInfo.setElements(List.of(getAutomationCompositionElementInfo(element)));
+ var statusMsg = createParticipantStatus();
+ statusMsg.setCompositionId(automationComposition.getCompositionId());
statusMsg.setAutomationCompositionInfoList(List.of(acInfo));
publisher.sendParticipantStatus(statusMsg);
}
@@ -225,4 +226,59 @@ public class AutomationCompositionOutHandler {
publisher.sendParticipantPrimeAck(participantPrimeAck);
cacheProvider.getMsgIdentification().remove(compositionId);
}
+
+ /**
+ * Send Composition Definition Info.
+ *
+ * @param compositionId the composition id
+ * @param elementId the Composition Definition Element id
+ * @param outProperties the output Properties Map
+ */
+ public void sendAcDefinitionInfo(UUID compositionId, ToscaConceptIdentifier elementId,
+ Map<String, Object> outProperties) {
+ if (compositionId == null) {
+ LOGGER.error("Cannot send Composition outProperties, id is null");
+ return;
+ }
+ var statusMsg = createParticipantStatus();
+ statusMsg.setCompositionId(compositionId);
+ var acElementDefsMap = cacheProvider.getAcElementsDefinitions();
+ var acElementsDefinitions = acElementDefsMap.get(compositionId);
+ if (acElementsDefinitions == null) {
+ LOGGER.error("Cannot send Composition outProperties, id {} is null", compositionId);
+ return;
+ }
+ var acElementDefinition = getAutomationCompositionElementDefinition(acElementsDefinitions, elementId);
+ if (acElementDefinition == null) {
+ LOGGER.error("Cannot send Composition outProperties, elementId {} not present", elementId);
+ return;
+ }
+ acElementDefinition.setOutProperties(outProperties);
+ var participantDefinition = new ParticipantDefinition();
+ participantDefinition.setParticipantId(cacheProvider.getParticipantId());
+ participantDefinition.setAutomationCompositionElementDefinitionList(List.of(acElementDefinition));
+ statusMsg.setParticipantDefinitionUpdates(List.of(participantDefinition));
+ publisher.sendHeartbeat(statusMsg);
+ }
+
+ private AutomationCompositionElementDefinition getAutomationCompositionElementDefinition(
+ Map<ToscaConceptIdentifier, AutomationCompositionElementDefinition> acElementsDefinition,
+ ToscaConceptIdentifier elementId) {
+
+ if (elementId == null) {
+ if (acElementsDefinition.size() == 1) {
+ return acElementsDefinition.values().iterator().next();
+ }
+ return null;
+ }
+ return acElementsDefinition.get(elementId);
+ }
+
+ private ParticipantStatus createParticipantStatus() {
+ var statusMsg = new ParticipantStatus();
+ statusMsg.setParticipantId(cacheProvider.getParticipantId());
+ statusMsg.setState(ParticipantState.ON_LINE);
+ statusMsg.setParticipantSupportedElementType(cacheProvider.getSupportedAcElementTypes());
+ return statusMsg;
+ }
}
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 5f07518e1..6d7ff2ccd 100755
--- 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
@@ -30,7 +30,6 @@ import org.onap.policy.clamp.acm.participant.intermediary.comm.ParticipantMessag
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
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.ParticipantState;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeploy;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionStateChange;
@@ -69,8 +68,7 @@ public class ParticipantHandler {
*/
@Timed(value = "listener.participant_status_req", description = "PARTICIPANT_STATUS_REQ messages received")
public void handleParticipantStatusReq(final ParticipantStatusReq participantStatusReqMsg) {
- var participantStatus = makeHeartbeat(true);
- publisher.sendParticipantStatus(participantStatus);
+ publisher.sendParticipantStatus(makeHeartbeat());
}
/**
@@ -147,7 +145,7 @@ public class ParticipantHandler {
public void handleParticipantRegisterAck(ParticipantRegisterAck participantRegisterAckMsg) {
LOGGER.debug("ParticipantRegisterAck message received as responseTo {}",
participantRegisterAckMsg.getResponseTo());
- publisher.sendParticipantStatus(makeHeartbeat(false));
+ publisher.sendParticipantStatus(makeHeartbeat());
}
/**
@@ -224,33 +222,19 @@ public class ParticipantHandler {
*/
public void sendHeartbeat() {
if (publisher.isActive()) {
- publisher.sendHeartbeat(makeHeartbeat(false));
+ publisher.sendHeartbeat(makeHeartbeat());
}
}
/**
* Method to send heartbeat to automation composition runtime.
*/
- public ParticipantStatus makeHeartbeat(boolean responseToParticipantStatusReq) {
+ private ParticipantStatus makeHeartbeat() {
var heartbeat = new ParticipantStatus();
heartbeat.setParticipantId(cacheProvider.getParticipantId());
heartbeat.setState(ParticipantState.ON_LINE);
- heartbeat.setAutomationCompositionInfoList(getAutomationCompositionInfoList());
heartbeat.setParticipantSupportedElementType(cacheProvider.getSupportedAcElementTypes());
- if (responseToParticipantStatusReq) {
- var acElementDefsMap = cacheProvider.getAcElementsDefinitions();
- List<ParticipantDefinition> participantDefinitionList = new ArrayList<>(acElementDefsMap.size());
- for (var acElementDefs : acElementDefsMap.values()) {
- var participantDefinition = new ParticipantDefinition();
- participantDefinition.setParticipantId(cacheProvider.getParticipantId());
- participantDefinition
- .setAutomationCompositionElementDefinitionList(new ArrayList<>(acElementDefs.values()));
- participantDefinitionList.add(participantDefinition);
- }
- heartbeat.setParticipantDefinitionUpdates(participantDefinitionList);
- }
-
return heartbeat;
}