diff options
author | 2023-07-04 09:26:41 +0100 | |
---|---|---|
committer | 2023-07-13 13:20:31 +0000 | |
commit | ef0a60deb046c5bf5ed1a6209493dfde6a6457a9 (patch) | |
tree | 3e92ffecd8579cfb0ddabef80dee5586c695eda1 /participant/participant-impl/participant-impl-simulator/src/main | |
parent | 51ef04415186a0de3e50339b7fca04fb5ef079c9 (diff) |
Add restart support inside participants
Issue-ID: POLICY-4747
Change-Id: I09ca3e373f8271fbfe612c031920058b744cf413
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
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/main/handler/AutomationCompositionElementHandler.java | 58 |
1 files changed, 57 insertions, 1 deletions
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 7554c0b3c..eaf94552b 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 @@ -40,6 +40,7 @@ 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.StateChangeResult; +import org.onap.policy.clamp.models.acm.utils.AcmUtils; import org.onap.policy.models.base.PfModelException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -188,7 +189,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio @Override public void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties) throws PfModelException { - LOGGER.debug("updat call"); + LOGGER.debug("update call"); if (!execution(config.getUpdateTimerMs(), "Current Thread update is Interrupted during execution {}", element.getId())) { @@ -233,6 +234,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio @Override public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList) throws PfModelException { + LOGGER.debug("prime call"); if (!execution(config.getPrimeTimerMs(), "Current Thread prime is Interrupted during execution {}", compositionId)) { @@ -250,6 +252,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio @Override public void deprime(UUID compositionId) throws PfModelException { + LOGGER.debug("deprime call"); if (!execution(config.getDeprimeTimerMs(), "Current Thread deprime is Interrupted during execution {}", compositionId)) { @@ -287,4 +290,57 @@ public class AutomationCompositionElementHandler implements AutomationCompositio } return result; } + + @Override + public void handleRestartComposition(UUID compositionId, + List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state) + throws PfModelException { + LOGGER.debug("restart composition definition call"); + switch (state) { + case PRIMING: + prime(compositionId, elementDefinitionList); + break; + + case DEPRIMING: + deprime(compositionId); + break; + + default: + intermediaryApi.updateCompositionState(compositionId, state, StateChangeResult.NO_ERROR, "Restarted"); + } + } + + @Override + public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element, + Map<String, Object> properties, 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"); + return; + } + if (DeployState.DEPLOYING.equals(deployState)) { + deploy(automationCompositionId, element, properties); + return; + } + if (DeployState.UNDEPLOYING.equals(deployState)) { + undeploy(automationCompositionId, element.getId()); + return; + } + if (DeployState.UPDATING.equals(deployState)) { + update(automationCompositionId, element, properties); + return; + } + if (DeployState.DELETING.equals(deployState)) { + delete(automationCompositionId, element.getId()); + return; + } + if (LockState.LOCKING.equals(lockState)) { + lock(automationCompositionId, element.getId()); + return; + } + if (LockState.UNLOCKING.equals(lockState)) { + unlock(automationCompositionId, element.getId()); + } + } } |