aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-10-08 09:18:39 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2024-10-08 13:37:02 +0000
commit20ad241b626db4d44bffd08ca0e5d6f2d8f4be4d (patch)
tree55957befcc2b1703ea2cc4797cd09e209580a966
parent9632ec36d91bcaf4815444126ac132390eb49433 (diff)
Add sync message when OutProperties instance change
Add sync message when OutProperties instance change. Remove update out Properties instance when ac state change happen. Issue-ID: POLICY-5135 Change-Id: If62521ae3200c8836db92f4825110f14696767df Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java3
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java14
-rw-r--r--runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java25
3 files changed, 35 insertions, 7 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
index 6a56a2c2b..4f564478f 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionAcHandler.java
@@ -340,9 +340,6 @@ public class SupervisionAcHandler {
var element = automationComposition.getElements().get(acElementAck.getKey());
if (element != null) {
element.setMessage(AcmUtils.validatedMessage(acElementAck.getValue().getMessage()));
- element.setOutProperties(acElementAck.getValue().getOutProperties());
- element.setOperationalState(acElementAck.getValue().getOperationalState());
- element.setUseState(acElementAck.getValue().getUseState());
if (stage == null) {
element.setSubState(SubState.NONE);
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
index ea3ef0ff7..3eb471609 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandler.java
@@ -34,6 +34,7 @@ import org.onap.policy.clamp.acm.runtime.supervision.comm.ParticipantSyncPublish
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.AutomationCompositionDefinition;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionInfo;
import org.onap.policy.clamp.models.acm.concepts.Participant;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantReplica;
@@ -109,7 +110,8 @@ public class SupervisionParticipantHandler {
participantStatusMsg.getParticipantSupportedElementType(), false);
if (!participantStatusMsg.getAutomationCompositionInfoList().isEmpty()) {
- automationCompositionProvider.upgradeStates(participantStatusMsg.getAutomationCompositionInfoList());
+ updateAcOutProperties(participantStatusMsg.getAutomationCompositionInfoList(),
+ participantStatusMsg.getCompositionId());
}
if (!participantStatusMsg.getParticipantDefinitionUpdates().isEmpty()
&& participantStatusMsg.getCompositionId() != null) {
@@ -150,6 +152,16 @@ public class SupervisionParticipantHandler {
}
+ private void updateAcOutProperties(List<AutomationCompositionInfo> automationCompositionInfoList,
+ UUID compositionId) {
+ automationCompositionProvider.upgradeStates(automationCompositionInfoList);
+ var acDefinition = acDefinitionProvider.getAcDefinition(compositionId);
+ for (var acInfo : automationCompositionInfoList) {
+ var ac = automationCompositionProvider.getAutomationComposition(acInfo.getAutomationCompositionId());
+ participantSyncPublisher.sendSync(acDefinition.getServiceTemplate(), ac);
+ }
+ }
+
private void updateAcDefinitionOutProperties(UUID compositionId, UUID replicaId, List<ParticipantDefinition> list) {
var acDefinitionOpt = acDefinitionProvider.findAcDefinition(compositionId);
if (acDefinitionOpt.isEmpty()) {
diff --git a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
index aab1a1ceb..83a279cb7 100644
--- a/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
+++ b/runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionParticipantHandlerTest.java
@@ -169,13 +169,19 @@ class SupervisionParticipantHandlerTest {
void testHandleParticipantStatus() {
var participantStatusMessage = createParticipantStatus();
participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
+ participantStatusMessage.setCompositionId(UUID.randomUUID());
+
+ var acDefinitionProvider = mock(AcDefinitionProvider.class);
+ var acDefinition = new AutomationCompositionDefinition();
+ acDefinition.setCompositionId(participantStatusMessage.getCompositionId());
+ when(acDefinitionProvider.getAcDefinition(acDefinition.getCompositionId())).thenReturn(acDefinition);
var participantProvider = mock(ParticipantProvider.class);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
- mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class),
+ acDefinitionProvider, mock(ParticipantSyncPublisher.class),
mock(AcRuntimeParameterGroup.class));
var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
when(participantProvider.findParticipant(CommonTestData.getParticipantId()))
@@ -206,6 +212,7 @@ class SupervisionParticipantHandlerTest {
Map.of(acElementDefinition.getAcElementDefinitionId().getName(), nodeTemplateState));
var acDefinitionProvider = mock(AcDefinitionProvider.class);
when(acDefinitionProvider.findAcDefinition(compositionId)).thenReturn(Optional.of(acDefinition));
+ when(acDefinitionProvider.getAcDefinition(compositionId)).thenReturn(acDefinition);
var participantProvider = mock(ParticipantProvider.class);
var handler =
@@ -222,13 +229,19 @@ class SupervisionParticipantHandlerTest {
void testHandleParticipantStatusNotRegisterd() {
var participantStatusMessage = createParticipantStatus();
participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
+ participantStatusMessage.setCompositionId(UUID.randomUUID());
+
+ var acDefinitionProvider = mock(AcDefinitionProvider.class);
+ var acDefinition = new AutomationCompositionDefinition();
+ acDefinition.setCompositionId(participantStatusMessage.getCompositionId());
+ when(acDefinitionProvider.getAcDefinition(acDefinition.getCompositionId())).thenReturn(acDefinition);
var participantProvider = mock(ParticipantProvider.class);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
- mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class),
+ acDefinitionProvider, mock(ParticipantSyncPublisher.class),
mock(AcRuntimeParameterGroup.class));
handler.handleParticipantMessage(participantStatusMessage);
@@ -240,13 +253,19 @@ class SupervisionParticipantHandlerTest {
void testHandleParticipantStatusCheckOnline() {
var participantStatusMessage = createParticipantStatus();
participantStatusMessage.setAutomationCompositionInfoList(List.of(new AutomationCompositionInfo()));
+ participantStatusMessage.setCompositionId(UUID.randomUUID());
+
+ var acDefinitionProvider = mock(AcDefinitionProvider.class);
+ var acDefinition = new AutomationCompositionDefinition();
+ acDefinition.setCompositionId(participantStatusMessage.getCompositionId());
+ when(acDefinitionProvider.getAcDefinition(acDefinition.getCompositionId())).thenReturn(acDefinition);
var participantProvider = mock(ParticipantProvider.class);
var automationCompositionProvider = mock(AutomationCompositionProvider.class);
var handler =
new SupervisionParticipantHandler(participantProvider, mock(ParticipantRegisterAckPublisher.class),
mock(ParticipantDeregisterAckPublisher.class), automationCompositionProvider,
- mock(AcDefinitionProvider.class), mock(ParticipantSyncPublisher.class),
+ acDefinitionProvider, mock(ParticipantSyncPublisher.class),
mock(AcRuntimeParameterGroup.class));
var participant = CommonTestData.createParticipant(CommonTestData.getParticipantId());
when(participantProvider.findParticipant(CommonTestData.getParticipantId()))