summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-02-14 16:30:56 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2024-02-15 15:29:53 +0000
commite0a13196ebb34c84931df27ba00cd1778adbceb9 (patch)
tree64f1af69d7802ee41a08278ec1e84b21241c1fb5 /participant/participant-impl
parent665815fc5c91c3437a0b0459448994789464a391 (diff)
Add old properties and new properties support
Add old/new properties support in migrate and update, and add Java code backward compatibility. Issue-ID: POLICY-4930 Change-Id: I640bc2a858969168b13fe6cdbb557ebf920bafd5 Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl')
-rw-r--r--participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java72
-rw-r--r--participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java86
-rw-r--r--participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java69
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java20
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java8
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java78
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java213
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java130
8 files changed, 250 insertions, 426 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
index 02697facc..75f3edb0a 100644
--- a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2023 Nordix Foundation.
+ * Copyright (C) 2022-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.
@@ -23,22 +23,18 @@ package org.onap.policy.clamp.acm.participant.a1pms.handler;
import jakarta.validation.Validation;
import jakarta.validation.ValidationException;
import java.lang.invoke.MethodHandles;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import lombok.AccessLevel;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
import org.apache.http.HttpStatus;
import org.onap.policy.clamp.acm.participant.a1pms.exception.A1PolicyServiceException;
import org.onap.policy.clamp.acm.participant.a1pms.models.ConfigurationEntity;
import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient;
-import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
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.AutomationCompositionElementDefinition;
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;
@@ -55,21 +51,24 @@ import org.springframework.stereotype.Component;
* This class handles implementation of automationCompositionElement updates.
*/
@Component
-@RequiredArgsConstructor
-public class AutomationCompositionElementHandler implements AutomationCompositionElementListener {
+public class AutomationCompositionElementHandler extends AcElementListenerV1 {
private static final Coder CODER = new StandardCoder();
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final ParticipantIntermediaryApi intermediaryApi;
-
private final AcA1PmsClient acA1PmsClient;
// Map of acElement Id and A1PMS services
@Getter(AccessLevel.PACKAGE)
private final Map<UUID, ConfigurationEntity> configRequestMap = new ConcurrentHashMap<>();
+ public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi,
+ AcA1PmsClient acA1PmsClient) {
+ super(intermediaryApi);
+ this.acA1PmsClient = acA1PmsClient;
+ }
+
/**
* Handle a automation composition element state change.
*
@@ -128,52 +127,6 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
@Override
- public void lock(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
- StateChangeResult.NO_ERROR, "Locked");
- }
-
- @Override
- public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
- StateChangeResult.NO_ERROR, "Unlocked");
- }
-
- @Override
- public void delete(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, DeployState.DELETED, null,
- StateChangeResult.NO_ERROR, "Deleted");
- }
-
- @Override
- public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, element.getId(), DeployState.DEPLOYED, null,
- StateChangeResult.NO_ERROR, "Update not supported");
- }
-
- @Override
- public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
- throws PfModelException {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed");
- }
-
- @Override
- public void deprime(UUID compositionId) throws PfModelException {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
- "Deprimed");
- }
-
- @Override
- public void handleRestartComposition(UUID compositionId,
- List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
- throws PfModelException {
- var finalState = AcTypeState.PRIMED.equals(state) || AcTypeState.PRIMING.equals(state) ? AcTypeState.PRIMED
- : AcTypeState.COMMISSIONED;
- intermediaryApi.updateCompositionState(compositionId, finalState, StateChangeResult.NO_ERROR, "Restarted");
- }
-
- @Override
public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
if (DeployState.DEPLOYING.equals(deployState)) {
@@ -198,11 +151,4 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState,
lockState, StateChangeResult.NO_ERROR, "Restarted");
}
-
- @Override
- public void migrate(UUID automationCompositionId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
- }
}
diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java
index 883b8a17b..752b8d938 100644
--- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation.
+ * Copyright (C) 2021-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.
@@ -23,22 +23,16 @@ package org.onap.policy.clamp.acm.participant.http.main.handler;
import jakarta.validation.Validation;
import jakarta.ws.rs.core.Response.Status;
import java.lang.invoke.MethodHandles;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
-import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest;
import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient;
-import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
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.AutomationCompositionElementDefinition;
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.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -52,17 +46,19 @@ import org.springframework.stereotype.Component;
* This class handles implementation of automationCompositionElement updates.
*/
@Component
-@RequiredArgsConstructor
-public class AutomationCompositionElementHandler implements AutomationCompositionElementListener {
+public class AutomationCompositionElementHandler extends AcElementListenerV1 {
private static final Coder CODER = new StandardCoder();
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final ParticipantIntermediaryApi intermediaryApi;
-
private final AcHttpClient acHttpClient;
+ public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi, AcHttpClient acHttpClient) {
+ super(intermediaryApi);
+ this.acHttpClient = acHttpClient;
+ }
+
/**
* Handle a automation composition element state change.
*
@@ -119,70 +115,4 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
throw new AutomationCompositionException(Status.BAD_REQUEST, "Error extracting ConfigRequest ", e);
}
}
-
- @Override
- public void lock(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
- StateChangeResult.NO_ERROR, "Locked");
- }
-
- @Override
- public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
- StateChangeResult.NO_ERROR, "Unlocked");
- }
-
- @Override
- public void delete(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, DeployState.DELETED, null,
- StateChangeResult.NO_ERROR, "Deleted");
- }
-
- @Override
- public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, element.getId(), DeployState.DEPLOYED, null,
- StateChangeResult.NO_ERROR, "Update not supported");
- }
-
- @Override
- public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
- throws PfModelException {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed");
- }
-
- @Override
- public void deprime(UUID compositionId) throws PfModelException {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
- "Deprimed");
- }
-
- @Override
- public void handleRestartComposition(UUID compositionId,
- List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
- throws PfModelException {
- var finalState = AcTypeState.PRIMED.equals(state) || AcTypeState.PRIMING.equals(state) ? AcTypeState.PRIMED
- : AcTypeState.COMMISSIONED;
- intermediaryApi.updateCompositionState(compositionId, finalState, StateChangeResult.NO_ERROR, "Restarted");
- }
-
- @Override
- public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
- Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
- if (DeployState.DEPLOYING.equals(deployState)) {
- deploy(automationCompositionId, element, properties);
- return;
- }
- deployState = AcmUtils.deployCompleted(deployState);
- lockState = AcmUtils.lockCompleted(deployState, lockState);
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState,
- lockState, StateChangeResult.NO_ERROR, "Restarted");
- }
-
- @Override
- public void migrate(UUID automationCompositionId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
- }
}
diff --git a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java
index 417b60978..d4b09c923 100644
--- a/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java
@@ -26,7 +26,6 @@ import jakarta.validation.Validation;
import jakarta.validation.ValidationException;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -36,18 +35,15 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import lombok.AccessLevel;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
import org.apache.http.HttpStatus;
-import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
import org.onap.policy.clamp.acm.participant.kserve.exception.KserveException;
import org.onap.policy.clamp.acm.participant.kserve.k8s.InferenceServiceValidator;
import org.onap.policy.clamp.acm.participant.kserve.k8s.KserveClient;
import org.onap.policy.clamp.acm.participant.kserve.models.ConfigurationEntity;
import org.onap.policy.clamp.acm.participant.kserve.models.KserveInferenceEntity;
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.AutomationCompositionElementDefinition;
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;
@@ -64,8 +60,7 @@ import org.springframework.stereotype.Component;
* This class handles implementation of automationCompositionElement updates.
*/
@Component
-@RequiredArgsConstructor
-public class AutomationCompositionElementHandler implements AutomationCompositionElementListener {
+public class AutomationCompositionElementHandler extends AcElementListenerV1 {
private static final Coder CODER = new StandardCoder();
@@ -74,13 +69,16 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
private ExecutorService executor = Context.taskWrapping(
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
- private final ParticipantIntermediaryApi intermediaryApi;
-
private final KserveClient kserveClient;
@Getter(AccessLevel.PACKAGE)
private final Map<UUID, ConfigurationEntity> configRequestMap = new ConcurrentHashMap<>();
+ public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi, KserveClient kserveClient) {
+ super(intermediaryApi);
+ this.kserveClient = kserveClient;
+ }
+
private static class ThreadConfig {
private int uninitializedToPassiveTimeout = 60;
@@ -174,52 +172,6 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
@Override
- public void lock(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
- StateChangeResult.NO_ERROR, "Locked");
- }
-
- @Override
- public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
- StateChangeResult.NO_ERROR, "Unlocked");
- }
-
- @Override
- public void delete(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, DeployState.DELETED, null,
- StateChangeResult.NO_ERROR, "Deleted");
- }
-
- @Override
- public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, element.getId(), DeployState.DEPLOYED, null,
- StateChangeResult.NO_ERROR, "Update not supported");
- }
-
- @Override
- public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
- throws PfModelException {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed");
- }
-
- @Override
- public void deprime(UUID compositionId) throws PfModelException {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
- "Deprimed");
- }
-
- @Override
- public void handleRestartComposition(UUID compositionId,
- List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
- throws PfModelException {
- var finalState = AcTypeState.PRIMED.equals(state) || AcTypeState.PRIMING.equals(state) ? AcTypeState.PRIMED
- : AcTypeState.COMMISSIONED;
- intermediaryApi.updateCompositionState(compositionId, finalState, StateChangeResult.NO_ERROR, "Restarted");
- }
-
- @Override
public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
if (DeployState.DEPLOYING.equals(deployState)) {
@@ -244,11 +196,4 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState,
lockState, StateChangeResult.NO_ERROR, "Restarted");
}
-
- @Override
- public void migrate(UUID automationCompositionId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
- }
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
index d6ce70ce1..ae8e47461 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation.
+ * Copyright (C) 2021-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.
@@ -31,8 +31,8 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import lombok.AccessLevel;
import lombok.Getter;
-import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException;
import org.onap.policy.clamp.acm.participant.kubernetes.helm.PodStatusValidator;
import org.onap.policy.clamp.acm.participant.kubernetes.models.ChartInfo;
@@ -58,7 +58,7 @@ import org.springframework.stereotype.Component;
* This class handles implementation of automationCompositionElement updates.
*/
@Component
-public class AutomationCompositionElementHandler implements AutomationCompositionElementListener {
+public class AutomationCompositionElementHandler extends AcElementListenerV1 {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// Map of helm installation and the status of corresponding pods
@@ -69,13 +69,14 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
@Autowired
private ChartService chartService;
- @Autowired
- private ParticipantIntermediaryApi intermediaryApi;
-
// Map of acElement Id and installed Helm charts
@Getter(AccessLevel.PACKAGE)
private final Map<UUID, ChartInfo> chartMap = new HashMap<>();
+ public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi) {
+ super(intermediaryApi);
+ }
+
// Default thread config values
private static class ThreadConfig {
private int uninitializedToPassiveTimeout = 60;
@@ -249,11 +250,4 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState,
lockState, StateChangeResult.NO_ERROR, "Restarted");
}
-
- @Override
- public void migrate(UUID automationCompositionId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
- }
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
index fb8a04602..14b505f66 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/handler/AutomationCompositionElementHandlerTest.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");
@@ -29,6 +29,7 @@ import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
import java.io.File;
import java.io.IOException;
@@ -78,15 +79,12 @@ class AutomationCompositionElementHandlerTest {
@InjectMocks
@Spy
private AutomationCompositionElementHandler automationCompositionElementHandler =
- new AutomationCompositionElementHandler();
+ new AutomationCompositionElementHandler(mock(ParticipantIntermediaryApi.class));
@Mock
private ChartService chartService;
@Mock
- private ParticipantIntermediaryApi participantIntermediaryApi;
-
- @Mock
private ExecutorService executor;
@Mock
private Future<String> result;
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
index 281fe3e01..d66ab3154 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/acm/participant/policy/main/handler/AutomationCompositionElementHandler.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.
* ================================================================================
@@ -28,15 +28,12 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
-import lombok.RequiredArgsConstructor;
import org.apache.http.HttpStatus;
-import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener;
import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi;
+import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyApiHttpClient;
import org.onap.policy.clamp.acm.participant.policy.client.PolicyPapHttpClient;
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.AutomationCompositionElementDefinition;
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;
@@ -53,8 +50,7 @@ import org.springframework.stereotype.Component;
* This class handles implementation of automationCompositionElement updates.
*/
@Component
-@RequiredArgsConstructor
-public class AutomationCompositionElementHandler implements AutomationCompositionElementListener {
+public class AutomationCompositionElementHandler extends AcElementListenerV1 {
private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandler.class);
@@ -62,7 +58,20 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
private final PolicyApiHttpClient apiHttpClient;
private final PolicyPapHttpClient papHttpClient;
- private final ParticipantIntermediaryApi intermediaryApi;
+
+ /**
+ * Constructor.
+ *
+ * @param apiHttpClient the PolicyApi Http Client
+ * @param papHttpClient the Policy Pap Http Client
+ * @param intermediaryApi the Participant Intermediary Api
+ */
+ public AutomationCompositionElementHandler(PolicyApiHttpClient apiHttpClient, PolicyPapHttpClient papHttpClient,
+ ParticipantIntermediaryApi intermediaryApi) {
+ super(intermediaryApi);
+ this.apiHttpClient = apiHttpClient;
+ this.papHttpClient = papHttpClient;
+ }
/**
* Callback method to handle a automation composition element state change.
@@ -214,52 +223,6 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
@Override
- public void lock(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
- StateChangeResult.NO_ERROR, "Locked");
- }
-
- @Override
- public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
- StateChangeResult.NO_ERROR, "Unlocked");
- }
-
- @Override
- public void delete(UUID instanceId, UUID elementId) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, DeployState.DELETED, null,
- StateChangeResult.NO_ERROR, "Deleted");
- }
-
- @Override
- public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(instanceId, element.getId(), DeployState.DEPLOYED, null,
- StateChangeResult.NO_ERROR, "Update not supported");
- }
-
- @Override
- public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
- throws PfModelException {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed");
- }
-
- @Override
- public void deprime(UUID compositionId) throws PfModelException {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
- "Deprimed");
- }
-
- @Override
- public void handleRestartComposition(UUID compositionId,
- List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
- throws PfModelException {
- var finalState = AcTypeState.PRIMED.equals(state) || AcTypeState.PRIMING.equals(state) ? AcTypeState.PRIMED
- : AcTypeState.COMMISSIONED;
- intermediaryApi.updateCompositionState(compositionId, finalState, StateChangeResult.NO_ERROR, "Restarted");
- }
-
- @Override
public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
if (DeployState.DEPLOYING.equals(deployState)) {
@@ -280,11 +243,4 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState,
lockState, StateChangeResult.NO_ERROR, "Restarted");
}
-
- @Override
- public void migrate(UUID automationCompositionId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
- }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
index 7409c1137..2cba379c4 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 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.
@@ -22,21 +22,20 @@ package org.onap.policy.clamp.acm.participant.sim.main.handler;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
import lombok.Setter;
-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.acm.participant.intermediary.api.impl.AcElementListenerV2;
import org.onap.policy.clamp.acm.participant.sim.model.InternalData;
import org.onap.policy.clamp.acm.participant.sim.model.InternalDatas;
import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
-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.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
@@ -52,41 +51,43 @@ import org.springframework.stereotype.Component;
* This class handles implementation of automationCompositionElement updates.
*/
@Component
-@RequiredArgsConstructor
-public class AutomationCompositionElementHandler implements AutomationCompositionElementListener {
+public class AutomationCompositionElementHandler extends AcElementListenerV2 {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final ParticipantIntermediaryApi intermediaryApi;
-
@Getter
@Setter
private SimConfig config = new SimConfig();
+ public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi) {
+ super(intermediaryApi);
+ }
+
/**
- * Callback method to handle an update on a automation composition element.
+ * Handle a deploy on a automation composition element.
*
- * @param automationCompositionId the automationComposition Id
- * @param element the information on the automation composition element
- * @param properties properties Map
- * @throws PfModelException in case of a exception
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ * @throws PfModelException from Policy framework
*/
@Override
- public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
throws PfModelException {
- LOGGER.debug("deploy call");
+ LOGGER.debug("deploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
if (!execution(config.getDeployTimerMs(), "Current Thread deploy is Interrupted during execution {}",
- element.getId())) {
+ instanceElement.elementId())) {
return;
}
if (config.isDeploySuccess()) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Deployed");
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Deploy failed!");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+ "Deploy failed!");
}
}
@@ -111,99 +112,108 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
/**
* Handle a automation composition element state change.
*
- * @param automationCompositionElementId the ID of the automation composition element
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ * @throws PfModelException from Policy framework
*/
@Override
- public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
- LOGGER.debug("undeploy call");
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ LOGGER.debug("undeploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
if (!execution(config.getUndeployTimerMs(), "Current Thread undeploy is Interrupted during execution {}",
- automationCompositionElementId)) {
+ instanceElement.elementId())) {
return;
}
if (config.isUndeploySuccess()) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
"Undeployed");
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.DEPLOYED, null, StateChangeResult.FAILED,
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DEPLOYED, null, StateChangeResult.FAILED,
"Undeploy failed!");
}
}
@Override
- public void lock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
- LOGGER.debug("lock call");
+ public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ LOGGER.debug("lock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
if (!execution(config.getLockTimerMs(), "Current Thread lock is Interrupted during execution {}",
- automationCompositionElementId)) {
+ instanceElement.elementId())) {
return;
}
if (config.isLockSuccess()) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, null, LockState.UNLOCKED, StateChangeResult.FAILED, "Lock failed!");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.FAILED, "Lock failed!");
}
}
@Override
- public void unlock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
- LOGGER.debug("unlock call");
+ public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ LOGGER.debug("unlock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
if (!execution(config.getUnlockTimerMs(), "Current Thread unlock is Interrupted during execution {}",
- automationCompositionElementId)) {
+ instanceElement.elementId())) {
return;
}
if (config.isUnlockSuccess()) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, null, LockState.LOCKED, StateChangeResult.FAILED, "Unlock failed!");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), null, LockState.LOCKED, StateChangeResult.FAILED, "Unlock failed!");
}
}
@Override
- public void delete(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
- LOGGER.debug("delete call");
+ public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
+ throws PfModelException {
+ LOGGER.debug("delete call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
if (!execution(config.getDeleteTimerMs(), "Current Thread delete is Interrupted during execution {}",
- automationCompositionElementId)) {
+ instanceElement.elementId())) {
return;
}
if (config.isDeleteSuccess()) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
- automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
- "Delete failed!");
+ intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
+ instanceElement.elementId(), DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+ "Delete failed!");
}
}
@Override
- public void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
- LOGGER.debug("update call");
+ public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementUpdated) throws PfModelException {
+ LOGGER.debug("update call compositionElement: {}, instanceElement: {}, instanceElementUpdated: {}",
+ compositionElement, instanceElement, instanceElementUpdated);
if (!execution(config.getUpdateTimerMs(), "Current Thread update is Interrupted during execution {}",
- element.getId())) {
+ instanceElement.elementId())) {
return;
}
if (config.isUpdateSuccess()) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceElement.instanceId(), instanceElement.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Update failed!");
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceElement.instanceId(), instanceElement.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Update failed!");
}
}
@@ -238,39 +248,38 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
@Override
- public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
- throws PfModelException {
- LOGGER.debug("prime call");
+ public void prime(CompositionDto composition) throws PfModelException {
+ LOGGER.debug("prime call composition: {}", composition);
if (!execution(config.getPrimeTimerMs(), "Current Thread prime is Interrupted during execution {}",
- compositionId)) {
+ composition.compositionId())) {
return;
}
if (config.isPrimeSuccess()) {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
- "Primed");
+ intermediaryApi.updateCompositionState(composition.compositionId(),
+ AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed");
} else {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.FAILED,
- "Prime failed!");
+ intermediaryApi.updateCompositionState(composition.compositionId(),
+ AcTypeState.COMMISSIONED, StateChangeResult.FAILED, "Prime failed!");
}
}
@Override
- public void deprime(UUID compositionId) throws PfModelException {
- LOGGER.debug("deprime call");
+ public void deprime(CompositionDto composition) throws PfModelException {
+ LOGGER.debug("deprime call composition: {}", composition);
if (!execution(config.getDeprimeTimerMs(), "Current Thread deprime is Interrupted during execution {}",
- compositionId)) {
+ composition.compositionId())) {
return;
}
if (config.isDeprimeSuccess()) {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
- "Deprimed");
+ intermediaryApi.updateCompositionState(composition.compositionId(), AcTypeState.COMMISSIONED,
+ StateChangeResult.NO_ERROR, "Deprimed");
} else {
- intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.FAILED,
- "Deprime failed!");
+ intermediaryApi.updateCompositionState(composition.compositionId(), AcTypeState.PRIMED,
+ StateChangeResult.FAILED, "Deprime failed!");
}
}
@@ -286,6 +295,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
for (var element : instance.getElements().values()) {
var data = new InternalData();
data.setCompositionId(instance.getCompositionId());
+ data.setCompositionDefinitionElementId(element.getDefinition());
data.setAutomationCompositionId(instance.getInstanceId());
data.setAutomationCompositionElementId(element.getId());
data.setIntProperties(element.getProperties());
@@ -299,55 +309,55 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
@Override
- public void handleRestartComposition(UUID compositionId,
- List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
- throws PfModelException {
+ public void handleRestartComposition(CompositionDto composition, AcTypeState state) throws PfModelException {
LOGGER.debug("restart composition definition call");
switch (state) {
case PRIMING:
- prime(compositionId, elementDefinitionList);
+ prime(composition);
break;
case DEPRIMING:
- deprime(compositionId);
+ deprime(composition);
break;
default:
- intermediaryApi.updateCompositionState(compositionId, state, StateChangeResult.NO_ERROR, "Restarted");
+ intermediaryApi.updateCompositionState(composition.compositionId(), state,
+ StateChangeResult.NO_ERROR, "Restarted");
}
}
@Override
- public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
- Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
+ public void handleRestartInstance(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
+ DeployState deployState, LockState lockState) throws PfModelException {
LOGGER.debug("restart instance call");
if (!AcmUtils.isInTransitionalState(deployState, lockState)) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- deployState, lockState, StateChangeResult.NO_ERROR, "Restarted");
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceElement.instanceId(), instanceElement.elementId(), deployState, lockState,
+ StateChangeResult.NO_ERROR, "Restarted");
return;
}
if (DeployState.DEPLOYING.equals(deployState)) {
- deploy(automationCompositionId, element, properties);
+ deploy(compositionElement, instanceElement);
return;
}
if (DeployState.UNDEPLOYING.equals(deployState)) {
- undeploy(automationCompositionId, element.getId());
+ undeploy(compositionElement, instanceElement);
return;
}
if (DeployState.UPDATING.equals(deployState)) {
- update(automationCompositionId, element, properties);
+ update(compositionElement, instanceElement, instanceElement);
return;
}
if (DeployState.DELETING.equals(deployState)) {
- delete(automationCompositionId, element.getId());
+ delete(compositionElement, instanceElement);
return;
}
if (LockState.LOCKING.equals(lockState)) {
- lock(automationCompositionId, element.getId());
+ lock(compositionElement, instanceElement);
return;
}
if (LockState.UNLOCKING.equals(lockState)) {
- unlock(automationCompositionId, element.getId());
+ unlock(compositionElement, instanceElement);
}
}
@@ -380,21 +390,26 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
@Override
- public void migrate(UUID automationCompositionId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
- LOGGER.debug("migrate call");
+ public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
+ InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate)
+ throws PfModelException {
+ LOGGER.debug("migrate call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ + " instanceElementMigrate: {}",
+ compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
if (!execution(config.getMigrateTimerMs(), "Current Thread migrate is Interrupted during execution {}",
- element.getId())) {
+ instanceElement.elementId())) {
return;
}
if (config.isMigrateSuccess()) {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceElement.instanceId(), instanceElement.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
} else {
- intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceElement.instanceId(), instanceElement.elementId(),
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
}
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
index d7c9e17ad..d63405369 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 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.
@@ -26,10 +26,12 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.jupiter.api.Test;
+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.acm.participant.sim.comm.CommonTestData;
import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
@@ -52,17 +54,19 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
var instanceId = UUID.randomUUID();
- var element = new AcElementDeploy();
- element.setId(UUID.randomUUID());
- acElementHandler.deploy(instanceId, element, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+ var elementId = UUID.randomUUID();
+ var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
+ acElementHandler.deploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DEPLOYED,
+ null, StateChangeResult.NO_ERROR, "Deployed");
config.setDeploySuccess(false);
- acElementHandler.deploy(instanceId, element, Map.of());
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
- DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Deploy failed!");
+ acElementHandler.deploy(compositionElement, instanceElement);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
+ null, StateChangeResult.FAILED, "Deploy failed!");
}
@Test
@@ -72,14 +76,17 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
var instanceId = UUID.randomUUID();
var elementId = UUID.randomUUID();
- acElementHandler.undeploy(instanceId, elementId);
+ var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
+ acElementHandler.undeploy(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
null, StateChangeResult.NO_ERROR, "Undeployed");
config.setUndeploySuccess(false);
- acElementHandler.undeploy(instanceId, elementId);
+ acElementHandler.undeploy(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DEPLOYED,
null, StateChangeResult.FAILED, "Undeploy failed!");
}
@@ -91,14 +98,17 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
var instanceId = UUID.randomUUID();
var elementId = UUID.randomUUID();
- acElementHandler.lock(instanceId, elementId);
+ var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
+ acElementHandler.lock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
StateChangeResult.NO_ERROR, "Locked");
config.setLockSuccess(false);
- acElementHandler.lock(instanceId, elementId);
+ acElementHandler.lock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
StateChangeResult.FAILED, "Lock failed!");
}
@@ -110,14 +120,17 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
var instanceId = UUID.randomUUID();
var elementId = UUID.randomUUID();
- acElementHandler.unlock(instanceId, elementId);
+ var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
+ acElementHandler.unlock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED,
StateChangeResult.NO_ERROR, "Unlocked");
config.setUnlockSuccess(false);
- acElementHandler.unlock(instanceId, elementId);
+ acElementHandler.unlock(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED,
StateChangeResult.FAILED, "Unlock failed!");
}
@@ -129,15 +142,20 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
var instanceId = UUID.randomUUID();
var element = new AcElementDeploy();
element.setId(UUID.randomUUID());
- acElementHandler.update(instanceId, element, Map.of());
+ var instanceElement = new InstanceElementDto(instanceId, element.getId(), null, Map.of(), Map.of());
+ var instanceElementUpdated = new InstanceElementDto(instanceId, element.getId(), null,
+ Map.of("key", "value"), Map.of());
+ acElementHandler.update(compositionElement, instanceElement, instanceElementUpdated);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
config.setUpdateSuccess(false);
- acElementHandler.update(instanceId, element, Map.of());
+ acElementHandler.update(compositionElement, instanceElement, instanceElementUpdated);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Update failed!");
}
@@ -149,14 +167,17 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
var instanceId = UUID.randomUUID();
var elementId = UUID.randomUUID();
- acElementHandler.delete(instanceId, elementId);
+ var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
+ acElementHandler.delete(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.DELETED,
null, StateChangeResult.NO_ERROR, "Deleted");
config.setDeleteSuccess(false);
- acElementHandler.delete(instanceId, elementId);
+ acElementHandler.delete(compositionElement, instanceElement);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, DeployState.UNDEPLOYED,
null, StateChangeResult.FAILED, "Delete failed!");
}
@@ -221,12 +242,13 @@ class AutomationCompositionElementHandlerTest {
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
var compositionId = UUID.randomUUID();
- acElementHandler.prime(compositionId, List.of());
+ var composition = new CompositionDto(compositionId, Map.of(), Map.of());
+ acElementHandler.prime(composition);
verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
"Primed");
config.setPrimeSuccess(false);
- acElementHandler.prime(compositionId, List.of());
+ acElementHandler.prime(composition);
verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
StateChangeResult.FAILED, "Prime failed!");
}
@@ -239,12 +261,13 @@ class AutomationCompositionElementHandlerTest {
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
var compositionId = UUID.randomUUID();
- acElementHandler.deprime(compositionId);
+ var composition = new CompositionDto(compositionId, Map.of(), Map.of());
+ acElementHandler.deprime(composition);
verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
StateChangeResult.NO_ERROR, "Deprimed");
config.setDeprimeSuccess(false);
- acElementHandler.deprime(compositionId);
+ acElementHandler.deprime(composition);
verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.FAILED,
"Deprime failed!");
}
@@ -257,15 +280,16 @@ class AutomationCompositionElementHandlerTest {
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
var compositionId = UUID.randomUUID();
- acElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.PRIMING);
+ var composition = new CompositionDto(compositionId, Map.of(), Map.of());
+ acElementHandler.handleRestartComposition(composition, AcTypeState.PRIMING);
verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
"Primed");
- acElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.PRIMED);
+ acElementHandler.handleRestartComposition(composition, AcTypeState.PRIMED);
verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
"Restarted");
- acElementHandler.handleRestartComposition(compositionId, List.of(), AcTypeState.DEPRIMING);
+ acElementHandler.handleRestartComposition(composition, AcTypeState.DEPRIMING);
verify(intermediaryApi).updateCompositionState(compositionId, AcTypeState.COMMISSIONED,
StateChangeResult.NO_ERROR, "Deprimed");
}
@@ -278,36 +302,43 @@ class AutomationCompositionElementHandlerTest {
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
var instanceId = UUID.randomUUID();
- var element = new AcElementDeploy();
- element.setId(UUID.randomUUID());
- acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DEPLOYING, LockState.NONE);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ var elementId = UUID.randomUUID();
+ var instanceElement = new InstanceElementDto(instanceId, elementId, null, Map.of(), Map.of());
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ acElementHandler.handleRestartInstance(compositionElement, instanceElement,
+ DeployState.DEPLOYING, LockState.NONE);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId,
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
- acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DEPLOYED, LockState.LOCKED);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ acElementHandler.handleRestartInstance(compositionElement, instanceElement,
+ DeployState.DEPLOYED, LockState.LOCKED);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId,
DeployState.DEPLOYED, LockState.LOCKED, StateChangeResult.NO_ERROR, "Restarted");
- acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.UPDATING, LockState.LOCKED);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ acElementHandler.handleRestartInstance(compositionElement, instanceElement,
+ DeployState.UPDATING, LockState.LOCKED);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId,
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
- acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.UNDEPLOYING,
+ acElementHandler.handleRestartInstance(compositionElement, instanceElement, DeployState.UNDEPLOYING,
LockState.LOCKED);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId,
DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Undeployed");
- acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DELETING, LockState.NONE);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
+ acElementHandler.handleRestartInstance(compositionElement, instanceElement,
+ DeployState.DELETING, LockState.NONE);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId,
DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
- acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DEPLOYED, LockState.LOCKING);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), null,
+ acElementHandler.handleRestartInstance(compositionElement, instanceElement,
+ DeployState.DEPLOYED, LockState.LOCKING);
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null,
LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
- acElementHandler.handleRestartInstance(instanceId, element, Map.of(), DeployState.DEPLOYED,
+ acElementHandler.handleRestartInstance(compositionElement, instanceElement, DeployState.DEPLOYED,
LockState.UNLOCKING);
- verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), null,
+ verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, elementId, null,
LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
}
@@ -353,15 +384,24 @@ class AutomationCompositionElementHandlerTest {
var intermediaryApi = mock(ParticipantIntermediaryApi.class);
var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
acElementHandler.setConfig(config);
+ var compositionElement = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
+ var compositionElementTraget = new CompositionElementDto(UUID.randomUUID(), new ToscaConceptIdentifier(),
+ Map.of(), Map.of());
var instanceId = UUID.randomUUID();
var element = new AcElementDeploy();
element.setId(UUID.randomUUID());
- acElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of());
+ var instanceElement = new InstanceElementDto(instanceId, element.getId(), null, Map.of(), Map.of());
+ var instanceElementMigrated = new InstanceElementDto(instanceId, element.getId(),
+ null, Map.of("key", "value"), Map.of());
+ acElementHandler
+ .migrate(compositionElement, compositionElementTraget, instanceElement, instanceElementMigrated);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
config.setMigrateSuccess(false);
- acElementHandler.migrate(instanceId, element, UUID.randomUUID(), Map.of());
+ acElementHandler
+ .migrate(compositionElement, compositionElementTraget, instanceElement, instanceElementMigrated);
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(),
DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
}