diff options
Diffstat (limited to 'participant/participant-intermediary/src/main/java')
8 files changed, 244 insertions, 39 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java index cbcd8dd7f..5994328d5 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java @@ -89,14 +89,16 @@ public interface AutomationCompositionElementListener { /** * Handle an update on a automation composition element. * - * @param compositionElement the information of the Automation Composition Definition Element + * @param compositionElement the information of the Automation Composition Definition Element * @param compositionElementTarget the information of the Automation Composition Definition Element Target - * @param instanceElement the information of the Automation Composition Instance Element - * @param instanceElementMigrate the information of the Automation Composition Instance Element updated + * @param instanceElement the information of the Automation Composition Instance Element + * @param instanceElementMigrate the information of the Automation Composition Instance Element updated + * @param nextStage the next stage * @throws PfModelException from Policy framework */ void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget, - InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException; + InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate, + int nextStage) throws PfModelException; void migratePrecheck(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException; diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java index 9b3279232..c06ffe62e 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,41 +38,52 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; public interface ParticipantIntermediaryApi { /** - * Update the state of a automation composition element. + * Update the state of a AutomationComposition Instance Element. * - * @param automationCompositionId the ID of the automation composition to update the state on - * @param elementId the ID of the automation composition element to update the state on - * @param deployState the Deploy State of the automation composition element - * @param lockState the Lock State of the automation composition element + * @param instance the ID of the AutomationComposition Instance to update the state on + * @param elementId the ID of the AutomationComposition Instance element to update the state on + * @param deployState the Deploy State of the AutomationComposition Instance element + * @param lockState the Lock State of the AutomationComposition Instance element * @param stateChangeResult the indicator if error occurs * @param message the message */ - void updateAutomationCompositionElementState(UUID automationCompositionId, UUID elementId, DeployState deployState, + void updateAutomationCompositionElementState(UUID instance, UUID elementId, DeployState deployState, LockState lockState, StateChangeResult stateChangeResult, String message); /** - * Get a copy of all AutomationCompositions. + * Update the stage of a AutomationComposition Instance Element. * - * @return get all AutomationCompositions + * @param instance the ID of the AutomationComposition Instance to update the state on + * @param elementId the ID of the AutomationComposition Instance Element to update the state on + * @param stateChangeResult the indicator if error occurs + * @param message the message + */ + void updateAutomationCompositionElementStage(UUID instance, UUID elementId, StateChangeResult stateChangeResult, + int stage, String message); + + /** + * Get a copy of all AutomationComposition Instances. + * + * @return get all AutomationComposition Instances */ Map<UUID, AutomationComposition> getAutomationCompositions(); /** - * Get a copy of the AutomationComposition by automationCompositionId. + * Get a copy of the AutomationComposition Instance by AutomationComposition Instance Id. * - * @param automationCompositionId the ID of the automation composition to update the state on - * @return get the AutomationComposition + * @param instanceId the ID of the AutomationComposition Instance to update the state on + * @return get the AutomationComposition Instance */ - AutomationComposition getAutomationComposition(UUID automationCompositionId); + AutomationComposition getAutomationComposition(UUID instanceId); /** - * Get a copy of the AutomationCompositionElement by automationCompositionId and elementId. + * Get a copy of the AutomationCompositionElement by AutomationComposition Instance Id and elementId. * - * @param automationCompositionId the ID of the automation composition to update the state on - * @param elementId the ID of the automation composition element to update the state on + * @param instanceId the ID of the AutomationComposition Instance to update the state on + * @param elementId the ID of the AutomationComposition Instance Element to update the state on * @return get the AutomationCompositionElement */ - AutomationCompositionElement getAutomationCompositionElement(UUID automationCompositionId, UUID elementId); + AutomationCompositionElement getAutomationCompositionElement(UUID instanceId, UUID elementId); /** * Get a copy of all AutomationCompositionElementDefinition from all primed compositions. @@ -99,15 +110,15 @@ public interface ParticipantIntermediaryApi { AutomationCompositionElementDefinition getAcElementDefinition(UUID compositionId, ToscaConceptIdentifier elementId); /** - * Send Automation Composition Element update Info to AC-runtime. + * Send AutomationComposition Instance Element update Info to AC-runtime. * - * @param automationCompositionId the ID of the automation composition to update the states - * @param elementId the ID of the automation composition element to update the states + * @param instanceId the ID of the AutomationComposition Instance to update the states + * @param elementId the ID of the AutomationComposition Instance Element to update the states * @param useState the use State * @param operationalState the operational State * @param outProperties the output Properties Map */ - void sendAcElementInfo(UUID automationCompositionId, UUID elementId, String useState, String operationalState, + void sendAcElementInfo(UUID instanceId, UUID elementId, String useState, String operationalState, Map<String, Object> outProperties); /** diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java index 6bc3f9265..34bdc349b 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV1.java @@ -209,7 +209,8 @@ public abstract class AcElementListenerV1 @Override public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget, - InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException { + InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate, + int stage) throws PfModelException { var element = new AcElementDeploy(); element.setId(instanceElementMigrate.elementId()); element.setDefinition(compositionElementTarget.elementDefinitionId()); diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java index 6e6f96eca..7db220095 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV2.java @@ -36,7 +36,8 @@ import org.onap.policy.models.base.PfModelException; * Wrapper of AutomationCompositionElementListener. * Valid since 7.1.1 release. */ -public abstract class AcElementListenerV2 implements AutomationCompositionElementListener { +public abstract class AcElementListenerV2 + implements AutomationCompositionElementListener, AutomationCompositionElementListenerV2 { protected final ParticipantIntermediaryApi intermediaryApi; private static final String NOT_SUPPORTED = "not supported!"; @@ -98,6 +99,13 @@ public abstract class AcElementListenerV2 implements AutomationCompositionElemen @Override public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget, + InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate, int stage) + throws PfModelException { + migrate(compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate); + } + + @Override + public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException { intermediaryApi.updateAutomationCompositionElementState(instanceElementMigrate.instanceId(), diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3.java new file mode 100644 index 000000000..d63323d1a --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AcElementListenerV3.java @@ -0,0 +1,119 @@ +/*-
+ * ============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.acm.participant.intermediary.api.impl;
+
+import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto;
+import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+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.StateChangeResult;
+import org.onap.policy.models.base.PfModelException;
+
+/**
+ * Wrapper of AutomationCompositionElementListener.
+ * Valid since 8.0.1 release.
+ */
+public abstract class AcElementListenerV3 implements AutomationCompositionElementListener {
+ protected final ParticipantIntermediaryApi intermediaryApi;
+
+ protected AcElementListenerV3(ParticipantIntermediaryApi intermediaryApi) {
+ this.intermediaryApi = intermediaryApi;
+ }
+
+ @Override
+ public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
+ }
+
+ @Override
+ public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
+ }
+
+ @Override
+ public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
+ }
+
+ @Override
+ public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementUpdated) throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Update not supported");
+
+ }
+
+ @Override
+ public void prime(CompositionDto composition) throws PfModelException {
+ intermediaryApi.updateCompositionState(composition.compositionId(), AcTypeState.PRIMED,
+ StateChangeResult.NO_ERROR, "Primed");
+ }
+
+ @Override
+ public void deprime(CompositionDto composition) throws PfModelException {
+ intermediaryApi.updateCompositionState(composition.compositionId(), AcTypeState.COMMISSIONED,
+ StateChangeResult.NO_ERROR, "Deprimed");
+ }
+
+ @Override
+ public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
+ InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate, int stage)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElementMigrate.instanceId(),
+ instanceElementMigrate.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ }
+
+ @Override
+ public void migratePrecheck(CompositionElementDto compositionElement,
+ CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementMigrate) throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElementMigrate.instanceId(),
+ instanceElementMigrate.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Migration Precheck completed");
+ }
+
+ @Override
+ public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Review completed");
+ }
+
+ @Override
+ public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null,
+ StateChangeResult.NO_ERROR, "Prepare completed");
+ }
+}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerV2.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerV2.java new file mode 100644 index 000000000..721caa88e --- /dev/null +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/AutomationCompositionElementListenerV2.java @@ -0,0 +1,58 @@ +/*- + * ============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.acm.participant.intermediary.api.impl; + +import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionDto; +import org.onap.policy.clamp.acm.participant.intermediary.api.CompositionElementDto; +import org.onap.policy.clamp.acm.participant.intermediary.api.InstanceElementDto; +import org.onap.policy.models.base.PfModelException; + +public interface AutomationCompositionElementListenerV2 { + + void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException; + + void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException; + + void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException; + + void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException; + + void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException; + + void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement, + InstanceElementDto instanceElementUpdated) throws PfModelException; + + void prime(CompositionDto composition) throws PfModelException; + + void deprime(CompositionDto composition) throws PfModelException; + + void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget, + InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException; + + void migratePrecheck(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget, + InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) throws PfModelException; + + void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement) + throws PfModelException; + + void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement) + throws PfModelException; +} diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java index 5cdbacab6..e1bd06465 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -50,16 +50,22 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp private final CacheProvider cacheProvider; @Override - public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState newState, + public void updateAutomationCompositionElementState(UUID instance, UUID elementId, DeployState deployState, LockState lockState, StateChangeResult stateChangeResult, String message) { - automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, newState, - lockState, stateChangeResult, message); + automationCompositionHandler.updateAutomationCompositionElementState(instance, elementId, deployState, + lockState, stateChangeResult, message); } @Override - public void sendAcElementInfo(UUID automationCompositionId, UUID elementId, String useState, + public void updateAutomationCompositionElementStage(UUID instance, UUID elementId, + StateChangeResult stateChangeResult, int stage, String message) { + // + } + + @Override + public void sendAcElementInfo(UUID instance, UUID elementId, String useState, String operationalState, Map<String, Object> outProperties) { - automationCompositionHandler.sendAcElementInfo(automationCompositionId, elementId, useState, operationalState, + automationCompositionHandler.sendAcElementInfo(instance, elementId, useState, operationalState, outProperties); } @@ -75,8 +81,8 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp } @Override - public AutomationCompositionElement getAutomationCompositionElement(UUID automationCompositionId, UUID elementId) { - var automationComposition = cacheProvider.getAutomationCompositions().get(automationCompositionId); + public AutomationCompositionElement getAutomationCompositionElement(UUID instanceId, UUID elementId) { + var automationComposition = cacheProvider.getAutomationCompositions().get(instanceId); if (automationComposition == null) { return null; } @@ -91,8 +97,8 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp } @Override - public AutomationComposition getAutomationComposition(UUID automationCompositionId) { - var automationComposition = cacheProvider.getAutomationCompositions().get(automationCompositionId); + public AutomationComposition getAutomationComposition(UUID instanceId) { + var automationComposition = cacheProvider.getAutomationCompositions().get(instanceId); return automationComposition != null ? new AutomationComposition(automationComposition) : null; } @@ -107,7 +113,7 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp UUID compositionId) { var acElementDefinitions = cacheProvider.getAcElementsDefinitions().get(compositionId); if (acElementDefinitions == null) { - return null; + return Map.of(); } return PfUtils.mapMap(acElementDefinitions, AutomationCompositionElementDefinition::new); } diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandler.java index e6c2d379c..24b7f3adc 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/ThreadHandler.java @@ -309,7 +309,7 @@ public class ThreadHandler implements Closeable { CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) { try { - listener.migrate(compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate); + listener.migrate(compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate, 0); } catch (PfModelException e) { LOGGER.error("Automation composition element migrate failed {} {}", instanceElement.elementId(), e.getMessage()); |