summaryrefslogtreecommitdiffstats
path: root/participant
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-06-04 09:11:31 +0100
committerFrancesco Fiora <francesco.fiora@est.tech>2024-06-06 08:30:37 +0000
commita48f784beca5e7aa189217c52cfa83452cf8fc47 (patch)
treef8b7befa293c8032c47355125c197acfbadccf9e /participant
parent6563ce72688dacd99c7badd0c9e94ad7fa22da23 (diff)
Add support for unique replica id generation in the participants
Issue-ID: POLICY-5032 Change-Id: I9c36b87d1f03f03089d2c62308e0975e24f6e99a Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcDefinitionHandler.java1
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java1
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionOutHandler.java3
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java4
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandler.java7
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java1
-rw-r--r--participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java5
7 files changed, 20 insertions, 2 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcDefinitionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcDefinitionHandler.java
index e1d4b0959..d3ad4cf3e 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcDefinitionHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AcDefinitionHandler.java
@@ -91,6 +91,7 @@ public class AcDefinitionHandler {
participantPrimeAck.setCompositionState(AcTypeState.COMMISSIONED);
participantPrimeAck.setStateChangeResult(StateChangeResult.NO_ERROR);
participantPrimeAck.setParticipantId(cacheProvider.getParticipantId());
+ participantPrimeAck.setReplicaId(cacheProvider.getReplicaId());
participantPrimeAck.setState(ParticipantState.ON_LINE);
publisher.sendParticipantPrimeAck(participantPrimeAck);
return;
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 5c54861f7..a3eafd844 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
@@ -77,6 +77,7 @@ public class AutomationCompositionHandler {
var automationCompositionAck = new AutomationCompositionDeployAck(
ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionAck.setParticipantId(cacheProvider.getParticipantId());
+ automationCompositionAck.setReplicaId(cacheProvider.getReplicaId());
automationCompositionAck.setMessage("Already deleted or never used");
automationCompositionAck.setResult(true);
automationCompositionAck.setStateChangeResult(StateChangeResult.NO_ERROR);
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 0ed333ebd..1f4c036e7 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
@@ -103,6 +103,7 @@ public class AutomationCompositionOutHandler {
var automationCompositionStateChangeAck =
new AutomationCompositionDeployAck(ParticipantMessageType.AUTOMATION_COMPOSITION_STATECHANGE_ACK);
automationCompositionStateChangeAck.setParticipantId(cacheProvider.getParticipantId());
+ automationCompositionStateChangeAck.setReplicaId(cacheProvider.getReplicaId());
automationCompositionStateChangeAck.setMessage(message);
automationCompositionStateChangeAck.setResponseTo(cacheProvider.getMsgIdentification().get(element.getId()));
automationCompositionStateChangeAck.setStateChangeResult(stateChangeResult);
@@ -228,6 +229,7 @@ public class AutomationCompositionOutHandler {
participantPrimeAck.setCompositionState(state);
participantPrimeAck.setStateChangeResult(stateChangeResult);
participantPrimeAck.setParticipantId(cacheProvider.getParticipantId());
+ participantPrimeAck.setReplicaId(cacheProvider.getReplicaId());
participantPrimeAck.setState(ParticipantState.ON_LINE);
publisher.sendParticipantPrimeAck(participantPrimeAck);
cacheProvider.getMsgIdentification().remove(compositionId);
@@ -286,6 +288,7 @@ public class AutomationCompositionOutHandler {
private ParticipantStatus createParticipantStatus() {
var statusMsg = new ParticipantStatus();
statusMsg.setParticipantId(cacheProvider.getParticipantId());
+ statusMsg.setReplicaId(cacheProvider.getReplicaId());
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/CacheProvider.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java
index 343f8a9e8..b85a3c35a 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/CacheProvider.java
@@ -53,6 +53,9 @@ public class CacheProvider {
@Setter
private boolean registered = false;
+ @Getter
+ private final UUID replicaId;
+
private final List<ParticipantSupportedElementType> supportedAcElementTypes;
@Getter
@@ -73,6 +76,7 @@ public class CacheProvider {
public CacheProvider(ParticipantParameters parameters) {
this.participantId = parameters.getIntermediaryParameters().getParticipantId();
this.supportedAcElementTypes = parameters.getIntermediaryParameters().getParticipantSupportedElementTypes();
+ this.replicaId = UUID.randomUUID();
}
public List<ParticipantSupportedElementType> getSupportedAcElementTypes() {
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 0865dca8e..54a05912a 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
@@ -126,7 +126,7 @@ public class ParticipantHandler {
* @return true if it applies, false otherwise
*/
public boolean appliesTo(ParticipantMessage participantMsg) {
- return participantMsg.appliesTo(cacheProvider.getParticipantId());
+ return participantMsg.appliesTo(cacheProvider.getParticipantId(), cacheProvider.getReplicaId());
}
/**
@@ -136,7 +136,7 @@ public class ParticipantHandler {
* @return true if it applies, false otherwise
*/
public boolean appliesTo(ParticipantAckMessage participantMsg) {
- return participantMsg.appliesTo(cacheProvider.getParticipantId());
+ return participantMsg.appliesTo(cacheProvider.getParticipantId(), cacheProvider.getReplicaId());
}
/**
@@ -145,6 +145,7 @@ public class ParticipantHandler {
public void sendParticipantRegister() {
var participantRegister = new ParticipantRegister();
participantRegister.setParticipantId(cacheProvider.getParticipantId());
+ participantRegister.setReplicaId(cacheProvider.getReplicaId());
participantRegister.setParticipantSupportedElementType(cacheProvider.getSupportedAcElementTypes());
publisher.sendParticipantRegister(participantRegister);
@@ -169,6 +170,7 @@ public class ParticipantHandler {
public void sendParticipantDeregister() {
var participantDeregister = new ParticipantDeregister();
participantDeregister.setParticipantId(cacheProvider.getParticipantId());
+ participantDeregister.setReplicaId(cacheProvider.getReplicaId());
publisher.sendParticipantDeregister(participantDeregister);
}
@@ -225,6 +227,7 @@ public class ParticipantHandler {
private ParticipantStatus makeHeartbeat() {
var heartbeat = new ParticipantStatus();
heartbeat.setParticipantId(cacheProvider.getParticipantId());
+ heartbeat.setReplicaId(cacheProvider.getReplicaId());
heartbeat.setState(ParticipantState.ON_LINE);
heartbeat.setParticipantSupportedElementType(cacheProvider.getSupportedAcElementTypes());
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
index cd28d41fb..eb1db475b 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ParticipantHandlerTest.java
@@ -125,6 +125,7 @@ class ParticipantHandlerTest {
void appliesToTest() {
var cacheProvider = mock(CacheProvider.class);
when(cacheProvider.getParticipantId()).thenReturn(CommonTestData.getParticipantId());
+ when(cacheProvider.getReplicaId()).thenReturn(CommonTestData.getReplicaId());
var participantHandler = new ParticipantHandler(mock(AutomationCompositionHandler.class),
mock(AcLockHandler.class), mock(AcDefinitionHandler.class), mock(ParticipantMessagePublisher.class),
cacheProvider);
diff --git a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
index 3011c91f5..1536a0be0 100644
--- a/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
+++ b/participant/participant-intermediary/src/test/java/org/onap/policy/clamp/acm/participant/intermediary/main/parameters/CommonTestData.java
@@ -62,6 +62,7 @@ public class CommonTestData {
public static final UUID AC_ID_0 = UUID.randomUUID();
public static final UUID AC_ID_1 = UUID.randomUUID();
public static final UUID PARTCICIPANT_ID = UUID.randomUUID();
+ public static final UUID REPLICA_ID = UUID.randomUUID();
/**
* Get ParticipantIntermediaryParameters.
@@ -160,6 +161,10 @@ public class CommonTestData {
return PARTCICIPANT_ID;
}
+ public static UUID getReplicaId() {
+ return REPLICA_ID;
+ }
+
public static UUID getRndParticipantId() {
return UUID.randomUUID();
}