diff options
author | 2024-07-23 12:45:09 +0100 | |
---|---|---|
committer | 2024-07-23 15:16:00 +0000 | |
commit | b2bc0f63a484abe5b77b1e921d820ae80481602b (patch) | |
tree | 57450bb88f425afcb10332c65d36ffe9703a9159 /participant/participant-impl/participant-impl-simulator/src/main/java | |
parent | 1c144c87fbe077eb471650064c64888c4501f581 (diff) |
Add support for Prepare, Review and Migrate pre-check in participant
Add support for Prepare, Review and Migrate pre-check
in ACM participant simulator.
Issue-ID: POLICY-5088
Change-Id: Ibad54aacc6102654f93a86169212d91ba3a59b8b
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-simulator/src/main/java')
4 files changed, 115 insertions, 29 deletions
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..ef8db0e99 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,59 +47,56 @@ 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()); 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..5f866eb0c 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 @@ -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,52 +65,47 @@ 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()); } @@ -126,4 +119,26 @@ public class AutomationCompositionElementHandlerV2 extends AcElementListenerV2 { compositionElement, compositionElementTarget, instanceElement, instanceElementMigrate); simulatorService.migrate(instanceElement.instanceId(), instanceElement.elementId()); } + + @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..e1e3ad49f 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 @@ -342,4 +342,67 @@ public class SimulatorService { 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, "Migration precheck completed"); + } else { + intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, + 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; |