From b13d8dc3a73bc372dabe47ebd88ed1892ee688ea Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Tue, 11 Jul 2023 11:19:34 +0100 Subject: Add support participant restart in ACM runtime Issue-ID: POLICY-4744 Change-Id: I33d31751be7ca5d7c215a2b465564d3ab0c7bee6 Signed-off-by: FrancescoFioraEst --- .../models/acm/concepts/AcElementRestart.java | 73 ++++++++++++++++++++++ .../clamp/models/acm/concepts/AcTypeState.java | 3 +- .../models/acm/concepts/ParticipantRestartAc.java | 10 +-- .../dmaap/participant/ParticipantRestart.java | 12 ++-- .../policy/clamp/models/acm/utils/AcmUtils.java | 16 +++++ 5 files changed, 100 insertions(+), 14 deletions(-) create mode 100644 models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java (limited to 'models/src/main') diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java new file mode 100644 index 000000000..3815989f7 --- /dev/null +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AcElementRestart.java @@ -0,0 +1,73 @@ +/*- + * ============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.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.UnaryOperator; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.ToString; +import org.onap.policy.models.base.PfConceptKey; +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; + +@NoArgsConstructor +@Data +@ToString +public class AcElementRestart { + + @NonNull + private UUID id = UUID.randomUUID(); + + @NonNull + private ToscaConceptIdentifier definition = new ToscaConceptIdentifier(PfConceptKey.getNullKey()); + + // State of the AutomationCompositionElement + private DeployState deployState; + + // State of the AutomationCompositionElement + private LockState lockState; + + private ToscaServiceTemplate toscaServiceTemplateFragment; + + // A map indexed by the property name. Each map entry is the serialized value of the property, + // which can be deserialized into an instance of the type of the property. + private Map properties = new LinkedHashMap<>(); + + /** + * Copy constructor, does a deep copy but as all fields here are immutable, it's just a regular copy. + * + * @param otherElement the other element to copy from + */ + public AcElementRestart(final AcElementRestart otherElement) { + this.id = otherElement.id; + this.definition = new ToscaConceptIdentifier(otherElement.definition); + this.deployState = otherElement.deployState; + this.lockState = otherElement.lockState; + this.toscaServiceTemplateFragment = otherElement.toscaServiceTemplateFragment; + this.properties = PfUtils.mapMap(otherElement.properties, UnaryOperator.identity()); + } + +} 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 8e36f7a3b..76851b490 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,6 +25,5 @@ public enum AcTypeState { COMMISSIONED, PRIMING, PRIMED, - DEPRIMING, - RESTARTING + DEPRIMING } 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 index b8ee0200d..e5f4ad4ae 100644 --- 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 @@ -37,11 +37,7 @@ public class ParticipantRestartAc { private UUID automationCompositionId; - // current state of auto composition - private DeployState deployState; - private LockState lockState; - - private List acElementList = new ArrayList<>(); + private List acElementList = new ArrayList<>(); /** * Copy constructor. @@ -50,8 +46,6 @@ public class ParticipantRestartAc { */ public ParticipantRestartAc(ParticipantRestartAc copyConstructor) { this.automationCompositionId = copyConstructor.automationCompositionId; - this.deployState = copyConstructor.deployState; - this.lockState = copyConstructor.lockState; - this.acElementList = PfUtils.mapList(copyConstructor.acElementList, AcElementDeploy::new); + this.acElementList = PfUtils.mapList(copyConstructor.acElementList, AcElementRestart::new); } } 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 index 6b801ce8d..c86a3e460 100644 --- 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 @@ -25,6 +25,7 @@ import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; +import org.onap.policy.clamp.models.acm.concepts.AcTypeState; 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; @@ -34,11 +35,14 @@ import org.onap.policy.models.base.PfUtils; @ToString(callSuper = true) public class ParticipantRestart extends ParticipantMessage { - // priming + // composition state + AcTypeState state; + + // element definition private List participantDefinitionUpdates = new ArrayList<>(); - // autocomposition list - private List autocompositionList = new ArrayList<>(); + // automationcomposition instances list + private List automationcompositionList = new ArrayList<>(); /** * Constructor. @@ -56,6 +60,6 @@ public class ParticipantRestart extends ParticipantMessage { super(source); this.participantDefinitionUpdates = PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new); - this.autocompositionList = PfUtils.mapList(source.autocompositionList, ParticipantRestartAc::new); + this.automationcompositionList = PfUtils.mapList(source.automationcompositionList, ParticipantRestartAc::new); } } 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 ee8e010d2..ae49ec69f 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 @@ -36,6 +36,7 @@ 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.AcElementRestart; 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; @@ -426,4 +427,19 @@ public final class AcmUtils { return acElementDeploy; } + /** + * Create a new AcElementRestart from an AutomationCompositionElement. + * + * @param element the AutomationCompositionElement + * @return the AcElementRestart + */ + public static AcElementRestart createAcElementRestart(AutomationCompositionElement element) { + var acElementRestart = new AcElementRestart(); + acElementRestart.setId(element.getId()); + acElementRestart.setDefinition(new ToscaConceptIdentifier(element.getDefinition())); + acElementRestart.setDeployState(element.getDeployState()); + acElementRestart.setLockState(element.getLockState()); + acElementRestart.setProperties(PfUtils.mapMap(element.getProperties(), UnaryOperator.identity())); + return acElementRestart; + } } -- cgit 1.2.3-korg