summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAdheli Tavares <adheli.tavares@est.tech>2024-06-11 09:32:45 +0000
committerGerrit Code Review <gerrit@onap.org>2024-06-11 09:32:45 +0000
commitb174e37eb1a41e9997c9455edacc36667e0c5c1a (patch)
treeed036f27b4ae9c7b2301bcf24d4412fdbd555733 /models
parenta35b7acb63a5990293231d30ff6efbe046267f3e (diff)
parentc616ee76ee72202bdf485de86b53a92837620c38 (diff)
Merge "Add Synchronization topic in acm runtime"
Diffstat (limited to 'models')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java7
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java12
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java47
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java2
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSyncTest.java86
5 files changed, 149 insertions, 5 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java
index 29c2c01bd..e6e42e851 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantMessageType.java
@@ -110,5 +110,10 @@ public enum ParticipantMessageType {
* Used by acm runtime to migrate from a composition to another one in participants, triggers a
* AUTOMATION_COMPOSITION_MIGRATION message with result of AUTOMATION_COMPOSITION_STATE_CHANGE operation.
*/
- AUTOMATION_COMPOSITION_MIGRATION
+ AUTOMATION_COMPOSITION_MIGRATION,
+
+ /**
+ * Used by runtime to send composition and instances to sync participant replicas.
+ */
+ PARTICIPANT_SYNC_MSG
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java
index 103be6891..119cdf030 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023,2024 Nordix Foundation.
+ * Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public class ParticipantRestart extends ParticipantMessage {
// element definition
private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
- // automationcomposition instances list
+ // automation composition instances list
private List<ParticipantRestartAc> automationcompositionList = new ArrayList<>();
/**
@@ -52,6 +52,14 @@ public class ParticipantRestart extends ParticipantMessage {
}
/**
+ * Constructor with message type.
+ * @param messageType messageType
+ */
+ public ParticipantRestart(ParticipantMessageType messageType) {
+ super(messageType);
+ }
+
+ /**
* Constructs the object, making a deep copy.
*
* @param source source from which to copy
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java
new file mode 100644
index 000000000..33a730941
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.messages.kafka.participant;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ParticipantSync extends ParticipantRestart {
+
+ /**
+ * Constructor.
+ */
+ public ParticipantSync() {
+ super(ParticipantMessageType.PARTICIPANT_SYNC_MSG);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantSync(ParticipantSync source) {
+ super(source);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java
index 3353de600..95b718e68 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java
@@ -20,7 +20,6 @@
package org.onap.policy.clamp.models.acm.messages.kafka.participant;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.assertSerializable;
import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.removeVariableFields;
@@ -43,7 +42,6 @@ class ParticipantRestartTest {
@Test
void testCopyConstructor() throws CoderException {
- assertThatThrownBy(() -> new ParticipantRestart(null)).isInstanceOf(NullPointerException.class);
final var orig = new ParticipantRestart();
// verify with null values
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSyncTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSyncTest.java
new file mode 100644
index 000000000..970b94824
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSyncTest.java
@@ -0,0 +1,86 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2024 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.clamp.models.acm.messages.kafka.participant;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.AcElementRestart;
+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.ParticipantRestartAc;
+import org.onap.policy.clamp.models.acm.utils.CommonTestData;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+
+
+public class ParticipantSyncTest {
+
+ @Test
+ void testCopyConstructor() throws CoderException {
+
+ final var orig = new ParticipantSync();
+ // verify with null values
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantSync(orig).toString()));
+
+ orig.setMessageId(UUID.randomUUID());
+ orig.setCompositionId(UUID.randomUUID());
+ orig.setTimestamp(Instant.ofEpochMilli(3000));
+ orig.setParticipantId(CommonTestData.getParticipantId());
+
+ var participantDefinitionUpdate = new ParticipantDefinition();
+ var type = new ToscaConceptIdentifier("id", "1.2.3");
+ var acDefinition = CommonTestData.getAcElementDefinition(type);
+ participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
+ orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
+
+ var acElement = new AcElementRestart();
+ acElement.setId(UUID.randomUUID());
+ var id = new ToscaConceptIdentifier("id", "1.2.3");
+ acElement.setDefinition(id);
+ acElement.setDeployState(DeployState.DEPLOYED);
+ acElement.setLockState(LockState.LOCKED);
+ acElement.setOperationalState("OperationalState");
+ acElement.setUseState("UseState");
+ acElement.setProperties(Map.of("key", "value"));
+ acElement.setOutProperties(Map.of("keyOut", "valueOut"));
+
+ var acRestart = new ParticipantRestartAc();
+ acRestart.setAcElementList(List.of(acElement));
+ acRestart.setAutomationCompositionId(UUID.randomUUID());
+
+ orig.setAutomationcompositionList(List.of(acRestart));
+
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantSync(orig).toString()));
+
+ assertSerializable(orig, ParticipantSync.class);
+ }
+}