summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.appc/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-08-21 13:43:08 -0400
committerJim Hahn <jrh3@att.com>2020-10-27 14:55:15 -0400
commit19ef8b24a98c09a349e6ae7309f535a0135463f6 (patch)
treed988e5a58865ae6f3a38dcb31e4f195f18e59946 /models-interactions/model-actors/actor.appc/src/main
parent6b29d2c19e288148171db0c0e446e18dcd46effd (diff)
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 <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.appc/src/main')
-rw-r--r--models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/AppcOperation.java14
-rw-r--r--models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java49
2 files changed, 4 insertions, 59 deletions
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;
@@ -71,14 +71,6 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
}
/**
- * Starts the GUARD.
- */
- @Override
- protected CompletableFuture<OperationOutcome> 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<Request,
* @param targetVnf target VNF
* @return a new request
*/
- protected Request makeRequest(int attempt, String targetVnf) {
+ protected Request makeRequest(int attempt, GenericVnf targetVnf) {
Request request = new Request();
request.setCommonHeader(new CommonHeader());
request.getCommonHeader().setRequestId(params.getRequestId());
@@ -102,7 +94,7 @@ public abstract class AppcOperation extends BidirectionalTopicOperation<Request,
}
// add/replace specific values
- request.getPayload().put(VNF_ID_KEY, targetVnf);
+ request.getPayload().put(VNF_ID_KEY, targetVnf.getVnfId());
return request;
}
diff --git a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java
index 1f5b9fd10..524c797b6 100644
--- a/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java
+++ b/models-interactions/model-actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperation.java
@@ -21,21 +21,12 @@
package org.onap.policy.controlloop.actor.appc;
import java.util.List;
-import java.util.concurrent.CompletableFuture;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.policy.aai.AaiConstants;
-import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.appc.Request;
-import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class ModifyConfigOperation extends AppcOperation {
- private static final Logger logger = LoggerFactory.getLogger(ModifyConfigOperation.class);
-
public static final String NAME = "ModifyConfig";
private static final List<String> 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<OperationOutcome> 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"));
}
}