diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-02-14 16:30:56 +0000 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-02-15 15:29:53 +0000 |
commit | e0a13196ebb34c84931df27ba00cd1778adbceb9 (patch) | |
tree | 64f1af69d7802ee41a08278ec1e84b21241c1fb5 /participant/participant-impl/participant-impl-kserve | |
parent | 665815fc5c91c3437a0b0459448994789464a391 (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/participant-impl-kserve')
-rw-r--r-- | participant/participant-impl/participant-impl-kserve/src/main/java/org/onap/policy/clamp/acm/participant/kserve/handler/AutomationCompositionElementHandler.java | 69 |
1 files changed, 7 insertions, 62 deletions
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"); - } } |