summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2023-06-02 12:36:45 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2023-06-06 08:32:42 +0000
commitd58c0ca04ae993702b2c399afd52b01e503ec0fe (patch)
tree45ab9c6019c79ed3a0814258e06d98219787f03d /participant/participant-intermediary/src
parentebb4d0cf867d752ae148880dd0109fc3cf6d6025 (diff)
Add Failure handling support in all ACM-participants
In any transition (like deploy, undeploy,  lock, unlock, update, delete) a participant should respond with the final state of transition, a status indicator (stateChaneResult) indicating if error has occurred and a message. Issue-ID: POLICY-4706 Change-Id: I424bc6d620f476392baee8904e21d3a6c7aa8d6b Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-intermediary/src')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java28
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java14
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java43
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java3
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java28
6 files changed, 76 insertions, 48 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
index c8fd91d69..6ca4d3cc7 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
@@ -20,9 +20,11 @@
package org.onap.policy.clamp.acm.participant.intermediary.api;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.models.base.PfModelException;
/**
@@ -48,23 +50,17 @@ public interface AutomationCompositionElementListener {
public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
throws PfModelException;
- public default void lock(UUID automationCompositionId, UUID automationCompositionElementId)
- throws PfModelException {
- // default Lock Operation
- }
+ public void lock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException;
- public default void unlock(UUID automationCompositionId, UUID automationCompositionElementId)
- throws PfModelException {
- // default Unlock Operation
- }
+ public void unlock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException;
- public default void delete(UUID automationCompositionId, UUID automationCompositionElementId)
- throws PfModelException {
- // default Delete Operation
- }
+ public void delete(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException;
- public default void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
- // default update Operation
- }
+ public void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws PfModelException;
+
+ public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
+ throws PfModelException;
+
+ public void deprime(UUID compositionId) throws PfModelException;
}
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 550ac37c5..1677f5486 100644
--- 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
@@ -23,9 +23,11 @@ package org.onap.policy.clamp.acm.participant.intermediary.api;
import java.util.Map;
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.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
/**
* This interface is used by participant implementations to use the participant intermediary.
@@ -47,10 +49,11 @@ public interface ParticipantIntermediaryApi {
* @param id the ID of the automation composition element to update the state on
* @param deployState the Deploy State of the automation composition element
* @param lockState the Lock State of the automation composition element
+ * @param stateChangeResult the indicator if error occurs
* @param message the message
*/
void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState,
- LockState lockState, String message);
+ LockState lockState, StateChangeResult stateChangeResult, String message);
/**
* Get AutomationCompositions.
@@ -70,4 +73,7 @@ public interface ParticipantIntermediaryApi {
*/
void sendAcElementInfo(UUID automationCompositionId, UUID id, String useState, String operationalState,
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 1bc3e5e72..14a653113 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
@@ -26,9 +26,11 @@ import java.util.UUID;
import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionHandler;
+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.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.springframework.stereotype.Component;
@@ -57,9 +59,9 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
}
@Override
- public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState newState,
- LockState lockState, String message) {
- automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, newState,
+ public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState,
+ LockState lockState, StateChangeResult stateChangeResult, String message) {
+ automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, deployState,
lockState, message);
}
@@ -74,4 +76,10 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
public Map<UUID, AutomationComposition> getAutomationCompositions() {
return PfUtils.mapMap(automationCompositionHandler.getAutomationCompositionMap(), AutomationComposition::new);
}
+
+ @Override
+ public void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult,
+ String message) {
+ // Auto-generated method stub
+ }
}
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 514bc655f..045677704 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
@@ -137,6 +137,10 @@ public class AutomationCompositionHandler {
if (checkOpt.isEmpty()) {
automationComposition.setDeployState(deployState);
automationComposition.setLockState(element.getLockState());
+
+ if (DeployState.DELETED.equals(deployState)) {
+ automationCompositionMap.remove(automationComposition.getInstanceId());
+ }
}
}
if (lockState != null) {
@@ -272,7 +276,7 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
public void handleAcPropertyUpdate(PropertiesUpdate updateMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
if (updateMsg.getParticipantUpdatesList().isEmpty()) {
LOGGER.warn("No AutomationCompositionElement updates in message {}",
@@ -283,8 +287,8 @@ public class AutomationCompositionHandler {
for (var participantDeploy : updateMsg.getParticipantUpdatesList()) {
if (participantId.equals(participantDeploy.getParticipantId())) {
- initializeDeploy(updateMsg.getMessageId(), updateMsg.getAutomationCompositionId(),
- participantDeploy, DeployState.UPDATING);
+ initializeDeploy(updateMsg.getMessageId(), updateMsg.getAutomationCompositionId(), participantDeploy,
+ DeployState.UPDATING);
callParticipantUpdateProperty(participantDeploy.getAcElementList(), acElementDefinitions,
updateMsg.getAutomationCompositionId());
@@ -320,7 +324,7 @@ public class AutomationCompositionHandler {
}
private void initializeDeploy(UUID messageId, UUID instanceId, ParticipantDeploy participantDeploy,
- DeployState deployState) {
+ DeployState deployState) {
if (automationCompositionMap.containsKey(instanceId)) {
updateExistingElementsOnThisParticipant(instanceId, participantDeploy, deployState);
} else {
@@ -333,12 +337,11 @@ public class AutomationCompositionHandler {
}
private void callParticipantDeploy(List<AcElementDeploy> acElements,
- List<AutomationCompositionElementDefinition> acElementDefinitions,
- Integer startPhaseMsg, UUID automationCompositionId) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions, Integer startPhaseMsg,
+ UUID automationCompositionId) {
try {
for (var element : acElements) {
- var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions,
- element.getDefinition());
+ var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, element.getDefinition());
if (acElementNodeTemplate != null) {
int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties());
if (startPhaseMsg.equals(startPhase)) {
@@ -357,12 +360,10 @@ public class AutomationCompositionHandler {
}
private void callParticipantUpdateProperty(List<AcElementDeploy> acElements,
- List<AutomationCompositionElementDefinition> acElementDefinitions,
- UUID automationCompositionId) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions, UUID automationCompositionId) {
try {
for (var element : acElements) {
- var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions,
- element.getDefinition());
+ var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, element.getDefinition());
if (acElementNodeTemplate != null) {
for (var acElementListener : listeners) {
var map = new HashMap<>(acElementNodeTemplate.getProperties());
@@ -389,7 +390,7 @@ public class AutomationCompositionHandler {
}
private List<AutomationCompositionElement> storeElementsOnThisParticipant(ParticipantDeploy participantDeploy,
- DeployState deployState) {
+ DeployState deployState) {
List<AutomationCompositionElement> acElementList = new ArrayList<>();
for (var element : participantDeploy.getAcElementList()) {
var acElement = new AutomationCompositionElement();
@@ -403,8 +404,8 @@ public class AutomationCompositionHandler {
return acElementList;
}
- private void updateExistingElementsOnThisParticipant(
- UUID instanceId, ParticipantDeploy participantDeploy, DeployState deployState) {
+ private void updateExistingElementsOnThisParticipant(UUID instanceId, ParticipantDeploy participantDeploy,
+ DeployState deployState) {
Map<UUID, AutomationCompositionElement> elementList = automationCompositionMap.get(instanceId).getElements();
for (var element : participantDeploy.getAcElementList()) {
@@ -443,12 +444,6 @@ public class AutomationCompositionHandler {
automationComposition.getElements().values().stream()
.forEach(acElement -> automationCompositionElementDelete(automationComposition.getInstanceId(),
acElement, startPhaseMsg, acElementDefinitions));
-
- boolean isAllUninitialised = automationComposition.getElements().values().stream()
- .filter(element -> !DeployState.DELETED.equals(element.getDeployState())).findAny().isEmpty();
- if (isAllUninitialised) {
- automationCompositionMap.remove(automationComposition.getInstanceId());
- }
}
/**
@@ -488,8 +483,6 @@ public class AutomationCompositionHandler {
for (var acElementListener : listeners) {
try {
acElementListener.lock(instanceId, acElement.getId());
- updateAutomationCompositionElementState(instanceId, acElement.getId(), null, LockState.LOCKED,
- "Locked");
} catch (PfModelException e) {
LOGGER.error("Automation composition element lock failed {}", instanceId);
}
@@ -507,8 +500,6 @@ public class AutomationCompositionHandler {
for (var acElementListener : listeners) {
try {
acElementListener.unlock(instanceId, acElement.getId());
- updateAutomationCompositionElementState(instanceId, acElement.getId(), null, LockState.UNLOCKED,
- "Unlocked");
} catch (PfModelException e) {
LOGGER.error("Automation composition element unlock failed {}", instanceId);
}
@@ -537,8 +528,6 @@ public class AutomationCompositionHandler {
for (var acElementListener : listeners) {
try {
acElementListener.delete(instanceId, acElement.getId());
- updateAutomationCompositionElementState(instanceId, acElement.getId(), DeployState.DELETED,
- null, "Deleted");
} catch (PfModelException e) {
LOGGER.error("Automation composition element unlock failed {}", instanceId);
}
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
index aa39f5a3f..8f70bc7d9 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImplTest.java
@@ -30,6 +30,7 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationComposit
import org.onap.policy.clamp.acm.participant.intermediary.handler.AutomationCompositionHandler;
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.common.utils.coder.CoderException;
class ParticipantIntermediaryApiImplTest {
@@ -50,7 +51,7 @@ class ParticipantIntermediaryApiImplTest {
var uuid = UUID.randomUUID();
var automationCompositionId = UUID.randomUUID();
apiImpl.updateAutomationCompositionElementState(automationCompositionId, uuid, DeployState.UNDEPLOYED,
- LockState.NONE, null);
+ LockState.NONE, StateChangeResult.NO_ERROR, null);
verify(automationComposiitonHandler).updateAutomationCompositionElementState(automationCompositionId, uuid,
DeployState.UNDEPLOYED, LockState.NONE, null);
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java
index b88ea03e5..0a724ed69 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/DummyAcElementListener.java
@@ -20,10 +20,12 @@
package org.onap.policy.clamp.acm.participant.intermediary.handler;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.models.base.PfModelException;
public class DummyAcElementListener implements AutomationCompositionElementListener {
@@ -37,4 +39,30 @@ public class DummyAcElementListener implements AutomationCompositionElementListe
throws PfModelException {
}
+
+ @Override
+ public void lock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+ }
+
+ @Override
+ public void unlock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+ }
+
+ @Override
+ public void delete(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+ }
+
+ @Override
+ public void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws PfModelException {
+ }
+
+ @Override
+ public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
+ throws PfModelException {
+ }
+
+ @Override
+ public void deprime(UUID compositionId) throws PfModelException {
+ }
}