From 19ef8b24a98c09a349e6ae7309f535a0135463f6 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 21 Aug 2020 13:43:08 -0400 Subject: Make Actors event-agnostic Removed event and event-context code from the Actor code. Also removed the preprocessing steps from the Actor code, giving the application complete control over any preprocessing. Also fixed a bug wherein the APPC actor was treating the AAI_RESOURCE_VNF property as a String instead of as a GenericVnf. Issue-ID: POLICY-2746-actor Change-Id: Ibc05fe39ffedc0bc461abf10e6a960861ac70119 Signed-off-by: Jim Hahn --- .../controlloop/actor/appc/AppcOperation.java | 14 ++----- .../actor/appc/ModifyConfigOperation.java | 49 +--------------------- 2 files changed, 4 insertions(+), 59 deletions(-) (limited to 'models-interactions/model-actors/actor.appc/src/main') diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java index 70c70823c..89d5c4f2f 100644 --- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java +++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java @@ -23,7 +23,7 @@ package org.onap.policy.controlloop.actor.appc; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.concurrent.CompletableFuture; +import org.onap.aai.domain.yang.GenericVnf; import org.onap.policy.appc.CommonHeader; import org.onap.policy.appc.Request; import org.onap.policy.appc.Response; @@ -70,14 +70,6 @@ public abstract class AppcOperation extends BidirectionalTopicOperation startPreprocessorAsync() { - return startGuardAsync(); - } - /** * Makes a request, given the target VNF. This is a support function for * {@link #makeRequest(int)}. @@ -86,7 +78,7 @@ public abstract class AppcOperation extends BidirectionalTopicOperation PROPERTY_NAMES = List.of(OperationProperties.AAI_RESOURCE_VNF); @@ -50,46 +41,8 @@ public class ModifyConfigOperation extends AppcOperation { super(params, config, PROPERTY_NAMES); } - /** - * Ensures that A&AI customer query has been performed, and then runs the guard query. - */ - @Override - @SuppressWarnings("unchecked") - protected CompletableFuture startPreprocessorAsync() { - if (params.isPreprocessed()) { - return null; - } - - ControlLoopOperationParams cqParams = params.toBuilder().actor(AaiConstants.ACTOR_NAME) - .operation(AaiCqResponse.OPERATION).payload(null).retry(null).timeoutSec(null).build(); - - // run Custom Query and Guard, in parallel - return allOf(() -> params.getContext().obtain(AaiCqResponse.CONTEXT_KEY, cqParams), this::startGuardAsync); - } - @Override protected Request makeRequest(int attempt) { - return makeRequest(attempt, getVnfId()); - } - - protected String getVnfId() { - GenericVnf vnf = this.getProperty(OperationProperties.AAI_RESOURCE_VNF); - if (vnf != null) { - return vnf.getVnfId(); - } - - AaiCqResponse cq = params.getContext().getProperty(AaiCqResponse.CONTEXT_KEY); - if (cq == null) { - throw new IllegalStateException("target vnf-id could not be determined"); - } - - GenericVnf genvnf = cq.getGenericVnfByModelInvariantId(params.getTargetEntityIds() - .get(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID)); - if (genvnf == null) { - logger.info("{}: target entity could not be found for {}", getFullName(), params.getRequestId()); - throw new IllegalArgumentException("target vnf-id could not be found"); - } - - return genvnf.getVnfId(); + return makeRequest(attempt, getRequiredProperty(OperationProperties.AAI_RESOURCE_VNF, "resource VNF")); } } -- cgit 1.2.3-korg