summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcTypeState.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java57
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java11
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestart.java61
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java20
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeTest.java30
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestartTest.java81
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java9
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java22
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java13
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java9
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java103
13 files changed, 364 insertions, 58 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcTypeState.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcTypeState.java
index 76851b490..8e36f7a3b 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcTypeState.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcTypeState.java
@@ -25,5 +25,6 @@ public enum AcTypeState {
COMMISSIONED,
PRIMING,
PRIMED,
- DEPRIMING
+ DEPRIMING,
+ RESTARTING
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java
new file mode 100644
index 000000000..b8ee0200d
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.concepts;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.models.base.PfUtils;
+
+@Getter
+@Setter
+@NoArgsConstructor
+@ToString
+public class ParticipantRestartAc {
+
+ private UUID automationCompositionId;
+
+ // current state of auto composition
+ private DeployState deployState;
+ private LockState lockState;
+
+ private List<AcElementDeploy> acElementList = new ArrayList<>();
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyConstructor the participant with updates to copy from
+ */
+ public ParticipantRestartAc(ParticipantRestartAc copyConstructor) {
+ this.automationCompositionId = copyConstructor.automationCompositionId;
+ this.deployState = copyConstructor.deployState;
+ this.lockState = copyConstructor.lockState;
+ this.acElementList = PfUtils.mapList(copyConstructor.acElementList, AcElementDeploy::new);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java
index e60a13202..c42778aae 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageType.java
@@ -49,12 +49,6 @@ public enum ParticipantMessageType {
AUTOMATION_COMPOSITION_STATE_CHANGE,
/**
- * Used by the automation composition runtime to order a health check on participants, triggers a
- * PARTICIPANT_STATUS message with the result of the PARTICIPANT_HEALTH_CHECK operation.
- */
- PARTICIPANT_HEALTH_CHECK,
-
- /**
* Used by participant to register itself with automation composition runtime.
*/
PARTICIPANT_REGISTER,
@@ -108,8 +102,7 @@ public enum ParticipantMessageType {
PROPERTIES_UPDATE,
/**
- * Used by participant to acknowledge the receipt of PROPERTIES_UPDATE message
- * from automation composition runtime.
+ * Used by runtime to send composition and instances to a restarted participant.
*/
- PROPERTIES_UPDATE_ACK
+ PARTICIPANT_RESTART
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestart.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestart.java
new file mode 100644
index 000000000..6b801ce8d
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestart.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.dmaap.participant;
+
+import java.util.ArrayList;
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc;
+import org.onap.policy.models.base.PfUtils;
+
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class ParticipantRestart extends ParticipantMessage {
+
+ // priming
+ private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
+
+ // autocomposition list
+ private List<ParticipantRestartAc> autocompositionList = new ArrayList<>();
+
+ /**
+ * Constructor.
+ */
+ public ParticipantRestart() {
+ super(ParticipantMessageType.PARTICIPANT_RESTART);
+ }
+
+ /**
+ * Constructs the object, making a deep copy.
+ *
+ * @param source source from which to copy
+ */
+ public ParticipantRestart(ParticipantRestart source) {
+ super(source);
+ this.participantDefinitionUpdates =
+ PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new);
+ this.autocompositionList = PfUtils.mapList(source.autocompositionList, ParticipantRestartAc::new);
+ }
+}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java
index 318b36a19..24197f1ab 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/instantiation/DeployOrder.java
@@ -25,5 +25,6 @@ public enum DeployOrder {
UNDEPLOY,
DEPLOY,
DELETE,
- UPDATE
+ UPDATE,
+ RESTARTING
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
index 671aca60f..ee8e010d2 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
@@ -35,8 +35,10 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
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;
@@ -49,6 +51,7 @@ import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -406,4 +409,21 @@ public final class AcmUtils {
element.setLockState(lockState);
}
}
+
+ /**
+ * Create a new AcElementDeploy from an AutomationCompositionElement.
+ *
+ * @param element the AutomationCompositionElement
+ * @param deployOrder the DeployOrder
+ * @return the AcElementDeploy
+ */
+ public static AcElementDeploy createAcElementDeploy(AutomationCompositionElement element, DeployOrder deployOrder) {
+ var acElementDeploy = new AcElementDeploy();
+ acElementDeploy.setId(element.getId());
+ acElementDeploy.setDefinition(new ToscaConceptIdentifier(element.getDefinition()));
+ acElementDeploy.setOrderedState(deployOrder);
+ acElementDeploy.setProperties(PfUtils.mapMap(element.getProperties(), UnaryOperator.identity()));
+ return acElementDeploy;
+ }
+
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeTest.java
index 890fc55ae..859b4224d 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantPrimeTest.java
@@ -29,13 +29,10 @@ import java.time.Instant;
import java.util.List;
import java.util.UUID;
import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
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;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* Test the copy constructor.
@@ -52,21 +49,9 @@ class ParticipantPrimeTest {
orig.setMessageId(UUID.randomUUID());
orig.setTimestamp(Instant.ofEpochMilli(3000));
- var toscaServiceTemplate = new ToscaServiceTemplate();
- toscaServiceTemplate.setName("serviceTemplate");
- toscaServiceTemplate.setDerivedFrom("parentServiceTemplate");
- toscaServiceTemplate.setDescription("Description of serviceTemplate");
- toscaServiceTemplate.setVersion("1.2.3");
-
- var toscaNodeTemplate = new ToscaNodeTemplate();
- toscaNodeTemplate.setName("nodeTemplate");
- toscaNodeTemplate.setDerivedFrom("parentNodeTemplate");
- toscaNodeTemplate.setDescription("Description of nodeTemplate");
- toscaNodeTemplate.setVersion("1.2.3");
-
var participantDefinitionUpdate = new ParticipantDefinition();
var type = new ToscaConceptIdentifier("id", "1.2.3");
- var acDefinition = getAcElementDefinition(type);
+ var acDefinition = CommonTestData.getAcElementDefinition(type);
participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
@@ -76,17 +61,4 @@ class ParticipantPrimeTest {
assertSerializable(orig, ParticipantPrime.class);
}
-
- private AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) {
- var toscaNodeTemplate = new ToscaNodeTemplate();
- toscaNodeTemplate.setName("nodeTemplate");
- toscaNodeTemplate.setDerivedFrom("parentNodeTemplate");
- toscaNodeTemplate.setDescription("Description of nodeTemplate");
- toscaNodeTemplate.setVersion("1.2.3");
-
- var acDefinition = new AutomationCompositionElementDefinition();
- acDefinition.setAcElementDefinitionId(id);
- acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate);
- return acDefinition;
- }
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestartTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestartTest.java
new file mode 100644
index 000000000..1ae607ebe
--- /dev/null
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantRestartTest.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.dmaap.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.dmaap.participant.ParticipantMessageUtils.assertSerializable;
+import static org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantMessageUtils.removeVariableFields;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+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;
+
+class ParticipantRestartTest {
+
+ @Test
+ void testCopyConstructor() throws CoderException {
+ assertThatThrownBy(() -> new ParticipantRestart(null)).isInstanceOf(NullPointerException.class);
+
+ final var orig = new ParticipantRestart();
+ // verify with null values
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantRestart(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 AcElementDeploy();
+ acElement.setId(UUID.randomUUID());
+ var id = new ToscaConceptIdentifier("id", "1.2.3");
+ acElement.setDefinition(id);
+
+ var acRestart = new ParticipantRestartAc();
+ acRestart.setAcElementList(List.of(acElement));
+ acRestart.setAutomationCompositionId(UUID.randomUUID());
+ acRestart.setDeployState(DeployState.DEPLOYED);
+ acRestart.setLockState(LockState.LOCKED);
+
+ orig.setAutocompositionList(List.of(acRestart));
+
+ assertEquals(removeVariableFields(orig.toString()),
+ removeVariableFields(new ParticipantRestart(orig).toString()));
+
+ assertSerializable(orig, ParticipantRestart.class);
+ }
+}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
index 046d1b848..7e8f60525 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
@@ -183,6 +183,15 @@ class AcmUtilsTest {
assertFalse(AcmUtils.isForward(DeployState.UNDEPLOYING, LockState.LOCKED));
}
+ @Test
+ void testCreateAcElementDeploy() {
+ var element = getDummyAutomationComposition().getElements().values().iterator().next();
+ var result = AcmUtils.createAcElementDeploy(element, DeployOrder.DEPLOY);
+ assertEquals(DeployOrder.DEPLOY, result.getOrderedState());
+ assertEquals(element.getId(), result.getId());
+ assertEquals(element.getDefinition(), result.getDefinition());
+ }
+
private AutomationComposition getDummyAutomationComposition() {
var automationComposition = new AutomationComposition();
automationComposition.setCompositionId(UUID.randomUUID());
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java
index 21666e484..03a3fb11a 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/CommonTestData.java
@@ -23,9 +23,12 @@ package org.onap.policy.clamp.models.acm.utils;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.UUID;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardYamlCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
@@ -78,4 +81,23 @@ public class CommonTestData {
return null;
}
}
+
+ /**
+ * Get new AutomationCompositionElementDefinition.
+ *
+ * @param id the ToscaConceptIdentifier
+ * @return a new AutomationCompositionElementDefinition
+ */
+ public static AutomationCompositionElementDefinition getAcElementDefinition(ToscaConceptIdentifier id) {
+ var toscaNodeTemplate = new ToscaNodeTemplate();
+ toscaNodeTemplate.setName("nodeTemplate");
+ toscaNodeTemplate.setDerivedFrom("parentNodeTemplate");
+ toscaNodeTemplate.setDescription("Description of nodeTemplate");
+ toscaNodeTemplate.setVersion("1.2.3");
+
+ var acDefinition = new AutomationCompositionElementDefinition();
+ acDefinition.setAcElementDefinitionId(id);
+ acDefinition.setAutomationCompositionElementToscaNodeTemplate(toscaNodeTemplate);
+ return acDefinition;
+ }
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java
index c5f33ad97..78a9e8a72 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AcElementPropertiesPublisher.java
@@ -27,15 +27,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import java.util.function.UnaryOperator;
import lombok.AllArgsConstructor;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.PropertiesUpdate;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
-import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -47,7 +45,7 @@ import org.springframework.stereotype.Component;
@AllArgsConstructor
public class AcElementPropertiesPublisher extends AbstractParticipantPublisher<PropertiesUpdate> {
- private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionDeployPublisher.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(AcElementPropertiesPublisher.class);
/**
* Send ACElementPropertiesUpdate to Participant.
@@ -59,12 +57,7 @@ public class AcElementPropertiesPublisher extends AbstractParticipantPublisher<P
public void send(AutomationComposition automationComposition) {
Map<UUID, List<AcElementDeploy>> map = new HashMap<>();
for (var element : automationComposition.getElements().values()) {
- var acElementDeploy = new AcElementDeploy();
- acElementDeploy.setId(element.getId());
- acElementDeploy.setDefinition(new ToscaConceptIdentifier(element.getDefinition()));
- acElementDeploy.setOrderedState(DeployOrder.UPDATE);
- acElementDeploy.setProperties(PfUtils.mapMap(element.getProperties(), UnaryOperator.identity()));
-
+ var acElementDeploy = AcmUtils.createAcElementDeploy(element, DeployOrder.UPDATE);
map.putIfAbsent(element.getParticipantId(), new ArrayList<>());
map.get(element.getParticipantId()).add(acElementDeploy);
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
index 2628f030d..fbb6e14c5 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionDeployPublisher.java
@@ -29,7 +29,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import java.util.function.UnaryOperator;
import lombok.AllArgsConstructor;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
@@ -37,8 +36,6 @@ import org.onap.policy.clamp.models.acm.concepts.ParticipantDeploy;
import org.onap.policy.clamp.models.acm.messages.dmaap.participant.AutomationCompositionDeploy;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
-import org.onap.policy.models.base.PfUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,11 +64,7 @@ public class AutomationCompositionDeployPublisher extends AbstractParticipantPub
var toscaServiceTemplateFragment = AcmUtils.getToscaServiceTemplateFragment(toscaServiceTemplate);
Map<UUID, List<AcElementDeploy>> map = new HashMap<>();
for (var element : automationComposition.getElements().values()) {
- var acElementDeploy = new AcElementDeploy();
- acElementDeploy.setId(element.getId());
- acElementDeploy.setDefinition(new ToscaConceptIdentifier(element.getDefinition()));
- acElementDeploy.setOrderedState(DeployOrder.DEPLOY);
- acElementDeploy.setProperties(PfUtils.mapMap(element.getProperties(), UnaryOperator.identity()));
+ var acElementDeploy = AcmUtils.createAcElementDeploy(element, DeployOrder.DEPLOY);
acElementDeploy.setToscaServiceTemplateFragment(toscaServiceTemplateFragment);
map.putIfAbsent(element.getParticipantId(), new ArrayList<>());
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java
new file mode 100644
index 000000000..cb00c8e4d
--- /dev/null
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/ParticipantRestartPublisher.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2023 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.acm.runtime.supervision.comm;
+
+import io.micrometer.core.annotation.Timed;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
+import lombok.AllArgsConstructor;
+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.ParticipantDefinition;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc;
+import org.onap.policy.clamp.models.acm.messages.dmaap.participant.ParticipantRestart;
+import org.onap.policy.clamp.models.acm.messages.rest.instantiation.DeployOrder;
+import org.onap.policy.clamp.models.acm.utils.AcmUtils;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+@Component
+@AllArgsConstructor
+public class ParticipantRestartPublisher extends AbstractParticipantPublisher<ParticipantRestart> {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantRestartPublisher.class);
+
+ /**
+ * Send Restart to Participant.
+ *
+ */
+ @Timed(value = "publisher.participant_restart", description = "Participant Restart published")
+ public void send(UUID participantId, AutomationCompositionDefinition acmDefinition,
+ List<AutomationComposition> automationCompositions) {
+
+ var message = new ParticipantRestart();
+ message.setParticipantId(participantId);
+ message.setCompositionId(acmDefinition.getCompositionId());
+ message.setMessageId(UUID.randomUUID());
+ message.setTimestamp(Instant.now());
+ message.setParticipantDefinitionUpdates(prepareParticipantRestarting(participantId, acmDefinition));
+
+ for (var automationComposition : automationCompositions) {
+ var restartAc = new ParticipantRestartAc();
+ restartAc.setAutomationCompositionId(automationComposition.getInstanceId());
+ restartAc.setDeployState(automationComposition.getDeployState());
+ restartAc.setLockState(automationComposition.getLockState());
+ for (var element : automationComposition.getElements().values()) {
+ if (participantId.equals(element.getParticipantId())) {
+ var acElementDeploy = AcmUtils.createAcElementDeploy(element, DeployOrder.RESTARTING);
+ acElementDeploy.setToscaServiceTemplateFragment(acmDefinition.getServiceTemplate());
+ restartAc.getAcElementList().add(acElementDeploy);
+ }
+ }
+ message.getAutocompositionList().add(restartAc);
+ }
+
+ LOGGER.debug("Participant Restart sent {}", message);
+ super.send(message);
+ }
+
+ private List<ParticipantDefinition> prepareParticipantRestarting(UUID participantId,
+ AutomationCompositionDefinition acmDefinition) {
+ var acElements = AcmUtils.extractAcElementsFromServiceTemplate(acmDefinition.getServiceTemplate());
+
+ // list of entry entry filtered by participantId
+ List<Entry<String, ToscaNodeTemplate>> elementList = new ArrayList<>();
+ Map<ToscaConceptIdentifier, UUID> supportedElementMap = new HashMap<>();
+ for (var elementEntry : acElements) {
+ var elementState = acmDefinition.getElementStateMap().get(elementEntry.getKey());
+ if (participantId.equals(elementState.getParticipantId())) {
+ var type = new ToscaConceptIdentifier(elementEntry.getValue().getType(),
+ elementEntry.getValue().getTypeVersion());
+ supportedElementMap.put(type, participantId);
+ elementList.add(elementEntry);
+ }
+ }
+ return AcmUtils.prepareParticipantPriming(elementList, supportedElementMap);
+ }
+}