aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-simulator/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src/main')
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java8
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java24
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java65
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java165
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java88
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java14
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java4
7 files changed, 324 insertions, 44 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java
index 2a319c3bd..4ddec02e5 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/config/MicrometerConfig.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.
@@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.sim.config;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,8 +35,9 @@ public class MicrometerConfig {
* Load up the metrics registry.
*/
@Bean
- public InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor,
- MeterRegistry registry) {
+ public InitializingBean forcePrometheusPostProcessor(@Qualifier("meterRegistryPostProcessor")
+ BeanPostProcessor meterRegistryPostProcessor,
+ MeterRegistry registry) {
return () -> meterRegistryPostProcessor.postProcessAfterInitialization(registry, "");
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java
index aa9d90e91..534b01b32 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV1.java
@@ -27,7 +27,6 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantInterme
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.AutomationCompositionElementDefinition;
-import org.onap.policy.models.base.PfModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@@ -48,61 +47,58 @@ public class AutomationCompositionElementHandlerV1 extends AcElementListenerV1 {
}
@Override
- public void deploy(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
+ public void deploy(UUID instanceId, AcElementDeploy element, Map<String, Object> properties) {
LOGGER.debug("deploy call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
simulatorService.deploy(instanceId, element.getId());
}
@Override
- public void undeploy(UUID instanceId, UUID elementId) throws PfModelException {
+ public void undeploy(UUID instanceId, UUID elementId) {
LOGGER.debug("undeploy call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.undeploy(instanceId, elementId);
}
@Override
- public void lock(UUID instanceId, UUID elementId) throws PfModelException {
+ public void lock(UUID instanceId, UUID elementId) {
LOGGER.debug("lock call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.lock(instanceId, elementId);
}
@Override
- public void unlock(UUID instanceId, UUID elementId) throws PfModelException {
+ public void unlock(UUID instanceId, UUID elementId) {
LOGGER.debug("unlock call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.unlock(instanceId, elementId);
}
@Override
- public void delete(UUID instanceId, UUID elementId) throws PfModelException {
+ public void delete(UUID instanceId, UUID elementId) {
LOGGER.debug("delete call instanceId: {}, elementId: {}", instanceId, elementId);
simulatorService.delete(instanceId, elementId);
}
@Override
- public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
+ public void update(UUID instanceId, AcElementDeploy element, Map<String, Object> properties) {
LOGGER.debug("update call instanceId: {}, element: {}, properties: {}", instanceId, element, properties);
simulatorService.update(instanceId, element.getId());
}
@Override
- public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
- throws PfModelException {
+ public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList) {
LOGGER.debug("prime call compositionId: {}, elementDefinitionList: {}", compositionId, elementDefinitionList);
simulatorService.prime(compositionId);
}
@Override
- public void deprime(UUID compositionId) throws PfModelException {
+ public void deprime(UUID compositionId) {
LOGGER.debug("deprime call compositionId: {}", compositionId);
simulatorService.deprime(compositionId);
}
@Override
public void migrate(UUID instanceId, AcElementDeploy element, UUID compositionTargetId,
- Map<String, Object> properties) throws PfModelException {
+ Map<String, Object> properties) {
LOGGER.debug("migrate call instanceId: {}, element: {}, compositionTargetId: {}, properties: {}",
instanceId, element, compositionTargetId, properties);
- simulatorService.migrate(instanceId, element.getId());
+ simulatorService.migrate(instanceId, element.getId(), 0, Map.of());
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java
index eaad5d902..82602c1e1 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV2.java
@@ -22,10 +22,10 @@ package org.onap.policy.clamp.acm.participant.sim.main.handler;
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.ElementState;
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.models.base.PfModelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@@ -34,7 +34,7 @@ import org.springframework.stereotype.Component;
/**
* This class handles implementation of automationCompositionElement updates.
*/
-@ConditionalOnExpression("'${element.handler:AcElementHandlerV2}' == 'AcElementHandlerV2'")
+@ConditionalOnExpression("'${element.handler}'=='AcElementHandlerV2'")
@Component
public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 {
@@ -53,11 +53,9 @@ public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 {
*
* @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(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("deploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.deploy(instanceElement.instanceId(), instanceElement.elementId());
}
@@ -67,63 +65,90 @@ public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 {
*
* @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(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("undeploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("lock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.lock(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("unlock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.unlock(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement)
- throws PfModelException {
+ public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
LOGGER.debug("delete call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
- InstanceElementDto instanceElementUpdated) throws PfModelException {
+ InstanceElementDto instanceElementUpdated) {
LOGGER.debug("update call compositionElement: {}, instanceElement: {}, instanceElementUpdated: {}",
compositionElement, instanceElement, instanceElementUpdated);
simulatorService.update(instanceElement.instanceId(), instanceElement.elementId());
}
@Override
- public void prime(CompositionDto composition) throws PfModelException {
+ public void prime(CompositionDto composition) {
LOGGER.debug("prime call composition: {}", composition);
simulatorService.prime(composition.compositionId());
}
@Override
- public void deprime(CompositionDto composition) throws PfModelException {
+ public void deprime(CompositionDto composition) {
LOGGER.debug("deprime call composition: {}", composition);
simulatorService.deprime(composition.compositionId());
}
@Override
public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
- InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate)
- throws PfModelException {
+ InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate) {
LOGGER.debug("migrate call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ " instanceElementMigrate: {}",
compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
- simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId());
+
+ if (ElementState.NEW.equals(instanceElementMigrate.state())) {
+ LOGGER.debug("new element scenario");
+
+ }
+ if (ElementState.REMOVED.equals(instanceElementMigrate.state())) {
+ simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
+ simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
+ } else {
+ simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId(),
+ 0, compositionElementTarget.inProperties());
+ }
+ }
+
+ @Override
+ public void migratePrecheck(CompositionElementDto compositionElement,
+ CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementMigrate) {
+ LOGGER.debug("migrate precheck call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ + " instanceElementMigrate: {}",
+ compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
+ simulatorService.migratePrecheck(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("prepare call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.prepare(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("review call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.review(instanceElement.instanceId(), instanceElement.elementId());
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java
new file mode 100644
index 000000000..e406a6127
--- /dev/null
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerV3.java
@@ -0,0 +1,165 @@
+/*-
+ * ============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.sim.main.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+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.ElementState;
+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.AcElementListenerV3;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class handles implementation of automationCompositionElement updates.
+ */
+@Getter
+@Setter
+@ConditionalOnExpression("'${element.handler:AcElementHandlerV3}' == 'AcElementHandlerV3'")
+@Component
+public class AutomationCompositionElementHandlerV3 extends AcElementListenerV3 {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionElementHandlerV3.class);
+
+ private final SimulatorService simulatorService;
+
+ public AutomationCompositionElementHandlerV3(ParticipantIntermediaryApi intermediaryApi,
+ SimulatorService simulatorService) {
+ super(intermediaryApi);
+ this.simulatorService = simulatorService;
+ }
+
+ /**
+ * Handle a deploy on a automation composition element.
+ *
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ */
+ @Override
+ public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("deploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.deploy(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ /**
+ * Handle a automation composition element state change.
+ *
+ * @param compositionElement the information of the Automation Composition Definition Element
+ * @param instanceElement the information of the Automation Composition Instance Element
+ */
+ @Override
+ public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("undeploy call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void lock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("lock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.lock(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void unlock(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("unlock call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.unlock(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void delete(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("delete call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void update(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementUpdated) {
+ LOGGER.debug("update call compositionElement: {}, instanceElement: {}, instanceElementUpdated: {}",
+ compositionElement, instanceElement, instanceElementUpdated);
+ simulatorService.update(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void prime(CompositionDto composition) {
+ LOGGER.debug("prime call composition: {}", composition);
+ simulatorService.prime(composition.compositionId());
+ }
+
+ @Override
+ public void deprime(CompositionDto composition) {
+ LOGGER.debug("deprime call composition: {}", composition);
+ simulatorService.deprime(composition.compositionId());
+ }
+
+ @Override
+ public void migrate(CompositionElementDto compositionElement, CompositionElementDto compositionElementTarget,
+ InstanceElementDto instanceElement, InstanceElementDto instanceElementMigrate, int stage) {
+ LOGGER.debug("migrate call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ + " instanceElementMigrate: {}, stage: {}",
+ compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate, stage);
+
+ if (ElementState.NEW.equals(instanceElementMigrate.state())) {
+ LOGGER.debug("new element scenario");
+ }
+ if (ElementState.REMOVED.equals(instanceElementMigrate.state())) {
+ simulatorService.undeploy(instanceElement.instanceId(), instanceElement.elementId());
+ simulatorService.delete(instanceElement.instanceId(), instanceElement.elementId());
+ } else {
+ simulatorService.migrate(instanceElementMigrate.instanceId(), instanceElementMigrate.elementId(), stage,
+ compositionElementTarget.inProperties());
+ instanceElementMigrate.outProperties().putIfAbsent("stage", new ArrayList<>());
+ @SuppressWarnings("unchecked")
+ var stageList = (List<Integer>) instanceElementMigrate.outProperties().get("stage");
+ stageList.add(stage);
+ intermediaryApi.sendAcElementInfo(instanceElementMigrate.instanceId(), instanceElementMigrate.elementId(),
+ null, null, instanceElementMigrate.outProperties());
+ }
+ }
+
+ @Override
+ public void migratePrecheck(CompositionElementDto compositionElement,
+ CompositionElementDto compositionElementTarget, InstanceElementDto instanceElement,
+ InstanceElementDto instanceElementMigrate) {
+ LOGGER.debug("migrate precheck call compositionElement: {}, compositionElementTarget: {}, instanceElement: {},"
+ + " instanceElementMigrate: {}",
+ compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate);
+ simulatorService.migratePrecheck(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void prepare(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("prepare call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.prepare(instanceElement.instanceId(), instanceElement.elementId());
+ }
+
+ @Override
+ public void review(CompositionElementDto compositionElement, InstanceElementDto instanceElement) {
+ LOGGER.debug("review call compositionElement: {}, instanceElement: {}", compositionElement, instanceElement);
+ simulatorService.review(instanceElement.instanceId(), instanceElement.elementId());
+ }
+}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java
index d37edf761..b0006f711 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/SimulatorService.java
@@ -35,6 +35,7 @@ import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
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;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantUtils;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
@@ -327,19 +328,98 @@ public class SimulatorService {
*
* @param instanceId the instanceId
* @param elementId the elementId
+ * @param stage the stage
*/
- public void migrate(UUID instanceId, UUID elementId) {
+ public void migrate(UUID instanceId, UUID elementId, int stage, Map<String, Object> compositionInProperties) {
if (!execution(getConfig().getMigrateTimerMs(),
"Current Thread migrate is Interrupted during execution {}", elementId)) {
return;
}
- if (getConfig().isMigrateSuccess()) {
+ if (config.isMigrateSuccess()) {
+ var stageSet = ParticipantUtils.findStageSet(compositionInProperties);
+ var nextStage = 1000;
+ for (var s : stageSet) {
+ if (s > stage) {
+ nextStage = Math.min(s, nextStage);
+ }
+ }
+ if (nextStage == 1000) {
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementStage(
+ instanceId, elementId,
+ StateChangeResult.NO_ERROR, nextStage, "stage " + stage + " Migrated");
+ }
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(
+ instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
+ }
+ }
+
+ /**
+ * Handle a Migrate Precheck on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void migratePrecheck(UUID instanceId, UUID elementId) {
+ if (!execution(config.getMigratePrecheckTimerMs(),
+ "Current Thread migrate precheck is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isMigratePrecheck()) {
intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
- DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated");
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migration precheck completed");
} else {
intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
- DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migrate failed!");
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Migration precheck failed");
+ }
+ }
+
+ /**
+ * Handle a Prepare on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void prepare(UUID instanceId, UUID elementId) {
+ if (!execution(config.getPrepareTimerMs(),
+ "Current Thread prepare is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isPrepare()) {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, "Prepare completed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Prepare failed");
+ }
+ }
+
+ /**
+ * Handle a Review on a automation composition element.
+ *
+ * @param instanceId the instanceId
+ * @param elementId the elementId
+ */
+ public void review(UUID instanceId, UUID elementId) {
+ if (!execution(config.getReviewTimerMs(),
+ "Current Thread review is Interrupted during execution {}", elementId)) {
+ return;
+ }
+
+ if (config.isReview()) {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Review completed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId,
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Review failed");
}
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
index f4d4c6e2e..f38f3079b 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.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.
@@ -38,6 +38,12 @@ public class SimConfig {
private boolean migrateSuccess = true;
+ private boolean migratePrecheck = true;
+
+ private boolean prepare = true;
+
+ private boolean review = true;
+
private boolean primeSuccess = true;
private boolean deprimeSuccess = true;
@@ -54,6 +60,12 @@ public class SimConfig {
private int migrateTimerMs = 100;
+ private int migratePrecheckTimerMs = 100;
+
+ private int prepareTimerMs = 100;
+
+ private int reviewTimerMs = 100;
+
private int deleteTimerMs = 100;
private int primeTimerMs = 100;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java
index 4c7845143..4157bfd88 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/parameters/ParticipantSimParameters.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.
@@ -41,5 +41,5 @@ public class ParticipantSimParameters implements ParticipantParameters {
@NotNull
@Valid
- private ParticipantIntermediaryParameters intermediaryParameters;
+ private ParticipantIntermediaryParameters intermediaryParameters = new ParticipantIntermediaryParameters();
}