summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.guard/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-02-25 10:49:32 -0500
committerJim Hahn <jrh3@att.com>2020-02-25 11:16:23 -0500
commit7ad8905da8be882fd2106861a030ff4ad470615f (patch)
tree8a7839fcc3046702f4595c8ca94f88e0cf7a44b4 /models-interactions/model-actors/actor.guard/src/main
parentfd9186d130a6777f93c10e7aff0289a05efed86c (diff)
Add "disabled" property to Guard Actor
Issue-ID: POLICY-2350 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I3e9c9aae474d4b288a162243bc492b301d1044c0
Diffstat (limited to 'models-interactions/model-actors/actor.guard/src/main')
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorParams.java5
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java9
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java4
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java5
4 files changed, 23 insertions, 0 deletions
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorParams.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorParams.java
index b8eb85c03..aa6d7273f 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorParams.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorParams.java
@@ -40,4 +40,9 @@ public class GuardActorParams extends HttpActorParams {
private String onapComponent;
private String onapInstance;
private String action = DEFAULT_ACTION;
+
+ /**
+ * {@code True} if guard operations are disabled.
+ */
+ private boolean disabled = false;
}
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java
index c6bf32635..0e711d1be 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java
@@ -23,6 +23,7 @@ package org.onap.policy.controlloop.actor.guard;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Executor;
+import lombok.Getter;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
@@ -34,6 +35,12 @@ public class GuardConfig extends HttpConfig {
private final Map<String, Object> defaultRequest = new LinkedHashMap<>();
/**
+ * {@code True} if the associated guard operation is disabled.
+ */
+ @Getter
+ private boolean disabled;
+
+ /**
* Constructs the object.
*
* @param blockingExecutor executor to be used for tasks that may perform blocking I/O
@@ -47,6 +54,8 @@ public class GuardConfig extends HttpConfig {
addProperty("ONAPInstance", params.getOnapInstance());
addProperty("ONAPName", params.getOnapName());
addProperty("action", params.getAction());
+
+ this.disabled = params.isDisabled();
}
/**
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
index a5459f660..e35caa06c 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
@@ -84,6 +84,10 @@ public class GuardOperation extends HttpOperation<DecisionResponse> {
@Override
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
+ if (config.isDisabled()) {
+ // guard is disabled, thus it is always treated as a success
+ return CompletableFuture.completedFuture(params.makeOutcome());
+ }
DecisionRequest request = Util.translate(getName(), makeRequest(), DecisionRequest.class);
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java
index 251482525..5f8360377 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java
@@ -41,4 +41,9 @@ public class GuardParams extends HttpParams {
private String onapComponent;
private String onapInstance;
private String action;
+
+ /**
+ * {@code True} if the associated guard operation is disabled.
+ */
+ private boolean disabled;
}