aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actorServiceProvider/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider/src/main')
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/Operation.java16
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationProperties.java63
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java5
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java7
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java34
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java20
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtil.java3
7 files changed, 140 insertions, 8 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/Operation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/Operation.java
index 39977fd41..dfa086595 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/Operation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/Operation.java
@@ -20,6 +20,7 @@
package org.onap.policy.controlloop.actorserviceprovider;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
@@ -43,6 +44,21 @@ public interface Operation {
String getName();
/**
+ * Gets the names of the properties required by the operation.
+ *
+ * @return the names of the properties required by the operation
+ */
+ List<String> getPropertyNames();
+
+ /**
+ * Sets a property.
+ *
+ * @param name property name
+ * @param value new value
+ */
+ public void setProperty(String name, Object value);
+
+ /**
* Called by enforcement PDP engine to start the operation. As part of the operation,
* it invokes the "start" and "complete" call-backs found within the parameters.
*
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationProperties.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationProperties.java
new file mode 100644
index 000000000..42846460d
--- /dev/null
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/OperationProperties.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actorserviceprovider;
+
+/**
+ * Names of properties needed by the Actors defined within this repo. Note: this is not
+ * exhaustive, as additional property names may be returned by company-defined Actors.
+ */
+public class OperationProperties {
+ public static final String AAI_MODEL_CLOUD_REGION = "AAI/modelInvariantId/cloudRegion";
+ public static final String AAI_MODEL_INVARIANT_GENERIC_VNF = "AAI/modelInvariantId/genericVnf";
+ public static final String AAI_MODEL_SERVICE = "AAI/modelInvariantId/service";
+ public static final String AAI_MODEL_TENANT = "AAI/modelInvariantId/tenant";
+ public static final String AAI_MODEL_VNF = "AAI/modelInvariantId/vnf";
+ public static final String AAI_RESOURCE_SERVICE_INSTANCE = "AAI/resourceId/serviceInstanceId";
+ public static final String AAI_RESOURCE_VNF = "AAI/resourceId/modelInvariantId/vnf";
+ public static final String AAI_PNF = "AAI/pnf";
+ public static final String AAI_VSERVER_LINK = "AAI/vserver/link";
+
+ /*
+ * These are typically extracted from the event or from the event's enrichment data.
+ */
+ public static final String ENRICHMENT_BANDWIDTH = "enrichment/bandwidth";
+ public static final String ENRICHMENT_BANDWIDTH_CHANGE_TIME = "enrichment/bandwidth/changeTime";
+ public static final String ENRICHMENT_GENERIC_VNF_ID = "enrichment/genericVnf/id";
+ public static final String ENRICHMENT_NETWORK_ID = "enrichment/network/id";
+ public static final String ENRICHMENT_SERVICE_ID = "enrichment/service/id";
+ public static final String ENRICHMENT_SERVICE_INSTANCE_ID = "enrichment/serviceInstance/id";
+ public static final String ENRICHMENT_VNF_ID = "enrichment/vnf/id";
+ public static final String ENRICHMENT_VSERVER_ID = "enrichment/vserver/id";
+ public static final String ENRICHMENT_VSERVER_NAME = "enrichment/vserver/name";
+
+ public static final String EVENT_ADDITIONAL_PARAMS = "event/additionalParams";
+ public static final String EVENT_PAYLOAD = "event/payload";
+
+ /*
+ * These are data computed and/or tracked by the invoker.
+ */
+ public static final String DATA_VF_COUNT = "data/vfCount";
+
+
+ private OperationProperties() {
+ super();
+ }
+}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
index 13231e6ad..a3f3a6905 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java
@@ -76,10 +76,11 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial
* @param params operation parameters
* @param config configuration for this operation
* @param clazz response class
+ * @param propertyNames names of properties required by this operation
*/
public BidirectionalTopicOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config,
- Class<S> clazz) {
- super(params, config);
+ Class<S> clazz, List<String> propertyNames) {
+ super(params, config, propertyNames);
this.config = config;
this.responseClass = clazz;
this.forwarder = config.getForwarder();
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
index 4800b3a4b..09c876d41 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
@@ -21,6 +21,7 @@
package org.onap.policy.controlloop.actorserviceprovider.impl;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
@@ -90,9 +91,11 @@ public abstract class HttpOperation<T> extends OperationPartial {
* @param params operation parameters
* @param config configuration for this operation
* @param clazz response class
+ * @param propertyNames names of properties required by this operation
*/
- public HttpOperation(ControlLoopOperationParams params, HttpConfig config, Class<T> clazz) {
- super(params, config);
+ public HttpOperation(ControlLoopOperationParams params, HttpConfig config, Class<T> clazz,
+ List<String> propertyNames) {
+ super(params, config, propertyNames);
this.config = config;
this.responseClass = clazz;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
index b28021607..060f7a64b 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java
@@ -23,6 +23,7 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
@@ -103,17 +104,27 @@ public abstract class OperationPartial implements Operation {
@Setter(AccessLevel.PROTECTED)
private String subRequestId;
+ @Getter
+ private final List<String> propertyNames;
+
+ /**
+ * Values for the properties identified by {@link #getPropertyNames()}.
+ */
+ private final Map<String, Object> properties = new HashMap<>();
+
/**
* Constructs the object.
*
* @param params operation parameters
* @param config configuration for this operation
+ * @param propertyNames names of properties required by this operation
*/
- public OperationPartial(ControlLoopOperationParams params, OperatorConfig config) {
+ public OperationPartial(ControlLoopOperationParams params, OperatorConfig config, List<String> propertyNames) {
this.params = params;
this.config = config;
this.fullName = params.getActor() + "." + params.getOperation();
+ this.propertyNames = propertyNames;
}
public Executor getBlockingExecutor() {
@@ -128,6 +139,27 @@ public abstract class OperationPartial implements Operation {
return params.getOperation();
}
+ /**
+ * Sets a property.
+ *
+ * @param name property name
+ * @param value new value
+ */
+ public void setProperty(String name, Object value) {
+ properties.put(name, value);
+ }
+
+ /**
+ * Gets a property's value.
+ *
+ * @param name name of the property of interest
+ * @return the property's value, or {@code null} if it has no value
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T getProperty(String name) {
+ return (T) properties.get(name);
+ }
+
@Override
public CompletableFuture<OperationOutcome> start() {
// allocate a controller for the entire operation
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java
index 7fc15c97b..f5dd49877 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java
@@ -34,6 +34,7 @@ import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.common.parameters.BeanValidator;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.controlloop.actorserviceprovider.ActorService;
+import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
@@ -89,6 +90,12 @@ public class ControlLoopOperationParams {
private Map<String, Object> payload;
/**
+ * {@code True} if the preprocessing steps have already been executed, {@code false}
+ * otherwise.
+ */
+ private boolean preprocessed;
+
+ /**
* Number of retries allowed, or {@code null} if no retries.
*/
private Integer retry;
@@ -137,6 +144,16 @@ public class ControlLoopOperationParams {
* @throws IllegalArgumentException if the parameters are invalid
*/
public CompletableFuture<OperationOutcome> start() {
+ return build().start();
+ }
+
+ /**
+ * Builds the specified operation.
+ *
+ * @return a new operation
+ * @throws IllegalArgumentException if the parameters are invalid
+ */
+ public Operation build() {
BeanValidationResult result = validate();
if (!result.isValid()) {
logger.warn("parameter error in operation {}.{} for {}:\n{}", getActor(), getOperation(), getRequestId(),
@@ -148,8 +165,7 @@ public class ControlLoopOperationParams {
return actorService
.getActor(getActor())
.getOperator(getOperation())
- .buildOperation(this)
- .start();
+ .buildOperation(this);
// @formatter:on
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtil.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtil.java
index 3854fb29a..110f84ad8 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtil.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtil.java
@@ -20,6 +20,7 @@
package org.onap.policy.controlloop.actorserviceprovider.pipeline;
+import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
@@ -38,7 +39,7 @@ public class PipelineUtil extends OperationPartial {
* @param params utility parameters
*/
public PipelineUtil(ControlLoopOperationParams params) {
- super(params, new OperatorConfig(ForkJoinPool.commonPool()));
+ super(params, new OperatorConfig(ForkJoinPool.commonPool()), Collections.emptyList());
}
@Override