aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java26
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java6
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java6
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java4
4 files changed, 30 insertions, 12 deletions
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 431ad3711..b9dfb9eba 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
@@ -23,11 +23,13 @@ package org.onap.policy.controlloop.actor.guard;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
+import org.onap.policy.controlloop.actorserviceprovider.CallbackManager;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
@@ -37,6 +39,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Guard Operation. The outcome message is set to the guard response. If the guard is
@@ -54,6 +58,7 @@ import org.onap.policy.models.decisions.concepts.DecisionResponse;
* </dl>
*/
public class GuardOperation extends HttpOperation<DecisionResponse> {
+ private static final Logger logger = LoggerFactory.getLogger(GuardOperation.class);
// operation name
public static final String NAME = OperationPartial.GUARD_OPERATION_NAME;
@@ -83,12 +88,25 @@ 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());
+ public CompletableFuture<OperationOutcome> start() {
+ if (!config.isDisabled()) {
+ // enabled - do full guard operation
+ return super.start();
}
+ // guard is disabled, thus it is always treated as a success
+ logger.info("{}: guard disabled, always succeeds for {}", getFullName(), params.getRequestId());
+
+ final Executor executor = params.getExecutor();
+ final CallbackManager callbacks = new CallbackManager();
+
+ return CompletableFuture.completedFuture(params.makeOutcome())
+ .whenCompleteAsync(callbackStarted(callbacks), executor)
+ .whenCompleteAsync(callbackCompleted(callbacks), executor);
+ }
+
+ @Override
+ protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
outcome.setSubRequestId(String.valueOf(attempt));
DecisionRequest request = Util.translate(getName(), makeRequest(), DecisionRequest.class);
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
index 3a14c3bde..4d53f6350 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
@@ -123,9 +123,9 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
* the VF count from the custom query.
*/
protected void validateTarget() {
- verifyNotNull("model-customization-id", modelCustomizationId);
- verifyNotNull("model-invariant-id", modelInvariantId);
- verifyNotNull("model-version-id", modelVersionId);
+ verifyNotNull("modelCustomizationId", modelCustomizationId);
+ verifyNotNull("modelInvariantId", modelInvariantId);
+ verifyNotNull("modelVersionId", modelVersionId);
}
private void verifyNotNull(String type, Object value) {
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
index 992065638..80f20b59b 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java
@@ -91,9 +91,9 @@ public class SoOperationTest extends BasicSoOperation {
@Test
public void testValidateTarget() {
// check when various fields are null
- verifyNotNull("model-customization-id", target::getModelCustomizationId, target::setModelCustomizationId);
- verifyNotNull("model-invariant-id", target::getModelInvariantId, target::setModelInvariantId);
- verifyNotNull("model-version-id", target::getModelVersionId, target::setModelVersionId);
+ verifyNotNull("modelCustomizationId", target::getModelCustomizationId, target::setModelCustomizationId);
+ verifyNotNull("modelInvariantId", target::getModelInvariantId, target::setModelInvariantId);
+ verifyNotNull("modelVersionId", target::getModelVersionId, target::setModelVersionId);
// verify it's still valid
assertThatCode(() -> new VfModuleCreate(params, config)).doesNotThrowAnyException();
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 94a9ee560..cdbdc2af5 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
@@ -891,7 +891,7 @@ public abstract class OperationPartial implements Operation {
* @param callbacks used to determine if the start callback can be invoked
* @return a function that sets the start time and invokes the callback
*/
- private BiConsumer<OperationOutcome, Throwable> callbackStarted(CallbackManager callbacks) {
+ protected BiConsumer<OperationOutcome, Throwable> callbackStarted(CallbackManager callbacks) {
return (outcome, thrown) -> {
@@ -920,7 +920,7 @@ public abstract class OperationPartial implements Operation {
* @param callbacks used to determine if the end callback can be invoked
* @return a function that sets the end time and invokes the callback
*/
- private BiConsumer<OperationOutcome, Throwable> callbackCompleted(CallbackManager callbacks) {
+ protected BiConsumer<OperationOutcome, Throwable> callbackCompleted(CallbackManager callbacks) {
return (outcome, thrown) -> {
if (callbacks.canEnd()) {