aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java4
-rw-r--r--models-interactions/model-actors/actor.cds/src/test/resources/service.yaml13
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperation.java (renamed from models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java)6
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperator.java (renamed from models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperator.java)6
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java2
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java (renamed from models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java)14
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperatorTest.java (renamed from models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperatorTest.java)6
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java6
-rw-r--r--models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java4
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java23
-rw-r--r--models-interactions/model-actors/actor.sdnr/src/test/resources/service.yaml38
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java10
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java114
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java52
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java21
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java21
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java15
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java100
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java18
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java24
-rw-r--r--models-interactions/model-actors/actor.so/src/test/resources/service.yaml5
-rw-r--r--models-interactions/model-actors/actor.test/src/test/resources/service.yaml5
-rw-r--r--models-interactions/model-actors/actor.test/src/test/resources/serviceFull.yaml5
-rw-r--r--models-interactions/model-actors/actor.test/src/test/resources/serviceInvalidHttp.yaml5
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/Restart.java2
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java10
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcConfig.java63
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java115
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperator.java49
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcParams.java55
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java15
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java10
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java23
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcConfigTest.java85
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java50
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperatorTest.java102
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcParamsTest.java93
-rw-r--r--models-interactions/model-actors/actor.vfc/src/test/resources/service.yaml35
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java11
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperator.java52
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActor.java2
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java134
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperator.java43
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperator.java81
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java97
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParams.java (renamed from models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/CommonActorParams.java)4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParams.java2
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParams.java2
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParams.java (renamed from models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorParams.java)21
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfig.java (renamed from models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.java)31
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParams.java (renamed from models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoParams.java)21
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java10
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java9
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java6
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java255
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java (renamed from models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperatorTest.java)43
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParamsTest.java (renamed from models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/CommonActorParamsTest.java)22
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParamsTest.java (renamed from models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorParamsTest.java)48
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.java (renamed from models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoConfigTest.java)30
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParamsTest.java (renamed from models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoParamsTest.java)39
-rw-r--r--models-interactions/model-actors/pom.xml8
-rw-r--r--models-interactions/model-impl/pom.xml12
-rw-r--r--models-sim/models-sim-dmaap/src/main/package/docker/dmaap-sim.sh2
-rw-r--r--models-sim/models-sim-dmaap/src/main/package/tarball/assembly.xml10
-rw-r--r--models-sim/models-sim-dmaap/src/main/resources/logback.xml46
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java5
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh2
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml10
-rw-r--r--models-sim/policy-models-sim-pdp/src/main/resources/logback.xml46
-rw-r--r--models-sim/policy-models-simulators/src/main/package/docker/simulators.sh2
-rw-r--r--models-sim/policy-models-simulators/src/main/package/tarball/assembly.xml9
-rw-r--r--models-sim/policy-models-simulators/src/main/resources/logback.xml56
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java6
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java6
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java6
77 files changed, 1086 insertions, 1335 deletions
diff --git a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
index 386eb219a..abfd2eb41 100644
--- a/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
+++ b/models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
@@ -50,9 +50,9 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.coder.StandardCoderObject;
-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.impl.HttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
@@ -277,7 +277,7 @@ public class AaiCustomQueryOperationTest extends BasicAaiOperation<Map<String, S
}
@Override
- public Operation buildOperation(ControlLoopOperationParams params) {
+ public HttpOperation<?> buildOperation(ControlLoopOperationParams params) {
return new AaiGetTenantOperation(params, getCurrentConfig());
}
diff --git a/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml b/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml
index 0d3c76f48..19ff698a3 100644
--- a/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml
+++ b/models-interactions/model-actors/actor.cds/src/test/resources/service.yaml
@@ -19,9 +19,10 @@
#
actors:
CDS:
- any:
- timeout: 10
- port: 6700
- host: my-host
- username: my-user
- password: my-pass
+ operations:
+ any:
+ timeout: 10
+ port: 6700
+ host: my-host
+ username: my-user
+ password: my-pass
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/DecisionOperation.java
index a21886bf2..6a7b6fd93 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/DecisionOperation.java
@@ -55,8 +55,8 @@ import org.slf4j.LoggerFactory;
* <dd>generated</dd>
* </dl>
*/
-public class GuardOperation extends HttpOperation<DecisionResponse> {
- private static final Logger logger = LoggerFactory.getLogger(GuardOperation.class);
+public class DecisionOperation extends HttpOperation<DecisionResponse> {
+ private static final Logger logger = LoggerFactory.getLogger(DecisionOperation.class);
// operation name
public static final String NAME = OperationPartial.GUARD_OPERATION_NAME;
@@ -80,7 +80,7 @@ public class GuardOperation extends HttpOperation<DecisionResponse> {
* @param params operation parameters
* @param config configuration for this operation
*/
- public GuardOperation(ControlLoopOperationParams params, HttpConfig config) {
+ public DecisionOperation(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, DecisionResponse.class);
this.config = (GuardConfig) config;
}
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperator.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperator.java
index b3a47fd71..f86d370e9 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperator.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/DecisionOperator.java
@@ -32,10 +32,10 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterVali
/**
* Guard Operator.
*/
-public class GuardOperator extends HttpOperator {
+public class DecisionOperator extends HttpOperator {
- public GuardOperator(String actorName, String name,
- @SuppressWarnings("rawtypes") OperationMaker<HttpConfig, HttpOperation> operationMaker) {
+ public DecisionOperator(String actorName, String name,
+ OperationMaker<HttpConfig, HttpOperation<?>> operationMaker) {
super(actorName, name, operationMaker);
}
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java
index 0053213f5..1cf09d399 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java
@@ -35,6 +35,6 @@ public class GuardActorServiceProvider extends HttpActor<GuardActorParams> {
public GuardActorServiceProvider() {
super(NAME, GuardActorParams.class);
- addOperator(new GuardOperator(NAME, GuardOperation.NAME, GuardOperation::new));
+ addOperator(new DecisionOperator(NAME, DecisionOperation.NAME, DecisionOperation::new));
}
}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java
index daf4dff6e..da0ee95b5 100644
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperationTest.java
+++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperationTest.java
@@ -54,7 +54,7 @@ import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
import org.onap.policy.simulators.GuardSimulatorJaxRs;
-public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> {
+public class DecisionOperationTest extends BasicHttpOperation<DecisionRequest> {
@Mock
private Consumer<OperationOutcome> started;
@@ -62,7 +62,7 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> {
private Consumer<OperationOutcome> completed;
private GuardConfig guardConfig;
- private GuardOperation oper;
+ private DecisionOperation oper;
/**
* Starts the simulator.
@@ -105,7 +105,7 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> {
params = params.toBuilder().startCallback(started).completeCallback(completed).build();
- oper = new GuardOperation(params, config);
+ oper = new DecisionOperation(params, config);
}
/**
@@ -117,7 +117,7 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> {
config = new GuardConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
- oper = new GuardOperation(params, config);
+ oper = new DecisionOperation(params, config);
outcome = oper.start().get();
assertEquals(PolicyResult.SUCCESS, outcome.getResult());
@@ -134,7 +134,7 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> {
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor)
.payload(Map.of("clname", GuardSimulatorJaxRs.DENY_CLNAME)).build();
- oper = new GuardOperation(params, config);
+ oper = new DecisionOperation(params, config);
outcome = oper.start().get();
assertEquals(PolicyResult.FAILURE, outcome.getResult());
@@ -154,7 +154,7 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> {
assertFalse(future2.isDone());
DecisionResponse resp = new DecisionResponse();
- resp.setStatus(GuardOperation.PERMIT);
+ resp.setStatus(DecisionOperation.PERMIT);
when(rawResponse.readEntity(String.class)).thenReturn(Util.translate("", resp, String.class));
verify(client).post(callbackCaptor.capture(), any(), requestCaptor.capture(), any());
@@ -205,7 +205,7 @@ public class GuardOperationTest extends BasicHttpOperation<DecisionRequest> {
// null payload - start with fresh parameters and operation
params = params.toBuilder().payload(null).build();
- oper = new GuardOperation(params, config);
+ oper = new DecisionOperation(params, config);
assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest());
}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperatorTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperatorTest.java
index 36263329a..170bcdf7e 100644
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardOperatorTest.java
+++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/DecisionOperatorTest.java
@@ -35,7 +35,7 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-public class GuardOperatorTest {
+public class DecisionOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-name";
private static final String CLIENT = "my-client";
@@ -53,7 +53,7 @@ public class GuardOperatorTest {
private HttpClientFactory factory;
- private GuardOperator oper;
+ private DecisionOperator oper;
/**
* Initializes fields, including {@link #oper}, and resets the static fields used by
@@ -92,7 +92,7 @@ public class GuardOperatorTest {
}
- private class MyOperator extends GuardOperator {
+ private class MyOperator extends DecisionOperator {
public MyOperator() {
super(ACTOR, OPERATION, null);
}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java
index 0fef3bd29..71c75b8cf 100644
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java
+++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorParamsTest.java
@@ -32,7 +32,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.CommonActorParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
public class GuardActorParamsTest {
private static final String CONTAINER = "my-container";
@@ -75,14 +75,14 @@ public class GuardActorParamsTest {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
- GuardActorParams sparse = Util.translate(CONTAINER, Map.of(CommonActorParams.OPERATIONS_FIELD, operations),
+ GuardActorParams sparse = Util.translate(CONTAINER, Map.of(ActorParams.OPERATIONS_FIELD, operations),
GuardActorParams.class);
assertTrue(sparse.validate(CONTAINER).isValid());
assertEquals(GuardActorParams.DEFAULT_ACTION, sparse.getAction());
// check fields from superclass
- testValidateField(CommonActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
+ testValidateField(ActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
testValidateField("timeoutSec", "minimum", params2 -> params2.setTimeoutSec(-1));
}
diff --git a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java
index 6721ff7d0..0ad8161c6 100644
--- a/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.guard/src/test/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProviderTest.java
@@ -35,7 +35,7 @@ public class GuardActorServiceProviderTest extends BasicActor {
final GuardActorServiceProvider prov = new GuardActorServiceProvider();
// verify that it has the operators we expect
- var expected = Arrays.asList(GuardOperation.NAME).stream().sorted().collect(Collectors.toList());
+ var expected = Arrays.asList(DecisionOperation.NAME).stream().sorted().collect(Collectors.toList());
var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList());
assertEquals(expected.toString(), actual.toString());
@@ -43,6 +43,6 @@ public class GuardActorServiceProviderTest extends BasicActor {
// verify that it all plugs into the ActorService
verifyActorService(GuardActorServiceProvider.NAME, "service.yaml");
- assertTrue(prov.getOperator(GuardOperation.NAME) instanceof GuardOperator);
+ assertTrue(prov.getOperator(DecisionOperation.NAME) instanceof DecisionOperator);
}
}
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java
index 12a1666a0..799872d08 100644
--- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorServiceProviderTest.java
@@ -26,14 +26,17 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.time.Instant;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;
+import java.util.stream.Collectors;
import org.junit.Test;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.ControlLoopResponse;
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.actor.test.BasicActor;
import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.Target;
@@ -45,7 +48,7 @@ import org.onap.policy.sdnr.util.Serialization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SdnrActorServiceProviderTest {
+public class SdnrActorServiceProviderTest extends BasicActor {
private static final String MODIFY_CONFIG = "ModifyConfig";
@@ -95,6 +98,24 @@ public class SdnrActorServiceProviderTest {
}
@Test
+ public void testConstructor() {
+ SdnrActorServiceProvider prov = new SdnrActorServiceProvider();
+ assertEquals(0, prov.getSequenceNumber());
+
+ // verify that it has the operators we expect
+ var expected = Arrays.asList(SdnrOperation.NAME).stream().sorted().collect(Collectors.toList());
+ var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList());
+
+ assertEquals(expected.toString(), actual.toString());
+ }
+
+ @Test
+ public void testActorService() {
+ // verify that it all plugs into the ActorService
+ verifyActorService(SdnrActorServiceProvider.NAME, "service.yaml");
+ }
+
+ @Test
public void testGetOperator() {
SdnrActorServiceProvider sp = new SdnrActorServiceProvider();
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/resources/service.yaml b/models-interactions/model-actors/actor.sdnr/src/test/resources/service.yaml
new file mode 100644
index 000000000..f18e99cdd
--- /dev/null
+++ b/models-interactions/model-actors/actor.sdnr/src/test/resources/service.yaml
@@ -0,0 +1,38 @@
+#
+# ============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========================================================
+#
+topics:
+ topicSources:
+ - topicCommInfrastructure: NOOP
+ topic: my-source
+ servers:
+ - localhost
+ managed: true
+ topicSinks:
+ - topicCommInfrastructure: NOOP
+ topic: my-sink
+ servers:
+ - localhost
+ managed: true
+actors:
+ SDNR:
+ sinkTopic: my-sink
+ sourceTopic: my-source
+ operations:
+ any: {}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
index e4b9c14fe..642e2b455 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
@@ -36,6 +36,8 @@ import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpActor;
+import org.onap.policy.controlloop.actorserviceprovider.impl.HttpPollingOperator;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingActorParams;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.so.SoCloudConfiguration;
import org.onap.policy.so.SoManager;
@@ -51,7 +53,7 @@ import org.onap.policy.so.util.Serialization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SoActorServiceProvider extends HttpActor<SoActorParams> {
+public class SoActorServiceProvider extends HttpActor<HttpPollingActorParams> {
private static final Logger logger = LoggerFactory.getLogger(SoActorServiceProvider.class);
public static final String NAME = "SO";
@@ -96,10 +98,10 @@ public class SoActorServiceProvider extends HttpActor<SoActorParams> {
* Constructs the object.
*/
public SoActorServiceProvider() {
- super(NAME, SoActorParams.class);
+ super(NAME, HttpPollingActorParams.class);
- addOperator(new SoOperator(NAME, VfModuleCreate.NAME, VfModuleCreate::new));
- addOperator(new SoOperator(NAME, VfModuleDelete.NAME, VfModuleDelete::new));
+ addOperator(new HttpPollingOperator(NAME, VfModuleCreate.NAME, VfModuleCreate::new));
+ addOperator(new HttpPollingOperator(NAME, VfModuleDelete.NAME, VfModuleDelete::new));
}
// TODO old code: remove lines down to **HERE**
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 a8900f76b..cb9ec9c40 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
@@ -29,19 +29,14 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Function;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import lombok.Getter;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.aai.AaiConstants;
import org.onap.policy.aai.AaiCqResponse;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -50,7 +45,7 @@ import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.controlloop.policy.Target;
import org.onap.policy.so.SoCloudConfiguration;
@@ -61,15 +56,12 @@ import org.onap.policy.so.SoRequestParameters;
import org.onap.policy.so.SoRequestStatus;
import org.onap.policy.so.SoResponse;
import org.onap.policy.so.util.SoLocalDateTimeTypeAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
- * Superclass for SDNC Operators. Note: subclasses should invoke {@link #resetGetCount()}
+ * Superclass for SDNC Operators. Note: subclasses should invoke {@link #resetPollCount()}
* each time they issue an HTTP request.
*/
public abstract class SoOperation extends HttpOperation<SoResponse> {
- private static final Logger logger = LoggerFactory.getLogger(SoOperation.class);
private static final Coder coder = new SoCoder();
public static final String PAYLOAD_KEY_VF_COUNT = "vfCount";
@@ -81,8 +73,6 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
public static final String REQ_PARAM_NM = "requestParameters";
public static final String CONFIG_PARAM_NM = "configurationParameters";
- private final SoConfig config;
-
// values extracted from the parameter Target
private final String modelCustomizationId;
private final String modelInvariantId;
@@ -90,12 +80,6 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
private final String vfCountKey;
- /**
- * Number of "get" requests issued so far, on the current operation attempt.
- */
- @Getter
- private int getCount;
-
/**
* Constructs the object.
@@ -103,9 +87,10 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
* @param params operation parameters
* @param config configuration for this operation
*/
- public SoOperation(ControlLoopOperationParams params, HttpConfig config) {
+ public SoOperation(ControlLoopOperationParams params, HttpPollingConfig config) {
super(params, config, SoResponse.class);
- this.config = (SoConfig) config;
+
+ setUsePolling();
verifyNotNull("Target information", params.getTarget());
@@ -117,11 +102,9 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
+ modelVersionId + "]";
}
- /**
- * Subclasses should invoke this before issuing their first HTTP request.
- */
- protected void resetGetCount() {
- getCount = 0;
+ @Override
+ protected void resetPollCount() {
+ super.resetPollCount();
setSubRequestId(null);
}
@@ -193,28 +176,18 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
params.getContext().setProperty(vfCountKey, vfCount);
}
- /**
- * If the response does not indicate that the request has been completed, then sleep a
- * bit and issue a "get".
- */
@Override
- protected CompletableFuture<OperationOutcome> postProcessResponse(OperationOutcome outcome, String url,
- Response rawResponse, SoResponse response) {
-
- // see if the request has "completed", whether or not it was successful
+ protected Status detmStatus(Response rawResponse, SoResponse response) {
if (rawResponse.getStatus() == 200) {
String requestState = getRequestState(response);
if (COMPLETE.equalsIgnoreCase(requestState)) {
extractSubRequestId(response);
- successfulCompletion();
- return CompletableFuture
- .completedFuture(setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response));
+ return Status.SUCCESS;
}
if (FAILED.equalsIgnoreCase(requestState)) {
extractSubRequestId(response);
- return CompletableFuture
- .completedFuture(setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response));
+ return Status.FAILURE;
}
}
@@ -225,18 +198,12 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
throw new IllegalArgumentException("missing request ID in response");
}
- // see if the limit for the number of "gets" has been reached
- if (getCount++ >= getMaxGets()) {
- logger.warn("{}: execeeded 'get' limit {} for {}", getFullName(), getMaxGets(), params.getRequestId());
- setOutcome(outcome, PolicyResult.FAILURE_TIMEOUT);
- outcome.setResponse(response);
- outcome.setMessage(SO_RESPONSE_CODE + " " + outcome.getMessage());
- return CompletableFuture.completedFuture(outcome);
- }
+ return Status.STILL_WAITING;
+ }
- // sleep and then perform a "get" operation
- Function<Void, CompletableFuture<OperationOutcome>> doGet = unused -> issueGet(outcome);
- return sleep(getWaitMsGet(), TimeUnit.MILLISECONDS).thenComposeAsync(doGet);
+ @Override
+ protected String getPollingPath() {
+ return super.getPollingPath() + getSubRequestId();
}
@Override
@@ -255,30 +222,6 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
}
/**
- * Invoked when a request completes successfully.
- */
- protected void successfulCompletion() {
- // do nothing
- }
-
- /**
- * Issues a "get" request to see if the original request is complete yet.
- *
- * @param outcome outcome to be populated with the response
- * @return a future that can be used to cancel the "get" request or await its response
- */
- private CompletableFuture<OperationOutcome> issueGet(OperationOutcome outcome) {
- String path = getPathGet() + getSubRequestId();
- String url = getClient().getBaseUrl() + path;
-
- logger.debug("{}: 'get' count {} for {}", getFullName(), getCount, params.getRequestId());
-
- logMessage(EventType.OUT, CommInfrastructure.REST, url, null);
-
- return handleResponse(outcome, url, callback -> getClient().get(callback, path, null));
- }
-
- /**
* Gets the request state of a response.
*
* @param response response from which to get the state
@@ -317,8 +260,10 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
// set default result and message
setOutcome(outcome, result);
+ int code = (result == PolicyResult.FAILURE_TIMEOUT ? SO_RESPONSE_CODE : rawResponse.getStatus());
+
outcome.setResponse(response);
- outcome.setMessage(rawResponse.getStatus() + " " + outcome.getMessage());
+ outcome.setMessage(code + " " + outcome.getMessage());
return outcome;
}
@@ -467,27 +412,6 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
// these may be overridden by junit tests
- /**
- * Gets the wait time, in milliseconds, between "get" requests.
- *
- * @return the wait time, in milliseconds, between "get" requests
- */
- public long getWaitMsGet() {
- return TimeUnit.MILLISECONDS.convert(getWaitSecGet(), TimeUnit.SECONDS);
- }
-
- public int getMaxGets() {
- return config.getMaxGets();
- }
-
- public String getPathGet() {
- return config.getPathGet();
- }
-
- public int getWaitSecGet() {
- return config.getWaitSecGet();
- }
-
@Override
protected Coder getCoder() {
return coder;
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java
deleted file mode 100644
index b8d0e652a..000000000
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============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.actor.so;
-
-import java.util.Map;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
-import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
-import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-
-/**
- * SO Operator.
- */
-public class SoOperator extends HttpOperator {
-
- public SoOperator(String actorName, String name,
- @SuppressWarnings("rawtypes") OperationMaker<HttpConfig, HttpOperation> operationMaker) {
- super(actorName, name, operationMaker);
- }
-
- @Override
- protected HttpConfig makeConfiguration(Map<String, Object> parameters) {
- SoParams params = Util.translate(getFullName(), parameters, SoParams.class);
- ValidationResult result = params.validate(getFullName());
- if (!result.isValid()) {
- throw new ParameterValidationRuntimeException("invalid parameters", result);
- }
-
- return new SoConfig(getBlockingExecutor(), params, getClientFactory());
- }
-}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
index 6a6c79279..c56bc222f 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.tuple.Pair;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.GenericVnf;
@@ -35,7 +36,7 @@ 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.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.so.SoModelInfo;
import org.onap.policy.so.SoOperationType;
import org.onap.policy.so.SoRelatedInstance;
@@ -43,6 +44,7 @@ import org.onap.policy.so.SoRelatedInstanceListElement;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoRequestDetails;
import org.onap.policy.so.SoRequestParameters;
+import org.onap.policy.so.SoResponse;
/**
* Operation to create a VF Module. This gets the VF count from the A&AI Custom Query
@@ -61,7 +63,7 @@ public class VfModuleCreate extends SoOperation {
* @param params operation parameters
* @param config configuration for this operation
*/
- public VfModuleCreate(ControlLoopOperationParams params, HttpConfig config) {
+ public VfModuleCreate(ControlLoopOperationParams params, HttpPollingConfig config) {
super(params, config);
// ensure we have the necessary parameters
@@ -101,7 +103,7 @@ public class VfModuleCreate extends SoOperation {
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
// starting a whole new attempt - reset the count
- resetGetCount();
+ resetPollCount();
Pair<String, SoRequest> pair = makeRequest();
String path = getPath() + pair.getLeft();
@@ -120,11 +122,18 @@ public class VfModuleCreate extends SoOperation {
}
/**
- * Increments the VF count that's stored in the context.
+ * Increments the VF count that's stored in the context, if the request was
+ * successful.
*/
@Override
- protected void successfulCompletion() {
- setVfCount(getVfCount() + 1);
+ protected Status detmStatus(Response rawResponse, SoResponse response) {
+ Status status = super.detmStatus(rawResponse, response);
+
+ if (status == Status.SUCCESS) {
+ setVfCount(getVfCount() + 1);
+ }
+
+ return status;
}
/**
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
index 9dbdc58d8..c67243f9f 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
@@ -47,12 +47,13 @@ import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture;
import org.onap.policy.so.SoModelInfo;
import org.onap.policy.so.SoOperationType;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoRequestDetails;
+import org.onap.policy.so.SoResponse;
/**
* Operation to delete a VF Module. This gets the VF count from the A&AI Custom Query
@@ -71,7 +72,7 @@ public class VfModuleDelete extends SoOperation {
* @param params operation parameters
* @param config configuration for this operation
*/
- public VfModuleDelete(ControlLoopOperationParams params, HttpConfig config) {
+ public VfModuleDelete(ControlLoopOperationParams params, HttpPollingConfig config) {
super(params, config);
// ensure we have the necessary parameters
@@ -111,7 +112,7 @@ public class VfModuleDelete extends SoOperation {
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
// starting a whole new attempt - reset the count
- resetGetCount();
+ resetPollCount();
Pair<String, SoRequest> pair = makeRequest();
SoRequest request = pair.getRight();
@@ -203,12 +204,20 @@ public class VfModuleDelete extends SoOperation {
return builder.header("Authorization", "Basic " + encoded);
}
+
/**
- * Decrements the VF count that's stored in the context.
+ * Decrements the VF count that's stored in the context, if the request was
+ * successful.
*/
@Override
- protected void successfulCompletion() {
- setVfCount(getVfCount() - 1);
+ protected Status detmStatus(Response rawResponse, SoResponse response) {
+ Status status = super.detmStatus(rawResponse, response);
+
+ if (status == Status.SUCCESS) {
+ setVfCount(getVfCount() - 1);
+ }
+
+ return status;
}
/**
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
index 11418ff75..c8afab450 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java
@@ -35,6 +35,7 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.policy.Target;
import org.onap.policy.simulators.SoSimulatorJaxRs;
import org.onap.policy.so.SoRequest;
@@ -56,13 +57,13 @@ public abstract class BasicSoOperation extends BasicHttpOperation<SoRequest> {
public static final String MODEL_VERS_ID = "my-model-version-id";
public static final String SUBSCRIPTION_SVC_TYPE = "my-subscription-service-type";
public static final String MY_PATH = "my-path";
- public static final String PATH_GET = "my-path-get/";
- public static final int MAX_GETS = 3;
- public static final int WAIT_SEC_GETS = 20;
+ public static final String POLL_PATH = "my-poll-path/";
+ public static final int MAX_POLLS = 3;
+ public static final int POLL_WAIT_SEC = 20;
public static final Integer VF_COUNT = 10;
@Mock
- protected SoConfig config;
+ protected HttpPollingConfig config;
protected Target target;
protected SoResponse response;
@@ -134,9 +135,9 @@ public abstract class BasicSoOperation extends BasicHttpOperation<SoRequest> {
super.initConfig();
when(config.getClient()).thenReturn(client);
when(config.getPath()).thenReturn(MY_PATH);
- when(config.getMaxGets()).thenReturn(MAX_GETS);
- when(config.getPathGet()).thenReturn(PATH_GET);
- when(config.getWaitSecGet()).thenReturn(WAIT_SEC_GETS);
+ when(config.getMaxPolls()).thenReturn(MAX_POLLS);
+ when(config.getPollPath()).thenReturn(POLL_PATH);
+ when(config.getPollWaitSec()).thenReturn(POLL_WAIT_SEC);
}
@Override
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 b794eab4e..46d96fded 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
@@ -28,7 +28,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -37,8 +36,6 @@ import java.time.Month;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.junit.Before;
@@ -56,7 +53,6 @@ import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.so.SoModelInfo;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoRequestInfo;
-import org.onap.policy.so.SoRequestReferences;
import org.onap.policy.so.SoRequestStatus;
import org.onap.policy.so.SoResponse;
@@ -79,11 +75,11 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testConstructor_testGetWaitMsGet() {
+ public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
assertSame(config, oper.getConfig());
- assertEquals(1000 * WAIT_SEC_GETS, oper.getWaitMsGet());
+ assertTrue(oper.isUsePolling());
// check when Target is null
params = params.toBuilder().target(null).build();
@@ -167,98 +163,6 @@ public class SoOperationTest extends BasicSoOperation {
}
@Test
- public void testPostProcess() throws Exception {
- // completed
- oper.generateSubRequestId(2);
- assertNull(oper.getSubRequestId());
- CompletableFuture<OperationOutcome> future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
- assertTrue(future2.isDone());
- assertSame(outcome, future2.get());
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
- assertNotNull(oper.getSubRequestId());
- assertSame(response, outcome.getResponse());
-
- // failed
- oper.generateSubRequestId(2);
- assertNull(oper.getSubRequestId());
- response.getRequest().getRequestStatus().setRequestState(SoOperation.FAILED);
- future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
- assertTrue(future2.isDone());
- assertSame(outcome, future2.get());
- assertEquals(PolicyResult.FAILURE, outcome.getResult());
- assertNotNull(oper.getSubRequestId());
- assertSame(response, outcome.getResponse());
-
- // no request id in the response
- oper.generateSubRequestId(2);
- assertNull(oper.getSubRequestId());
- response.getRequestReferences().setRequestId(null);
- response.getRequest().getRequestStatus().setRequestState("unknown");
- assertThatIllegalArgumentException()
- .isThrownBy(() -> oper.postProcessResponse(outcome, PATH, rawResponse, response))
- .withMessage("missing request ID in response");
- response.getRequestReferences().setRequestId(REQ_ID.toString());
-
- // status = 500
- when(rawResponse.getStatus()).thenReturn(500);
-
- // null request reference
- SoRequestReferences ref = response.getRequestReferences();
- response.setRequestReferences(null);
- assertThatIllegalArgumentException()
- .isThrownBy(() -> oper.postProcessResponse(outcome, PATH, rawResponse, response))
- .withMessage("missing request ID in response");
- response.setRequestReferences(ref);
- }
-
- /**
- * Tests postProcess() when the "get" is repeated a couple of times.
- */
- @Test
- public void testPostProcessRepeated_testResetGetCount() throws Exception {
- /*
- * Two failures and then a success - should result in two "get" calls.
- *
- * Note: getStatus() is invoked twice during each call, so have to double up the
- * return values.
- */
- when(rawResponse.getStatus()).thenReturn(500, 500, 500, 500, 200, 200);
-
- when(client.get(any(), any(), any())).thenAnswer(provideResponse(rawResponse));
-
- // use a real executor
- params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
-
- oper = new SoOperation(params, config) {
- @Override
- public long getWaitMsGet() {
- return 1;
- }
- };
-
- CompletableFuture<OperationOutcome> future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
-
- assertSame(outcome, future2.get(5, TimeUnit.SECONDS));
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
- assertEquals(2, oper.getGetCount());
-
- /*
- * repeat - this time, the "get" operations will be exhausted, so it should fail
- */
- when(rawResponse.getStatus()).thenReturn(500);
-
- future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
-
- assertSame(outcome, future2.get(5, TimeUnit.SECONDS));
- assertEquals(PolicyResult.FAILURE_TIMEOUT, outcome.getResult());
- assertEquals(MAX_GETS + 1, oper.getGetCount());
-
- oper.resetGetCount();
- assertEquals(0, oper.getGetCount());
- assertNull(oper.getSubRequestId());
- }
-
- @Test
public void testGetRequestState() {
SoResponse resp = new SoResponse();
assertNull(oper.getRequestState(resp));
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
index 2b3e1163b..94268646d 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java
@@ -51,6 +51,8 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoResponse;
@@ -88,11 +90,13 @@ public class VfModuleCreateTest extends BasicSoOperation {
*/
@Test
public void testSuccess() throws Exception {
- SoParams opParams = SoParams.builder().clientName(MY_CLIENT).path("serviceInstantiation/v7/serviceInstances")
- .pathGet("orchestrationRequests/v5/").maxGets(2).build();
- config = new SoConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
+ HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT)
+ .path("serviceInstantiation/v7/serviceInstances").pollPath("orchestrationRequests/v5/")
+ .maxPolls(2).build();
+ config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
+
oper = new VfModuleCreate(params, config);
outcome = oper.start().get();
@@ -179,7 +183,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
oper = new VfModuleCreate(params, config) {
@Override
- public long getWaitMsGet() {
+ protected long getPollWaitMs() {
return 1;
}
};
@@ -197,10 +201,10 @@ public class VfModuleCreateTest extends BasicSoOperation {
}
/**
- * Tests startOperationAsync() when "get" operations are required.
+ * Tests startOperationAsync() when polling is required.
*/
@Test
- public void testStartOperationAsyncWithGets() throws Exception {
+ public void testStartOperationAsyncWithPolling() throws Exception {
when(rawResponse.getStatus()).thenReturn(500, 500, 500, 500, 200, 200);
when(client.post(any(), any(), any(), any())).thenAnswer(provideResponse(rawResponse));
@@ -211,7 +215,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
oper = new VfModuleCreate(params, config) {
@Override
- public long getWaitMsGet() {
+ public long getPollWaitMs() {
return 1;
}
};
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
index f5d05a0e8..d7b53411b 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
+++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java
@@ -64,7 +64,8 @@ import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoResponse;
@@ -119,11 +120,12 @@ public class VfModuleDeleteTest extends BasicSoOperation {
*/
@Test
public void testSuccess() throws Exception {
- SoParams opParams = SoParams.builder().clientName(MY_CLIENT).path("serviceInstances/v7")
- .pathGet("orchestrationRequests/v5/").maxGets(2).build();
- config = new SoConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
+ HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT).path("serviceInstances/v7")
+ .pollPath("orchestrationRequests/v5/").maxPolls(2).build();
+ config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
+
oper = new VfModuleDelete(params, config);
outcome = oper.start().get();
@@ -138,7 +140,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
// verify that target validation is done
params = params.toBuilder().target(null).build();
- assertThatIllegalArgumentException().isThrownBy(() -> new VfModuleDelete(params, config))
+ assertThatIllegalArgumentException().isThrownBy(() -> new MyOperation(params, config))
.withMessageContaining("Target information");
}
@@ -208,7 +210,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
oper = new MyOperation(params, config) {
@Override
- public long getWaitMsGet() {
+ public long getPollWaitMs() {
return 1;
}
};
@@ -226,10 +228,10 @@ public class VfModuleDeleteTest extends BasicSoOperation {
}
/**
- * Tests startOperationAsync() when "get" operations are required.
+ * Tests startOperationAsync() when polling is required.
*/
@Test
- public void testStartOperationAsyncWithGets() throws Exception {
+ public void testStartOperationAsyncWithPolling() throws Exception {
// indicate that the response was incomplete
configureResponse(coder.encode(response).replace("COMPLETE", "incomplete"));
@@ -242,7 +244,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
oper = new MyOperation(params, config) {
@Override
- public long getWaitMsGet() {
+ public long getPollWaitMs() {
return 1;
}
};
@@ -383,7 +385,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
@Test
public void testMakeHttpClient() {
// must use a real operation to invoke this method
- assertNotNull(new VfModuleDelete(params, config).makeHttpClient());
+ assertNotNull(new MyOperation(params, config).makeHttpClient());
}
@@ -428,7 +430,7 @@ public class VfModuleDeleteTest extends BasicSoOperation {
private class MyOperation extends VfModuleDelete {
- public MyOperation(ControlLoopOperationParams params, HttpConfig config) {
+ public MyOperation(ControlLoopOperationParams params, HttpPollingConfig config) {
super(params, config);
}
diff --git a/models-interactions/model-actors/actor.so/src/test/resources/service.yaml b/models-interactions/model-actors/actor.so/src/test/resources/service.yaml
index e1cb0d9f3..e16e7d74a 100644
--- a/models-interactions/model-actors/actor.so/src/test/resources/service.yaml
+++ b/models-interactions/model-actors/actor.so/src/test/resources/service.yaml
@@ -26,8 +26,11 @@ httpClients:
actors:
SO:
clientName: my-client
+ pollPath: orchestrationRequests/v5
+ pollWaitSec: 20
+ maxPolls: 20
operations:
VF Module Create:
path: serviceInstantiation/v7/serviceInstances
VF Module Delete:
- path: serviceInstances/v7 \ No newline at end of file
+ path: serviceInstances/v7
diff --git a/models-interactions/model-actors/actor.test/src/test/resources/service.yaml b/models-interactions/model-actors/actor.test/src/test/resources/service.yaml
index 49de7da51..1d1604034 100644
--- a/models-interactions/model-actors/actor.test/src/test/resources/service.yaml
+++ b/models-interactions/model-actors/actor.test/src/test/resources/service.yaml
@@ -19,5 +19,6 @@
#
actors:
MyActor:
- MyOperationA: {}
- MyOperationB: {} \ No newline at end of file
+ operations:
+ MyOperationA: {}
+ MyOperationB: {}
diff --git a/models-interactions/model-actors/actor.test/src/test/resources/serviceFull.yaml b/models-interactions/model-actors/actor.test/src/test/resources/serviceFull.yaml
index 9818215be..8c6271e85 100644
--- a/models-interactions/model-actors/actor.test/src/test/resources/serviceFull.yaml
+++ b/models-interactions/model-actors/actor.test/src/test/resources/serviceFull.yaml
@@ -38,5 +38,6 @@ topics:
managed: true
actors:
MyActor:
- MyOperationA: {}
- MyOperationB: {} \ No newline at end of file
+ operations:
+ MyOperationA: {}
+ MyOperationB: {}
diff --git a/models-interactions/model-actors/actor.test/src/test/resources/serviceInvalidHttp.yaml b/models-interactions/model-actors/actor.test/src/test/resources/serviceInvalidHttp.yaml
index b31e8e81e..416126893 100644
--- a/models-interactions/model-actors/actor.test/src/test/resources/serviceInvalidHttp.yaml
+++ b/models-interactions/model-actors/actor.test/src/test/resources/serviceInvalidHttp.yaml
@@ -25,5 +25,6 @@ httpClients:
managed: true
actors:
MyActor:
- MyOperationA: {}
- MyOperationB: {} \ No newline at end of file
+ operations:
+ MyOperationA: {}
+ MyOperationB: {}
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/Restart.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/Restart.java
index b6b82d14f..bc9642888 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/Restart.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/Restart.java
@@ -41,7 +41,7 @@ public class Restart extends VfcOperation {
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
// starting a whole new attempt - reset the count
- resetGetCount();
+ resetPollCount();
Pair<String, VfcRequest> pair = makeRequest();
Entity<VfcRequest> entity = Entity.entity(pair.getRight(), MediaType.APPLICATION_JSON);
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
index 5bd6b59ad..768ad4c11 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
@@ -27,14 +27,16 @@ import java.util.List;
import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
-import org.onap.policy.controlloop.actorserviceprovider.impl.ActorImpl;
+import org.onap.policy.controlloop.actorserviceprovider.impl.HttpActor;
+import org.onap.policy.controlloop.actorserviceprovider.impl.HttpPollingOperator;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingActorParams;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.vfc.VfcHealActionVmInfo;
import org.onap.policy.vfc.VfcHealAdditionalParams;
import org.onap.policy.vfc.VfcHealRequest;
import org.onap.policy.vfc.VfcRequest;
-public class VfcActorServiceProvider extends ActorImpl {
+public class VfcActorServiceProvider extends HttpActor<HttpPollingActorParams> {
private static final String GENERIC_VNF_ID = "generic-vnf.vnf-id";
// TODO old code: remove lines down to **HERE**
@@ -60,9 +62,9 @@ public class VfcActorServiceProvider extends ActorImpl {
* Constructor.
*/
public VfcActorServiceProvider() {
- super(NAME);
+ super(NAME, HttpPollingActorParams.class);
- addOperator(new VfcOperator(NAME, Restart.NAME, Restart::new));
+ addOperator(new HttpPollingOperator(NAME, Restart.NAME, Restart::new));
}
// TODO old code: remove lines down to **HERE**
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcConfig.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcConfig.java
deleted file mode 100644
index 4b5088a3a..000000000
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcConfig.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============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.actor.vfc;
-
-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;
-
-@Getter
-public class VfcConfig extends HttpConfig {
-
- /**
- * Path to use for the "get" request. A trailing "/" is added, if it is missing.
- */
- private String pathGet;
-
- /**
- * Maximum number of "get" requests permitted, after the initial request, to retrieve
- * the response.
- */
- private int maxGets;
-
- /**
- * Time, in seconds, to wait between issuing "get" requests.
- */
- private int waitSecGet;
-
- /**
- * Constructor.
- *
- * @param blockingExecutor executor to be used for tasks that may perform blocking I/O
- * @param params operator parameters
- * @param clientFactory factory from which to obtain the {@link HttpClient}
- */
- public VfcConfig(Executor blockingExecutor, VfcParams params, HttpClientFactory clientFactory) {
- super(blockingExecutor, params, clientFactory);
-
- this.pathGet = params.getPathGet() + (params.getPathGet().endsWith("/") ? "" : "/");
- this.maxGets = params.getMaxGets();
- this.waitSecGet = params.getWaitSecGet();
- }
-
-}
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
index 573ee2698..d5ee44a5d 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperation.java
@@ -21,13 +21,8 @@
package org.onap.policy.controlloop.actor.vfc;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Function;
import javax.ws.rs.core.Response;
-import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
-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.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
@@ -39,12 +34,8 @@ import org.onap.policy.vfc.VfcHealAdditionalParams;
import org.onap.policy.vfc.VfcHealRequest;
import org.onap.policy.vfc.VfcRequest;
import org.onap.policy.vfc.VfcResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public abstract class VfcOperation extends HttpOperation<VfcResponse> {
- private static final Logger logger = LoggerFactory.getLogger(VfcOperation.class);
-
public static final String FAILED = "FAILED";
public static final String COMPLETE = "COMPLETE";
public static final int VFC_RESPONSE_CODE = 999;
@@ -53,13 +44,11 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
public static final String REQ_PARAM_NM = "requestParameters";
public static final String CONFIG_PARAM_NM = "configurationParameters";
- private final VfcConfig config;
-
/**
- * Number of "get" requests issued so far, on the current operation attempt.
+ * Job ID extracted from the first response.
*/
- @Getter
- private int getCount;
+ private String jobId;
+
/**
* Constructs the object.
@@ -69,14 +58,19 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
*/
public VfcOperation(ControlLoopOperationParams params, HttpConfig config) {
super(params, config, VfcResponse.class);
- this.config = (VfcConfig) config;
+
+ setUsePolling();
}
- /**
- * Subclasses should invoke this before issuing their first HTTP request.
- */
- protected void resetGetCount() {
- getCount = 0;
+ @Override
+ protected void resetPollCount() {
+ super.resetPollCount();
+ jobId = null;
+ }
+
+ @Override
+ protected String getPollingPath() {
+ return super.getPollingPath() + jobId;
}
/**
@@ -87,64 +81,38 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
return startGuardAsync();
}
- /**
- * If the response does not indicate that the request has been completed, then sleep a
- * bit and issue a "get".
- */
@Override
- protected CompletableFuture<OperationOutcome> postProcessResponse(OperationOutcome outcome, String url,
- Response rawResponse, VfcResponse response) {
- // Determine if the request has "completed" and determine if it was successful
+ protected Status detmStatus(Response rawResponse, VfcResponse response) {
if (rawResponse.getStatus() == 200) {
String requestState = getRequestState(response);
if ("finished".equalsIgnoreCase(requestState)) {
- return CompletableFuture
- .completedFuture(setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response));
+ extractJobId(response);
+ return Status.SUCCESS;
}
if ("error".equalsIgnoreCase(requestState)) {
- return CompletableFuture
- .completedFuture(setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response));
+ extractJobId(response);
+ return Status.FAILURE;
}
}
// still incomplete
- // need a request ID with which to query
- if (response == null || response.getJobId() == null) {
+ // need a job ID with which to query
+ if (jobId == null && !extractJobId(response)) {
throw new IllegalArgumentException("missing job ID in response");
}
- // see if the limit for the number of "gets" has been reached
- if (getCount++ >= getMaxGets()) {
- logger.warn("{}: execeeded 'get' limit {} for {}", getFullName(), getMaxGets(), params.getRequestId());
- setOutcome(outcome, PolicyResult.FAILURE_TIMEOUT);
- outcome.setResponse(response);
- outcome.setMessage(VFC_RESPONSE_CODE + " " + outcome.getMessage());
- return CompletableFuture.completedFuture(outcome);
- }
-
- // sleep and then perform a "get" operation
- Function<Void, CompletableFuture<OperationOutcome>> doGet = unused -> issueGet(outcome, response);
- return sleep(getWaitMsGet(), TimeUnit.MILLISECONDS).thenComposeAsync(doGet);
+ return Status.STILL_WAITING;
}
- /**
- * Issues a "get" request to see if the original request is complete yet.
- *
- * @param outcome outcome to be populated with the response
- * @param response previous response
- * @return a future that can be used to cancel the "get" request or await its response
- */
- private CompletableFuture<OperationOutcome> issueGet(OperationOutcome outcome, VfcResponse response) {
- String path = getPathGet() + response.getJobId();
- String url = getClient().getBaseUrl() + path;
-
- logger.debug("{}: 'get' count {} for {}", getFullName(), getCount, params.getRequestId());
-
- logMessage(EventType.OUT, CommInfrastructure.REST, url, null);
+ private boolean extractJobId(VfcResponse response) {
+ if (response == null || response.getJobId() == null) {
+ return false;
+ }
- return handleResponse(outcome, url, callback -> getClient().get(callback, path, null));
+ jobId = response.getJobId();
+ return true;
}
/**
@@ -180,8 +148,10 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
// set default result and message
setOutcome(outcome, result);
+ int code = (result == PolicyResult.FAILURE_TIMEOUT ? VFC_RESPONSE_CODE : rawResponse.getStatus());
+
outcome.setResponse(response);
- outcome.setMessage(rawResponse.getStatus() + " " + outcome.getMessage());
+ outcome.setMessage(code + " " + outcome.getMessage());
return outcome;
}
@@ -221,27 +191,4 @@ public abstract class VfcOperation extends HttpOperation<VfcResponse> {
return request;
}
-
- // These may be overridden by jUnit tests
-
- /**
- * Gets the wait time, in milliseconds, between "get" requests.
- *
- * @return the wait time, in milliseconds, between "get" requests
- */
- public long getWaitMsGet() {
- return TimeUnit.MILLISECONDS.convert(getWaitSecGet(), TimeUnit.SECONDS);
- }
-
- public int getMaxGets() {
- return config.getMaxGets();
- }
-
- public String getPathGet() {
- return config.getPathGet();
- }
-
- public int getWaitSecGet() {
- return config.getWaitSecGet();
- }
}
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperator.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperator.java
deleted file mode 100644
index 4e70d6550..000000000
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcOperator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============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.actor.vfc;
-
-import java.util.Map;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
-import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
-import org.onap.policy.controlloop.actorserviceprovider.impl.OperationMaker;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-
-public class VfcOperator extends HttpOperator {
-
- public VfcOperator(String actorName, String name,
- @SuppressWarnings("rawtypes") OperationMaker<HttpConfig, HttpOperation> operationMaker) {
- super(actorName, name, operationMaker);
- }
-
- @Override
- protected HttpConfig makeConfiguration(Map<String, Object> parameters) {
- VfcParams params = Util.translate(getFullName(), parameters, VfcParams.class);
- ValidationResult result = params.validate(getFullName());
- if (!result.isValid()) {
- throw new ParameterValidationRuntimeException("invalid parameters", result);
- }
-
- return new VfcConfig(getBlockingExecutor(), params, getClientFactory());
- }
-}
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcParams.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcParams.java
deleted file mode 100644
index 31c2a9441..000000000
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcParams.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============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.actor.vfc;
-
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.experimental.SuperBuilder;
-import org.onap.policy.common.parameters.annotations.Min;
-import org.onap.policy.common.parameters.annotations.NotBlank;
-import org.onap.policy.common.parameters.annotations.NotNull;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
-
-@NotNull
-@NotBlank
-@Data
-@EqualsAndHashCode(callSuper = true)
-@SuperBuilder(toBuilder = true)
-public class VfcParams extends HttpParams {
-
- /**
- * Path to use for the "get" request.
- */
- private String pathGet;
-
- /**
- * Maximum number of "get" requests permitted, after the initial request, to retrieve
- * the response.
- */
- @Min(0)
- private int maxGets;
-
- /**
- * Time, in seconds, to wait between issuing "get" requests.
- */
- @Min(1)
- private int waitSecGet;
-}
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java
index 47371d2b3..d41da1b87 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java
@@ -27,17 +27,18 @@ import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.simulators.Util;
import org.onap.policy.vfc.VfcRequest;
import org.onap.policy.vfc.VfcResponse;
public abstract class BasicVfcOperation extends BasicHttpOperation<VfcRequest> {
- public static final String PATH_GET = "my-path-get/";
- public static final int MAX_GETS = 3;
- public static final int WAIT_SEC_GETS = 20;
+ public static final String POLL_PATH = "my-path-get/";
+ public static final int MAX_POLLS = 3;
+ public static final int POLL_WAIT_SEC = 20;
@Mock
- protected VfcConfig config;
+ protected HttpPollingConfig config;
protected VfcResponse response;
@@ -94,9 +95,9 @@ public abstract class BasicVfcOperation extends BasicHttpOperation<VfcRequest> {
protected void initConfig() {
super.initConfig();
when(config.getClient()).thenReturn(client);
- when(config.getMaxGets()).thenReturn(MAX_GETS);
- when(config.getPathGet()).thenReturn(PATH_GET);
- when(config.getWaitSecGet()).thenReturn(WAIT_SEC_GETS);
+ when(config.getMaxPolls()).thenReturn(MAX_POLLS);
+ when(config.getPollPath()).thenReturn(POLL_PATH);
+ when(config.getPollWaitSec()).thenReturn(POLL_WAIT_SEC);
}
}
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
index d8ba7e4e8..ed072f761 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java
@@ -32,6 +32,8 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.vfc.VfcRequest;
import org.onap.policy.vfc.VfcResponse;
@@ -66,10 +68,12 @@ public class RestartTest extends BasicVfcOperation {
*/
@Test
public void testSuccess() throws Exception {
- VfcParams opParams = VfcParams.builder().clientName(MY_CLIENT).path("ns").pathGet("jobs").maxGets(1).build();
- config = new VfcConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
+ HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT).path("ns").pollPath("jobs")
+ .maxPolls(1).build();
+ config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
+
restartOper = new Restart(params, config);
outcome = restartOper.start().get();
@@ -81,7 +85,7 @@ public class RestartTest extends BasicVfcOperation {
public void testConstructor() {
CompletableFuture<OperationOutcome> futureRes = restartOper.startOperationAsync(1, outcome);
assertNotNull(futureRes);
- assertEquals(0, restartOper.getGetCount());
+ assertEquals(0, restartOper.getPollCount());
}
@Test
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
index db224b065..9e05f22e1 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProviderTest.java
@@ -28,8 +28,10 @@ import static org.junit.Assert.assertNull;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import java.util.Objects;
import java.util.UUID;
+import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -38,11 +40,12 @@ import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
+import org.onap.policy.controlloop.actor.test.BasicActor;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.simulators.Util;
import org.onap.policy.vfc.VfcRequest;
-public class VfcActorServiceProviderTest {
+public class VfcActorServiceProviderTest extends BasicActor {
private static final String DOROTHY_GALE_1939 = "dorothy.gale.1939";
private static final String CQ_RESPONSE_JSON = "aai/AaiCqResponse.json";
@@ -63,6 +66,24 @@ public class VfcActorServiceProviderTest {
}
@Test
+ public void testConstructor() {
+ VfcActorServiceProvider prov = new VfcActorServiceProvider();
+ assertEquals(0, prov.getSequenceNumber());
+
+ // verify that it has the operators we expect
+ var expected = Arrays.asList(Restart.NAME).stream().sorted().collect(Collectors.toList());
+ var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList());
+
+ assertEquals(expected.toString(), actual.toString());
+ }
+
+ @Test
+ public void testActorService() {
+ // verify that it all plugs into the ActorService
+ verifyActorService(VfcActorServiceProvider.NAME, "service.yaml");
+ }
+
+ @Test
public void testMethods() {
VfcActorServiceProvider sp = new VfcActorServiceProvider();
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcConfigTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcConfigTest.java
deleted file mode 100644
index f03e32393..000000000
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcConfigTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============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.actor.vfc;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.when;
-
-import java.util.concurrent.Executor;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.policy.common.endpoints.http.client.HttpClient;
-import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-
-public class VfcConfigTest {
- private static final String MY_CLIENT = "my-client";
- private static final String MY_PATH = "my-path";
- private static final String GET_PATH = "get-path";
- private static final int TIMEOUT_SEC = 10;
- private static final int MAX_GETS = 20;
- private static final int WAIT_SEC = 30;
-
- @Mock
- private HttpClient client;
- @Mock
- private HttpClientFactory factory;
- @Mock
- private Executor executor;
-
- private VfcParams params;
- private VfcConfig config;
-
- /**
- * Setup.
- *
- * @throws Exception Exception
- */
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- when(factory.get(MY_CLIENT)).thenReturn(client);
-
- params = VfcParams.builder().maxGets(MAX_GETS).pathGet(GET_PATH).waitSecGet(WAIT_SEC).clientName(MY_CLIENT)
- .path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
- config = new VfcConfig(executor, params, factory);
- }
-
- @Test
- public void test() {
- assertEquals(GET_PATH + "/", config.getPathGet());
- assertEquals(MAX_GETS, config.getMaxGets());
- assertEquals(WAIT_SEC, config.getWaitSecGet());
-
- // check value from superclass
- assertSame(executor, config.getBlockingExecutor());
- assertSame(client, config.getClient());
-
- // path with trailing "/"
- params = params.toBuilder().pathGet(GET_PATH + "/").build();
- config = new VfcConfig(executor, params, factory);
- assertEquals(GET_PATH + "/", config.getPathGet());
- }
-
-}
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java
index 0b58fd4a3..425ff91b1 100644
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java
+++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java
@@ -20,20 +20,15 @@
package org.onap.policy.controlloop.actor.vfc;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
-import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.vfc.VfcResponse;
import org.onap.policy.vfc.VfcResponseDescriptor;
@@ -55,11 +50,11 @@ public class VfcOperationTest extends BasicVfcOperation {
}
@Test
- public void testConstructor_testGetWaitMsGet() {
+ public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
assertEquals(DEFAULT_OPERATION, oper.getName());
assertSame(config, oper.getConfig());
- assertEquals(1000 * WAIT_SEC_GETS, oper.getWaitMsGet());
+ assertTrue(oper.isUsePolling());
}
@Test
@@ -68,44 +63,9 @@ public class VfcOperationTest extends BasicVfcOperation {
}
@Test
- public void testResetGetCount() {
- oper.resetGetCount();
- assertEquals(0, oper.getGetCount());
- }
-
- @Test
- public void testPostProcess() throws Exception {
-
- assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
- oper.postProcessResponse(outcome, PATH, rawResponse, response);
- });
-
- response.setResponseDescriptor(new VfcResponseDescriptor());
- response.setJobId("sampleJobId");
-
- // null status
- CompletableFuture<OperationOutcome> future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
- assertFalse(future2.isDone());
-
- response.getResponseDescriptor().setStatus("FinisHeD");
- future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
- assertTrue(future2.isDone());
- assertSame(outcome, future2.get());
- assertEquals(PolicyResult.SUCCESS, outcome.getResult());
- assertSame(response, outcome.getResponse());
-
- // failed
- response.getResponseDescriptor().setStatus("eRRor");
- future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
- assertTrue(future2.isDone());
- assertSame(outcome, future2.get());
- assertEquals(PolicyResult.FAILURE, outcome.getResult());
- assertSame(response, outcome.getResponse());
-
- // unfinished
- response.getResponseDescriptor().setStatus("anything but finished");
- future2 = oper.postProcessResponse(outcome, PATH, rawResponse, response);
- assertFalse(future2.isDone());
+ public void testResetPollCount() {
+ oper.resetPollCount();
+ assertEquals(0, oper.getPollCount());
}
@Test
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperatorTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperatorTest.java
deleted file mode 100644
index d469d5a74..000000000
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperatorTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*-
- * ============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.actor.vfc;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.onap.policy.common.endpoints.http.client.HttpClient;
-import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-
-public class VfcOperatorTest {
- private static final String ACTOR = "my-actor";
- private static final String OPERATION = "my-name";
- private static final String CLIENT = "my-client";
- private static final String PATH = "/my-path";
- private static final String PATH_GET = "my-path-get/";
- private static final int MAX_GETS = 3;
- private static final int WAIT_SEC_GETS = 20;
- private static final int TIMEOUT = 100;
-
- private VfcOperator oper;
-
- @Mock
- private HttpClient client;
-
- @Mock
- private HttpClientFactory factory;
-
- /**
- * setUp.
- *
- * @throws Exception exception
- */
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- when(factory.get(CLIENT)).thenReturn(client);
-
- oper = new MyOperator();
-
- VfcParams params = VfcParams.builder().pathGet(PATH_GET).maxGets(MAX_GETS).waitSecGet(WAIT_SEC_GETS)
- .clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
- Map<String, Object> paramMap = Util.translateToMap(OPERATION, params);
- oper.configure(paramMap);
- }
-
- @Test
- public void testConstructor() {
- assertEquals(ACTOR, oper.getActorName());
- assertEquals(OPERATION, oper.getName());
- assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
- }
-
- @Test
- public void testDoConfigure_testGetters() {
- assertTrue(oper.getCurrentConfig() instanceof VfcConfig);
-
- // test invalid parameters
- Map<String, Object> paramMap2 = Util.translateToMap(OPERATION, VfcParams.builder().build());
- assertThatThrownBy(() -> oper.configure(paramMap2)).isInstanceOf(ParameterValidationRuntimeException.class);
- }
-
- private class MyOperator extends VfcOperator {
-
- public MyOperator() {
- super(ACTOR, OPERATION, null);
- }
-
- @Override
- protected HttpClientFactory getClientFactory() {
- return factory;
- }
- }
-}
diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcParamsTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcParamsTest.java
deleted file mode 100644
index 5e324463f..000000000
--- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcParamsTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * ============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.actor.vfc;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actor.vfc.VfcParams.VfcParamsBuilder;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams.HttpParamsBuilder;
-
-public class VfcParamsTest {
- private static final String CONTAINER = "my-container";
- private static final String CLIENT = "my-client";
- private static final String PATH = "my-path";
- private static final String PATH_GET = "my-path-get";
- private static final int MAX_GETS = 3;
- private static final int WAIT_SEC_GETS = 20;
- private static final int TIMEOUT = 10;
-
- private VfcParams params;
-
- @Before
- public void setUp() throws Exception {
- params = VfcParams.builder().pathGet(PATH_GET).maxGets(MAX_GETS).waitSecGet(WAIT_SEC_GETS).clientName(CLIENT)
- .path(PATH).timeoutSec(TIMEOUT).build();
- }
-
- @Test
- public void testValidate() {
- assertTrue(params.validate(CONTAINER).isValid());
-
- testValidateField("pathGet", "null", bldr -> bldr.pathGet(null));
- testValidateField("maxGets", "minimum", bldr -> bldr.maxGets(-1));
- testValidateField("waitSecGet", "minimum", bldr -> bldr.waitSecGet(-1));
-
- // validate one of the superclass fields
- testValidateField("clientName", "null", bldr -> bldr.clientName(null));
-
- // check edge cases
- assertTrue(params.toBuilder().maxGets(0).build().validate(CONTAINER).isValid());
- assertFalse(params.toBuilder().waitSecGet(0).build().validate(CONTAINER).isValid());
- assertTrue(params.toBuilder().waitSecGet(1).build().validate(CONTAINER).isValid());
- }
-
- @Test
- public void testBuilder_testToBuilder() {
- assertEquals(CLIENT, params.getClientName());
-
- assertEquals(PATH_GET, params.getPathGet());
- assertEquals(MAX_GETS, params.getMaxGets());
- assertEquals(WAIT_SEC_GETS, params.getWaitSecGet());
-
- assertEquals(params, params.toBuilder().build());
- }
-
- private void testValidateField(String fieldName, String expected,
- @SuppressWarnings("rawtypes") Function<VfcParamsBuilder, HttpParamsBuilder> makeInvalid) {
-
- // original params should be valid
- ValidationResult result = params.validate(CONTAINER);
- assertTrue(fieldName, result.isValid());
-
- // make invalid params
- result = makeInvalid.apply(params.toBuilder()).build().validate(CONTAINER);
- assertFalse(fieldName, result.isValid());
- assertThat(result.getResult()).contains(fieldName).contains(expected);
- }
-
-}
diff --git a/models-interactions/model-actors/actor.vfc/src/test/resources/service.yaml b/models-interactions/model-actors/actor.vfc/src/test/resources/service.yaml
new file mode 100644
index 000000000..04d9e4639
--- /dev/null
+++ b/models-interactions/model-actors/actor.vfc/src/test/resources/service.yaml
@@ -0,0 +1,35 @@
+#
+# ============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========================================================
+#
+httpClients:
+- clientName: my-client
+ hostname: localhost
+ port: 80
+ basePath: base-url/
+ managed: true
+actors:
+ VFC:
+ clientName: my-client
+ pollPath: jobs
+ pollWaitSec: 20
+ maxPolls: 20
+ operations:
+ Restart:
+ path: ns
+ timeoutSec: 60
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java
index 6113f9391..c3c815e80 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImpl.java
@@ -29,6 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.actorserviceprovider.Util;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.slf4j.Logger;
@@ -156,7 +157,8 @@ public class ActorImpl extends StartConfigPartial<Map<String, Object>> implement
/**
* Extracts the operator parameters from the actor parameters, for a given operator.
- * This method assumes each operation has its own set of parameters.
+ * This method translates the parameters to an {@link ActorParams} and then creates a function
+ * that will extract operator-specific parameters.
*
* @param actorParameters actor parameters
* @return a function to extract the operator parameters from the actor parameters.
@@ -164,8 +166,13 @@ public class ActorImpl extends StartConfigPartial<Map<String, Object>> implement
* the given operation name
*/
protected Function<String, Map<String, Object>> makeOperatorParameters(Map<String, Object> actorParameters) {
+ String actorName = getName();
- return operName -> Util.translateToMap(getName() + "." + operName, actorParameters.get(operName));
+ // @formatter:off
+ return Util.translate(actorName, actorParameters, ActorParams.class)
+ .doValidation(actorName)
+ .makeOperationParameters(actorName);
+ // @formatter:on
}
/**
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperator.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperator.java
index 43c8b8872..0745c3aba 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperator.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperator.java
@@ -23,14 +23,10 @@ package org.onap.policy.controlloop.actorserviceprovider.impl;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
-import lombok.Getter;
import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicHandler;
import org.onap.policy.controlloop.actorserviceprovider.topic.BidirectionalTopicManager;
@@ -40,13 +36,8 @@ import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey;
* Operator that uses a bidirectional topic. Topic operators may share a
* {@link BidirectionalTopicHandler}.
*/
-public class BidirectionalTopicOperator extends OperatorPartial {
-
- /**
- * Function to make an operation.
- */
- @SuppressWarnings("rawtypes")
- private final OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation> operationMaker;
+public class BidirectionalTopicOperator
+ extends TypedOperator<BidirectionalTopicConfig, BidirectionalTopicOperation<?, ?>> {
/**
* Manager from which to get the topic handlers.
@@ -58,12 +49,6 @@ public class BidirectionalTopicOperator extends OperatorPartial {
*/
private final List<SelectorKey> selectorKeys;
- /**
- * Current configuration. This is set by {@link #doConfigure(Map)}.
- */
- @Getter
- private BidirectionalTopicConfig currentConfig;
-
/**
* Constructs the object.
@@ -88,17 +73,13 @@ public class BidirectionalTopicOperator extends OperatorPartial {
* @param selectorKeys keys used to extract the fields used to select responses for
* this operator
*/
- // @formatter:off
public BidirectionalTopicOperator(String actorName, String name, BidirectionalTopicManager topicManager,
List<SelectorKey> selectorKeys,
- @SuppressWarnings("rawtypes") OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation>
- operationMaker) {
- // @formatter:on
+ OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation<?, ?>> operationMaker) {
- super(actorName, name);
+ super(actorName, name, operationMaker);
this.topicManager = topicManager;
this.selectorKeys = selectorKeys;
- this.operationMaker = operationMaker;
}
/**
@@ -110,25 +91,13 @@ public class BidirectionalTopicOperator extends OperatorPartial {
* @param selectorKeys keys used to extract the fields used to select responses for
* this operator
*/
- // @formatter:off
public BidirectionalTopicOperator(String actorName, String name, BidirectionalTopicManager topicManager,
- @SuppressWarnings("rawtypes") OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation>
- operationMaker,
+ OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation<?, ?>> operationMaker,
SelectorKey... selectorKeys) {
- // @formatter:on
this(actorName, name, topicManager, Arrays.asList(selectorKeys), operationMaker);
}
/**
- * Translates the parameters to an {@link HttpParams} and then extracts the relevant
- * values.
- */
- @Override
- protected void doConfigure(Map<String, Object> parameters) {
- currentConfig = makeConfiguration(parameters);
- }
-
- /**
* Makes a new configuration using the specified parameters.
*
* @param parameters operator parameters
@@ -143,15 +112,4 @@ public class BidirectionalTopicOperator extends OperatorPartial {
return new BidirectionalTopicConfig(getBlockingExecutor(), params, topicManager, selectorKeys);
}
-
- @Override
- public Operation buildOperation(ControlLoopOperationParams params) {
- if (operationMaker == null) {
- throw new UnsupportedOperationException("cannot make operation for " + getFullName());
- }
-
- verifyRunning();
-
- return operationMaker.apply(params, currentConfig);
- }
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActor.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActor.java
index eb5662f23..5a6081611 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActor.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpActor.java
@@ -34,7 +34,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorPara
public class HttpActor<P extends HttpActorParams> extends ActorImpl {
/**
- * Class of parameters.
+ * Class of Actor parameters.
*/
private final Class<P> paramsClass;
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 fb6d38292..4800b3a4b 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
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.core.Response;
@@ -38,6 +39,7 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.slf4j.Logger;
@@ -53,6 +55,13 @@ public abstract class HttpOperation<T> extends OperationPartial {
private static final Logger logger = LoggerFactory.getLogger(HttpOperation.class);
/**
+ * Response status.
+ */
+ public enum Status {
+ SUCCESS, FAILURE, STILL_WAITING
+ }
+
+ /**
* Configuration for this operation.
*/
private final HttpConfig config;
@@ -62,6 +71,18 @@ public abstract class HttpOperation<T> extends OperationPartial {
*/
private final Class<T> responseClass;
+ /**
+ * {@code True} to use polling, {@code false} otherwise.
+ */
+ @Getter
+ private boolean usePolling;
+
+ /**
+ * Number of polls issued so far, on the current operation attempt.
+ */
+ @Getter
+ private int pollCount;
+
/**
* Constructs the object.
@@ -76,6 +97,17 @@ public abstract class HttpOperation<T> extends OperationPartial {
this.responseClass = clazz;
}
+ /**
+ * Indicates that polling should be used.
+ */
+ protected void setUsePolling() {
+ if (!(config instanceof HttpPollingConfig)) {
+ throw new IllegalStateException("cannot poll without polling parameters");
+ }
+
+ usePolling = true;
+ }
+
public HttpClient getClient() {
return config.getClient();
}
@@ -123,6 +155,17 @@ public abstract class HttpOperation<T> extends OperationPartial {
}
/**
+ * Resets the polling count
+ *
+ * <p/>
+ * Note: This should be invoked at the start of each operation (i.e., in
+ * {@link #startOperationAsync(int, OperationOutcome)}.
+ */
+ protected void resetPollCount() {
+ pollCount = 0;
+ }
+
+ /**
* Arranges to handle a response.
*
* @param outcome outcome to be populate
@@ -234,7 +277,88 @@ public abstract class HttpOperation<T> extends OperationPartial {
protected CompletableFuture<OperationOutcome> postProcessResponse(OperationOutcome outcome, String url,
Response rawResponse, T response) {
- return CompletableFuture.completedFuture(outcome);
+ if (!usePolling) {
+ // doesn't use polling - just return the completed future
+ return CompletableFuture.completedFuture(outcome);
+ }
+
+ HttpPollingConfig cfg = (HttpPollingConfig) config;
+
+ switch (detmStatus(rawResponse, response)) {
+ case SUCCESS:
+ logger.info("{}.{} request succeeded for {}", params.getActor(), params.getOperation(),
+ params.getRequestId());
+ return CompletableFuture
+ .completedFuture(setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response));
+
+ case FAILURE:
+ logger.info("{}.{} request failed for {}", params.getActor(), params.getOperation(),
+ params.getRequestId());
+ return CompletableFuture
+ .completedFuture(setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response));
+
+ case STILL_WAITING:
+ default:
+ logger.info("{}.{} request incomplete for {}", params.getActor(), params.getOperation(),
+ params.getRequestId());
+ break;
+ }
+
+ // still incomplete
+
+ // see if the limit for the number of polls has been reached
+ if (pollCount++ >= cfg.getMaxPolls()) {
+ logger.warn("{}: execeeded 'poll' limit {} for {}", getFullName(), cfg.getMaxPolls(),
+ params.getRequestId());
+ setOutcome(outcome, PolicyResult.FAILURE_TIMEOUT);
+ return CompletableFuture.completedFuture(outcome);
+ }
+
+ // sleep and then poll
+ Function<Void, CompletableFuture<OperationOutcome>> doPoll = unused -> issuePoll(outcome);
+ return sleep(getPollWaitMs(), TimeUnit.MILLISECONDS).thenComposeAsync(doPoll);
+ }
+
+ /**
+ * Polls to see if the original request is complete. This method polls using an HTTP
+ * "get" request whose URL is constructed by appending the extracted "poll ID" to the
+ * poll path from the configuration data.
+ *
+ * @param outcome outcome to be populated with the response
+ * @return a future that can be used to cancel the poll or await its response
+ */
+ protected CompletableFuture<OperationOutcome> issuePoll(OperationOutcome outcome) {
+ String path = getPollingPath();
+ String url = getClient().getBaseUrl() + path;
+
+ logger.debug("{}: 'poll' count {} for {}", getFullName(), pollCount, params.getRequestId());
+
+ logMessage(EventType.OUT, CommInfrastructure.REST, url, null);
+
+ return handleResponse(outcome, url, callback -> getClient().get(callback, path, null));
+ }
+
+ /**
+ * Determines the status of the response. This particular method simply throws an
+ * exception.
+ *
+ * @param rawResponse raw response
+ * @param response decoded response
+ * @return the status of the response
+ */
+ protected Status detmStatus(Response rawResponse, T response) {
+ throw new UnsupportedOperationException("cannot determine response status");
+ }
+
+ /**
+ * Gets the URL to use when polling. Typically, this is some unique ID appended to the
+ * polling path found within the configuration data. This particular method simply
+ * returns the polling path from the configuration data.
+ *
+ * @return the URL to use when polling
+ */
+ protected String getPollingPath() {
+ return ((HttpPollingConfig) config).getPollPath();
}
/**
@@ -255,4 +379,12 @@ public abstract class HttpOperation<T> extends OperationPartial {
NetLoggerUtil.log(direction, infra, sink, json);
return json;
}
+
+ // these may be overridden by junit tests
+
+ protected long getPollWaitMs() {
+ HttpPollingConfig cfg = (HttpPollingConfig) config;
+
+ return TimeUnit.MILLISECONDS.convert(cfg.getPollWaitSec(), TimeUnit.SECONDS);
+ }
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperator.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperator.java
index 9e446a7c8..f731a2c84 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperator.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperator.java
@@ -21,13 +21,10 @@
package org.onap.policy.controlloop.actorserviceprovider.impl;
import java.util.Map;
-import lombok.Getter;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
@@ -35,20 +32,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterVali
/**
* Operator that uses HTTP. The operator's parameters must be an {@link HttpParams}.
*/
-public class HttpOperator extends OperatorPartial {
-
- /**
- * Function to make an operation.
- */
- @SuppressWarnings("rawtypes")
- private final OperationMaker<HttpConfig, HttpOperation> operationMaker;
-
- /**
- * Current configuration. This is set by {@link #doConfigure(Map)}.
- */
- @Getter
- private HttpConfig currentConfig;
-
+public class HttpOperator extends TypedOperator<HttpConfig,HttpOperation<?>> {
/**
* Constructs the object.
@@ -68,18 +52,8 @@ public class HttpOperator extends OperatorPartial {
* @param operationMaker function to make an operation
*/
public HttpOperator(String actorName, String name,
- @SuppressWarnings("rawtypes") OperationMaker<HttpConfig, HttpOperation> operationMaker) {
- super(actorName, name);
- this.operationMaker = operationMaker;
- }
-
- /**
- * Translates the parameters to an {@link HttpParams} and then extracts the relevant
- * values.
- */
- @Override
- protected void doConfigure(Map<String, Object> parameters) {
- currentConfig = makeConfiguration(parameters);
+ OperationMaker<HttpConfig, HttpOperation<?>> operationMaker) {
+ super(actorName, name, operationMaker);
}
/**
@@ -98,17 +72,6 @@ public class HttpOperator extends OperatorPartial {
return new HttpConfig(getBlockingExecutor(), params, getClientFactory());
}
- @Override
- public Operation buildOperation(ControlLoopOperationParams params) {
- if (operationMaker == null) {
- throw new UnsupportedOperationException("cannot make operation for " + getFullName());
- }
-
- verifyRunning();
-
- return operationMaker.apply(params, currentConfig);
- }
-
// these may be overridden by junit tests
protected HttpClientFactory getClientFactory() {
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperator.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperator.java
new file mode 100644
index 000000000..9e681ceeb
--- /dev/null
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperator.java
@@ -0,0 +1,81 @@
+/*-
+ * ============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.impl;
+
+import java.util.Map;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
+import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.controlloop.actorserviceprovider.Util;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
+
+/**
+ * Operator that uses HTTP and polls for the request completion status. The operator's
+ * parameters must be an {@link HttpPollingParams}.
+ */
+public class HttpPollingOperator extends TypedOperator<HttpPollingConfig, HttpOperation<?>> {
+
+ /**
+ * Constructs the object.
+ *
+ * @param actorName name of the actor with which this operator is associated
+ * @param name operation name
+ */
+ protected HttpPollingOperator(String actorName, String name) {
+ this(actorName, name, null);
+ }
+
+ /**
+ * Constructs the object.
+ *
+ * @param actorName name of the actor with which this operator is associated
+ * @param name operation name
+ * @param operationMaker function to make an operation
+ */
+ public HttpPollingOperator(String actorName, String name,
+ OperationMaker<HttpPollingConfig, HttpOperation<?>> operationMaker) {
+ super(actorName, name, operationMaker);
+ }
+
+ /**
+ * Makes a new configuration using the specified parameters.
+ *
+ * @param parameters operator parameters
+ * @return a new configuration
+ */
+ protected HttpPollingConfig makeConfiguration(Map<String, Object> parameters) {
+ HttpPollingParams params = Util.translate(getFullName(), parameters, HttpPollingParams.class);
+ ValidationResult result = params.validate(getFullName());
+ if (!result.isValid()) {
+ throw new ParameterValidationRuntimeException("invalid parameters", result);
+ }
+
+ return new HttpPollingConfig(getBlockingExecutor(), params, getClientFactory());
+ }
+
+ // these may be overridden by junit tests
+
+ protected HttpClientFactory getClientFactory() {
+ return HttpClientFactoryInstance.getClientFactory();
+ }
+}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
new file mode 100644
index 000000000..5561a97ef
--- /dev/null
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/TypedOperator.java
@@ -0,0 +1,97 @@
+/*-
+ * ============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.impl;
+
+import java.util.Map;
+import lombok.Getter;
+import org.onap.policy.controlloop.actorserviceprovider.Operation;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
+
+/**
+ * Operator with typed parameter information.
+ *
+ * @param <C> type of configuration data
+ * @param <T> type of operation that the operator creates
+ */
+public abstract class TypedOperator<C, T extends Operation> extends OperatorPartial {
+
+ /**
+ * Function to make an operation.
+ */
+ private final OperationMaker<C, T> operationMaker;
+
+ /**
+ * Current configuration. This is set by {@link #doConfigure(Map)}.
+ */
+ @Getter
+ private C currentConfig;
+
+
+ /**
+ * Constructs the object.
+ *
+ * @param actorName name of the actor with which this operator is associated
+ * @param name operation name
+ */
+ protected TypedOperator(String actorName, String name) {
+ this(actorName, name, null);
+ }
+
+ /**
+ * Constructs the object.
+ *
+ * @param actorName name of the actor with which this operator is associated
+ * @param name operation name
+ * @param operationMaker function to make an operation
+ */
+ public TypedOperator(String actorName, String name, OperationMaker<C, T> operationMaker) {
+ super(actorName, name);
+ this.operationMaker = operationMaker;
+ }
+
+ /**
+ * Translates the parameters, saving the relevant configuration data.
+ */
+ @Override
+ protected void doConfigure(Map<String, Object> parameters) {
+ currentConfig = makeConfiguration(parameters);
+ }
+
+ /**
+ * Makes a new configuration using the specified parameters.
+ *
+ * @param parameters operator parameters
+ * @return a new configuration
+ */
+ protected abstract C makeConfiguration(Map<String, Object> parameters);
+
+ @Override
+ public T buildOperation(ControlLoopOperationParams params) {
+ if (operationMaker == null) {
+ throw new UnsupportedOperationException("cannot make operation for " + getFullName());
+ }
+
+ verifyRunning();
+
+ return operationMaker.apply(params, currentConfig);
+ }
+}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/CommonActorParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParams.java
index b8218e53b..948677fa4 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/CommonActorParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParams.java
@@ -38,7 +38,7 @@ import org.onap.policy.controlloop.actorserviceprovider.Util;
@Getter
@Setter
@EqualsAndHashCode
-public class CommonActorParams {
+public class ActorParams {
/**
* Name of the "operations" field contained within actor parameters.
*/
@@ -84,7 +84,7 @@ public class CommonActorParams {
* @return "this"
* @throws IllegalArgumentException if the parameters are invalid
*/
- public CommonActorParams doValidation(String name) {
+ public ActorParams doValidation(String name) {
ValidationResult result = validate(name);
if (!result.isValid()) {
throw new ParameterValidationRuntimeException("invalid parameters", result);
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParams.java
index 291aeeb23..3e65e4729 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParams.java
@@ -31,7 +31,7 @@ import org.onap.policy.common.parameters.annotations.Min;
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
-public class BidirectionalTopicActorParams extends CommonActorParams {
+public class BidirectionalTopicActorParams extends ActorParams {
/*
* Optional, default values that are used if missing from the operation-specific
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParams.java
index d589e1d7e..616f674c5 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParams.java
@@ -31,7 +31,7 @@ import org.onap.policy.common.parameters.annotations.Min;
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
-public class HttpActorParams extends CommonActorParams {
+public class HttpActorParams extends ActorParams {
/*
* Optional, default values that are used if missing from the operation-specific
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParams.java
index 3e82fe1a6..3343c5b3c 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParams.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.controlloop.actor.so;
+package org.onap.policy.controlloop.actorserviceprovider.parameters;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -26,10 +26,14 @@ import lombok.Setter;
import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams;
+/**
+ * Parameters used by Actors that, after issuing an HTTP request, must poll the target
+ * server to determine the request completion status.
+ */
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
-public class SoActorParams extends HttpActorParams {
+public class HttpPollingActorParams extends HttpActorParams {
/*
* Optional, default values that are used if missing from the operation-specific
@@ -37,20 +41,19 @@ public class SoActorParams extends HttpActorParams {
*/
/**
- * Path to use for the "get" request.
+ * Path to use when polling for request completion.
*/
- private String pathGet = "/orchestrationRequests/v5/";
+ private String pollPath;
/**
- * Maximum number of "get" requests permitted, after the initial request, to retrieve
- * the response.
+ * Maximum number of times to poll to retrieve the response.
*/
@Min(0)
- private int maxGets = 20;
+ private int maxPolls = 3;
/**
- * Time, in seconds, to wait between issuing "get" requests.
+ * Time, in seconds, to wait between polling.
*/
@Min(1)
- private int waitSecGet = 20;
+ private int pollWaitSec = 20;
}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfig.java
index 959cd454a..8e0daa07c 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfig.java
@@ -18,32 +18,35 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.controlloop.actor.so;
+package org.onap.policy.controlloop.actorserviceprovider.parameters;
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;
+/**
+ * Configuration for HTTP Operators that, after issuing a request, must poll the target
+ * server to determine the request completion status.
+ */
@Getter
-public class SoConfig extends HttpConfig {
+public class HttpPollingConfig extends HttpConfig {
/**
- * Path to use for the "get" request. A trailing "/" is added, if it is missing.
+ * Path to use when polling for request completion. A trailing "/" is added, if it is
+ * missing.
*/
- private String pathGet;
+ private String pollPath;
/**
- * Maximum number of "get" requests permitted, after the initial request, to retrieve
- * the response.
+ * Maximum number of times to poll to retrieve the response.
*/
- private int maxGets;
+ private int maxPolls;
/**
- * Time, in seconds, to wait between issuing "get" requests.
+ * Time, in seconds, to wait between polling.
*/
- private int waitSecGet;
+ private int pollWaitSec;
/**
@@ -53,11 +56,11 @@ public class SoConfig extends HttpConfig {
* @param params operator parameters
* @param clientFactory factory from which to obtain the {@link HttpClient}
*/
- public SoConfig(Executor blockingExecutor, SoParams params, HttpClientFactory clientFactory) {
+ public HttpPollingConfig(Executor blockingExecutor, HttpPollingParams params, HttpClientFactory clientFactory) {
super(blockingExecutor, params, clientFactory);
- this.pathGet = params.getPathGet() + (params.getPathGet().endsWith("/") ? "" : "/");
- this.maxGets = params.getMaxGets();
- this.waitSecGet = params.getWaitSecGet();
+ this.pollPath = params.getPollPath() + (params.getPollPath().endsWith("/") ? "" : "/");
+ this.maxPolls = params.getMaxPolls();
+ this.pollWaitSec = params.getPollWaitSec();
}
}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParams.java
index 53f6e932f..2f33bd217 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParams.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.controlloop.actor.so;
+package org.onap.policy.controlloop.actorserviceprovider.parameters;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -28,28 +28,31 @@ import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
+/**
+ * Parameters used by Operators that, after issuing an HTTP request, must poll the target
+ * server to determine the request completion status.
+ */
@NotNull
@NotBlank
@Data
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(toBuilder = true)
-public class SoParams extends HttpParams {
+public class HttpPollingParams extends HttpParams {
/**
- * Path to use for the "get" request.
+ * Path to use when polling for request completion.
*/
- private String pathGet;
+ private String pollPath;
/**
- * Maximum number of "get" requests permitted, after the initial request, to retrieve
- * the response.
+ * Maximum number of times to poll to retrieve the response.
*/
@Min(0)
- private int maxGets;
+ private int maxPolls;
/**
- * Time, in seconds, to wait between issuing "get" requests.
+ * Time, in seconds, to wait between polling.
*/
@Min(1)
- private int waitSecGet;
+ private int pollWaitSec;
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
index 0f282f662..97f6bbacf 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
@@ -36,6 +36,7 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
@@ -46,6 +47,7 @@ import org.junit.Test;
import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.controlloop.actorserviceprovider.impl.ActorImpl;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
@@ -80,10 +82,10 @@ public class ActorServiceTest {
actor3 = spy(new ActorImpl(ACTOR3));
actor4 = spy(new ActorImpl(ACTOR4));
- sub1 = Map.of("sub A", "value A");
- sub2 = Map.of("sub B", "value B");
- sub3 = Map.of("sub C", "value C");
- sub4 = Map.of("sub D", "value D");
+ sub1 = Map.of("sub A", "value A", ActorParams.OPERATIONS_FIELD, Collections.emptyMap());
+ sub2 = Map.of("sub B", "value B", ActorParams.OPERATIONS_FIELD, Collections.emptyMap());
+ sub3 = Map.of("sub C", "value C", ActorParams.OPERATIONS_FIELD, Collections.emptyMap());
+ sub4 = Map.of("sub D", "value D", ActorParams.OPERATIONS_FIELD, Collections.emptyMap());
params = Map.of(ACTOR1, sub1, ACTOR2, sub2, ACTOR3, sub3, ACTOR4, sub4);
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
index 681378de4..cf07d3b2b 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
@@ -36,7 +36,6 @@ import static org.mockito.Mockito.when;
import java.util.Iterator;
import java.util.Map;
-import java.util.TreeMap;
import java.util.stream.Collectors;
import org.junit.Before;
import org.junit.Test;
@@ -44,6 +43,7 @@ import org.onap.policy.common.parameters.ObjectValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Operator;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
@@ -84,7 +84,7 @@ public class ActorImplTest {
sub3 = Map.of("sub C", "value C");
sub4 = Map.of("sub D", "value D");
- params = Map.of(OPER1, sub1, OPER2, sub2, OPER3, sub3, OPER4, sub4);
+ params = Map.of(ActorParams.OPERATIONS_FIELD, Map.of(OPER1, sub1, OPER2, sub2, OPER3, sub3, OPER4, sub4));
actor = makeActor(oper1, oper2, oper3, oper4);
}
@@ -285,15 +285,12 @@ public class ActorImplTest {
*/
@Test
public void testDoConfigureConfigure() {
- // need mutable parameters
- params = new TreeMap<>(params);
-
// configure one operator
oper1.configure(sub1);
// configure another and remove its parameters
oper2.configure(sub2);
- params.remove(OPER2);
+ params = Map.of(ActorParams.OPERATIONS_FIELD, Map.of(OPER1, sub1, OPER3, sub3, OPER4, sub4));
// create a new, unconfigured actor
Operator oper5 = spy(new MyOper("UNCONFIGURED"));
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
index b5e3de32c..29f507e60 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
@@ -34,7 +34,6 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams;
@@ -108,8 +107,7 @@ public class BidirectionalTopicOperatorTest {
AtomicReference<BidirectionalTopicConfig> configRef = new AtomicReference<>();
// @formatter:off
- @SuppressWarnings("rawtypes")
- OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation> maker =
+ OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation<?,?>> maker =
(params, config) -> {
paramsRef.set(params);
configRef.set(config);
@@ -152,7 +150,7 @@ public class BidirectionalTopicOperatorTest {
}
@Override
- public Operation buildOperation(ControlLoopOperationParams params) {
+ public BidirectionalTopicOperation<?,?> buildOperation(ControlLoopOperationParams params) {
return null;
}
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java
new file mode 100644
index 000000000..ed5ba9b56
--- /dev/null
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java
@@ -0,0 +1,255 @@
+/*-
+ * ============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.impl;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ForkJoinPool;
+import java.util.concurrent.TimeUnit;
+import javax.ws.rs.client.InvocationCallback;
+import javax.ws.rs.core.Response;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.stubbing.Answer;
+import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
+import org.onap.policy.controlloop.policy.PolicyResult;
+
+/**
+ * Tests HttpOperation when polling is enabled.
+ */
+public class HttpPollingOperationTest {
+ private static final String BASE_URI = "http://my-host:6969/base-uri/";
+ private static final String MY_PATH = "my-path";
+ private static final String FULL_PATH = BASE_URI + MY_PATH;
+ private static final int MAX_POLLS = 3;
+ private static final int POLL_WAIT_SEC = 20;
+ private static final String POLL_PATH = "my-poll-path";
+ private static final String MY_ACTOR = "my-actor";
+ private static final String MY_OPERATION = "my-operation";
+ private static final String MY_RESPONSE = "my-response";
+ private static final int RESPONSE_ACCEPT = 100;
+ private static final int RESPONSE_SUCCESS = 200;
+ private static final int RESPONSE_FAILURE = 500;
+
+ @Mock
+ private HttpPollingConfig config;
+ @Mock
+ private HttpClient client;
+ @Mock
+ private Response rawResponse;
+
+ protected ControlLoopOperationParams params;
+ private String response;
+ private OperationOutcome outcome;
+
+ private HttpOperation<String> oper;
+
+ /**
+ * Sets up.
+ */
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ when(client.getBaseUrl()).thenReturn(BASE_URI);
+
+ when(config.getClient()).thenReturn(client);
+ when(config.getPath()).thenReturn(MY_PATH);
+ when(config.getMaxPolls()).thenReturn(MAX_POLLS);
+ when(config.getPollPath()).thenReturn(POLL_PATH);
+ when(config.getPollWaitSec()).thenReturn(POLL_WAIT_SEC);
+
+ response = MY_RESPONSE;
+
+ when(rawResponse.getStatus()).thenReturn(RESPONSE_SUCCESS);
+ when(rawResponse.readEntity(String.class)).thenReturn(response);
+
+ params = ControlLoopOperationParams.builder().actor(MY_ACTOR).operation(MY_OPERATION).build();
+ outcome = params.makeOutcome();
+
+ oper = new MyOper(params, config);
+ }
+
+ @Test
+ public void testConstructor_testGetWaitMsGet() {
+ assertEquals(MY_ACTOR, oper.getActorName());
+ assertEquals(MY_OPERATION, oper.getName());
+ assertSame(config, oper.getConfig());
+ assertEquals(1000 * POLL_WAIT_SEC, oper.getPollWaitMs());
+ }
+
+ @Test
+ public void testSetUsePollExceptions() {
+ // should be no exception
+ oper.setUsePolling();
+
+ // should throw an exception if we pass a plain HttpConfig
+ HttpConfig config2 = mock(HttpConfig.class);
+ when(config2.getClient()).thenReturn(client);
+ when(config2.getPath()).thenReturn(MY_PATH);
+
+ assertThatIllegalStateException().isThrownBy(() -> new MyOper(params, config2).setUsePolling());
+ }
+
+ @Test
+ public void testPostProcess() throws Exception {
+ // completed
+ oper.generateSubRequestId(2);
+ CompletableFuture<OperationOutcome> future2 =
+ oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response);
+ assertTrue(future2.isDone());
+ assertSame(outcome, future2.get());
+ assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertNotNull(oper.getSubRequestId());
+ assertSame(response, outcome.getResponse());
+
+ // failed
+ oper.generateSubRequestId(2);
+ when(rawResponse.getStatus()).thenReturn(RESPONSE_FAILURE);
+ future2 = oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response);
+ assertTrue(future2.isDone());
+ assertSame(outcome, future2.get());
+ assertEquals(PolicyResult.FAILURE, outcome.getResult());
+ assertNotNull(oper.getSubRequestId());
+ assertSame(response, outcome.getResponse());
+ }
+
+ /**
+ * Tests postProcess() when the poll is repeated a couple of times.
+ */
+ @Test
+ public void testPostProcessRepeated_testResetGetCount() throws Exception {
+ /*
+ * Two accepts and then a success - should result in two polls.
+ */
+ when(rawResponse.getStatus()).thenReturn(RESPONSE_ACCEPT, RESPONSE_ACCEPT, RESPONSE_SUCCESS, RESPONSE_SUCCESS);
+
+ when(client.get(any(), any(), any())).thenAnswer(provideResponse(rawResponse));
+
+ // use a real executor
+ params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
+
+ oper = new MyOper(params, config) {
+ @Override
+ public long getPollWaitMs() {
+ return 1;
+ }
+ };
+
+ CompletableFuture<OperationOutcome> future2 =
+ oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response);
+
+ assertSame(outcome, future2.get(5, TimeUnit.SECONDS));
+ assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ assertEquals(2, oper.getPollCount());
+
+ /*
+ * repeat - this time, the "poll" count will be exhausted, so it should fail
+ */
+ when(rawResponse.getStatus()).thenReturn(RESPONSE_ACCEPT);
+
+ future2 = oper.postProcessResponse(outcome, FULL_PATH, rawResponse, response);
+
+ assertSame(outcome, future2.get(5, TimeUnit.SECONDS));
+ assertEquals(PolicyResult.FAILURE_TIMEOUT, outcome.getResult());
+ assertEquals(MAX_POLLS + 1, oper.getPollCount());
+
+ oper.resetPollCount();
+ assertEquals(0, oper.getPollCount());
+ assertNull(oper.getSubRequestId());
+ }
+
+ @Test
+ public void testDetmStatus() {
+ // make an operation that does NOT override detmStatus()
+ oper = new HttpOperation<String>(params, config, String.class) {};
+
+ assertThatThrownBy(() -> oper.detmStatus(rawResponse, response))
+ .isInstanceOf(UnsupportedOperationException.class);
+ }
+
+ /**
+ * Provides a response to an asynchronous HttpClient call.
+ *
+ * @param response response to be provided to the call
+ * @return a function that provides the response to the call
+ */
+ protected Answer<CompletableFuture<Response>> provideResponse(Response response) {
+ return provideResponse(response, 0);
+ }
+
+ /**
+ * Provides a response to an asynchronous HttpClient call.
+ *
+ * @param response response to be provided to the call
+ * @param index index of the callback within the arguments
+ * @return a function that provides the response to the call
+ */
+ protected Answer<CompletableFuture<Response>> provideResponse(Response response, int index) {
+ return args -> {
+ InvocationCallback<Response> cb = args.getArgument(index);
+ cb.completed(response);
+ return CompletableFuture.completedFuture(response);
+ };
+ }
+
+ private static class MyOper extends HttpOperation<String> {
+
+ public MyOper(ControlLoopOperationParams params, HttpConfig config) {
+ super(params, config, String.class);
+
+ setUsePolling();
+ }
+
+ @Override
+ protected Status detmStatus(Response rawResponse, String response) {
+ switch (rawResponse.getStatus()) {
+ case RESPONSE_ACCEPT:
+ return Status.STILL_WAITING;
+ case RESPONSE_SUCCESS:
+ return Status.SUCCESS;
+ default:
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ protected boolean isSuccess(Response rawResponse, String response) {
+ return true;
+ }
+ }
+}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperatorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java
index 20403237b..2a22b4b86 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperatorTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java
@@ -18,10 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.controlloop.actor.so;
+package org.onap.policy.controlloop.actorserviceprovider.impl;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@@ -33,26 +34,28 @@ import org.mockito.MockitoAnnotations;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.Util;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
-public class SoOperatorTest {
+public class HttpPollingOperatorTest {
private static final String ACTOR = "my-actor";
private static final String OPERATION = "my-name";
private static final String CLIENT = "my-client";
private static final String PATH = "/my-path";
- private static final String PATH_GET = "my-path-get/";
- private static final int MAX_GETS = 3;
- private static final int WAIT_SEC_GETS = 20;
+ private static final String POLL_PATH = "my-path-get/";
+ private static final int MAX_POLLS = 3;
+ private static final int POLL_WAIT_SEC = 20;
private static final int TIMEOUT = 100;
@Mock
private HttpClient client;
-
@Mock
private HttpClientFactory factory;
-
- private SoOperator oper;
+ private HttpPollingOperator oper;
/**
* Initializes fields, including {@link #oper}, and resets the static fields used by
@@ -66,8 +69,8 @@ public class SoOperatorTest {
oper = new MyOperator();
- SoParams params = SoParams.builder().pathGet(PATH_GET).maxGets(MAX_GETS).waitSecGet(WAIT_SEC_GETS)
- .clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
+ HttpPollingParams params = HttpPollingParams.builder().pollPath(POLL_PATH).maxPolls(MAX_POLLS)
+ .pollWaitSec(POLL_WAIT_SEC).clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
Map<String, Object> paramMap = Util.translateToMap(OPERATION, params);
oper.configure(paramMap);
}
@@ -81,17 +84,23 @@ public class SoOperatorTest {
@Test
public void testDoConfigure_testGetters() {
- assertTrue(oper.getCurrentConfig() instanceof SoConfig);
+ assertTrue(oper.getCurrentConfig() instanceof HttpPollingConfig);
// test invalid parameters
- Map<String, Object> paramMap2 = Util.translateToMap(OPERATION, SoParams.builder().build());
+ Map<String, Object> paramMap2 = Util.translateToMap(OPERATION, HttpPollingParams.builder().build());
assertThatThrownBy(() -> oper.configure(paramMap2)).isInstanceOf(ParameterValidationRuntimeException.class);
}
+ @Test
+ public void testGetClientFactory() {
+ HttpPollingOperator oper2 = new HttpPollingOperator(ACTOR, OPERATION);
+ assertNotNull(oper2.getClientFactory());
+ }
+
- private class MyOperator extends SoOperator {
+ private class MyOperator extends HttpPollingOperator {
public MyOperator() {
- super(ACTOR, OPERATION, null);
+ super(ACTOR, OPERATION, MyOperation::new);
}
@Override
@@ -99,4 +108,10 @@ public class SoOperatorTest {
return factory;
}
}
+
+ private static class MyOperation extends HttpOperation<String> {
+ public MyOperation(ControlLoopOperationParams params, HttpConfig config) {
+ super(params, config, String.class);
+ }
+ }
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/CommonActorParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParamsTest.java
index 99b441064..0304ef3be 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/CommonActorParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ActorParamsTest.java
@@ -39,7 +39,7 @@ import org.junit.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-public class CommonActorParamsTest {
+public class ActorParamsTest {
private static final String CONTAINER = "my-container";
@@ -52,7 +52,7 @@ public class CommonActorParamsTest {
private static final String TEXT2B = "bye";
private Map<String, Map<String, Object>> operations;
- private CommonActorParams params;
+ private ActorParams params;
/**
* Initializes {@link #operations} with two items and {@link params} with a fully
@@ -64,7 +64,7 @@ public class CommonActorParamsTest {
operations.put(PATH1, Map.of("path", URI1));
operations.put(PATH2, Map.of("path", URI2, "text2", TEXT2B));
- params = makeCommonActorParams();
+ params = makeActorParams();
}
@Test
@@ -96,29 +96,29 @@ public class CommonActorParamsTest {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
- CommonActorParams sparse = Util.translate(CONTAINER,
- Map.of(CommonActorParams.OPERATIONS_FIELD, operations, "timeoutSec", 1),
- CommonActorParams.class);
+ ActorParams sparse = Util.translate(CONTAINER,
+ Map.of(ActorParams.OPERATIONS_FIELD, operations, "timeoutSec", 1),
+ ActorParams.class);
assertTrue(sparse.validate(CONTAINER).isValid());
- testValidateField(CommonActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
+ testValidateField(ActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
}
- private void testValidateField(String fieldName, String expected, Consumer<CommonActorParams> makeInvalid) {
+ private void testValidateField(String fieldName, String expected, Consumer<ActorParams> makeInvalid) {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
assertTrue(fieldName, result.isValid());
// make invalid params
- CommonActorParams params2 = makeCommonActorParams();
+ ActorParams params2 = makeActorParams();
makeInvalid.accept(params2);
result = params2.validate(CONTAINER);
assertFalse(fieldName, result.isValid());
assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
}
- private CommonActorParams makeCommonActorParams() {
+ private ActorParams makeActorParams() {
MyParams params2 = new MyParams();
params2.setOperations(operations);
params2.setText1(TEXT1);
@@ -128,7 +128,7 @@ public class CommonActorParamsTest {
}
@Setter
- public static class MyParams extends CommonActorParams {
+ public static class MyParams extends ActorParams {
@SuppressWarnings("unused")
private String text1;
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java
index 1276950a5..769e0fca5 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicActorParamsTest.java
@@ -77,11 +77,11 @@ public class BidirectionalTopicActorParamsTest {
// only a few fields are required
BidirectionalTopicActorParams sparse =
- Util.translate(CONTAINER, Map.of(CommonActorParams.OPERATIONS_FIELD, operMap, "timeoutSec", 1),
+ Util.translate(CONTAINER, Map.of(ActorParams.OPERATIONS_FIELD, operMap, "timeoutSec", 1),
BidirectionalTopicActorParams.class);
assertTrue(sparse.validate(CONTAINER).isValid());
- testValidateField(CommonActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
+ testValidateField(ActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
testValidateField("timeoutSec", "minimum", params2 -> params2.setTimeoutSec(-1));
// check edge cases
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java
index 99bf63305..5812b0437 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpActorParamsTest.java
@@ -65,10 +65,10 @@ public class HttpActorParamsTest {
// only a few fields are required
HttpActorParams sparse = Util.translate(CONTAINER,
- Map.of(CommonActorParams.OPERATIONS_FIELD, operations, "timeoutSec", 1), HttpActorParams.class);
+ Map.of(ActorParams.OPERATIONS_FIELD, operations, "timeoutSec", 1), HttpActorParams.class);
assertTrue(sparse.validate(CONTAINER).isValid());
- testValidateField(CommonActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
+ testValidateField(ActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
testValidateField("timeoutSec", "minimum", params2 -> params2.setTimeoutSec(-1));
// check edge cases
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParamsTest.java
index 5fb647253..78240beb6 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingActorParamsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.controlloop.actor.so;
+package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
@@ -31,15 +31,15 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Util;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.CommonActorParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
-public class SoActorParamsTest {
+public class HttpPollingActorParamsTest {
private static final String CONTAINER = "my-container";
private static final String CLIENT = "my-client";
- private static final String PATH_GET = "my-path-get";
- private static final int MAX_GETS = 3;
- private static final int WAIT_SEC_GETS = 20;
+ private static final String POLL_PATH = "my-poll-path";
+ private static final int MAX_POLLS = 3;
+ private static final int POLL_WAIT_SEC = 20;
private static final int TIMEOUT = 10;
private static final String PATH1 = "path #1";
@@ -48,7 +48,7 @@ public class SoActorParamsTest {
private static final String URI2 = "uri #2";
private Map<String, Map<String, Object>> operations;
- private SoActorParams params;
+ private HttpPollingActorParams params;
/**
* Initializes {@link #operations} with two items and {@link params} with a fully
@@ -60,7 +60,7 @@ public class SoActorParamsTest {
operations.put(PATH1, Map.of("path", URI1));
operations.put(PATH2, Map.of("path", URI2));
- params = makeSoActorParams();
+ params = makeHttpPollingActorParams();
}
@Test
@@ -68,50 +68,50 @@ public class SoActorParamsTest {
assertTrue(params.validate(CONTAINER).isValid());
// only a few fields are required
- SoActorParams sparse = Util.translate(CONTAINER, Map.of(CommonActorParams.OPERATIONS_FIELD, operations),
- SoActorParams.class);
+ HttpPollingActorParams sparse = Util.translate(CONTAINER, Map.of(ActorParams.OPERATIONS_FIELD, operations),
+ HttpPollingActorParams.class);
assertTrue(sparse.validate(CONTAINER).isValid());
- testValidateField("maxGets", "minimum", params2 -> params2.setMaxGets(-1));
- testValidateField("waitSecGet", "minimum", params2 -> params2.setWaitSecGet(0));
+ testValidateField("maxPolls", "minimum", params2 -> params2.setMaxPolls(-1));
+ testValidateField("pollWaitSec", "minimum", params2 -> params2.setPollWaitSec(0));
// check fields from superclass
- testValidateField(CommonActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
+ testValidateField(ActorParams.OPERATIONS_FIELD, "null", params2 -> params2.setOperations(null));
testValidateField("timeoutSec", "minimum", params2 -> params2.setTimeoutSec(-1));
// check edge cases
- params.setMaxGets(0);
+ params.setMaxPolls(0);
assertTrue(params.validate(CONTAINER).isValid());
- params.setMaxGets(MAX_GETS);
+ params.setMaxPolls(MAX_POLLS);
- params.setWaitSecGet(1);
+ params.setPollWaitSec(1);
assertTrue(params.validate(CONTAINER).isValid());
- params.setWaitSecGet(WAIT_SEC_GETS);
+ params.setPollWaitSec(POLL_WAIT_SEC);
}
- private void testValidateField(String fieldName, String expected, Consumer<SoActorParams> makeInvalid) {
+ private void testValidateField(String fieldName, String expected, Consumer<HttpPollingActorParams> makeInvalid) {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
assertTrue(fieldName, result.isValid());
// make invalid params
- SoActorParams params2 = makeSoActorParams();
+ HttpPollingActorParams params2 = makeHttpPollingActorParams();
makeInvalid.accept(params2);
result = params2.validate(CONTAINER);
assertFalse(fieldName, result.isValid());
assertThat(result.getResult()).contains(CONTAINER).contains(fieldName).contains(expected);
}
- private SoActorParams makeSoActorParams() {
- SoActorParams params2 = new SoActorParams();
+ private HttpPollingActorParams makeHttpPollingActorParams() {
+ HttpPollingActorParams params2 = new HttpPollingActorParams();
params2.setClientName(CLIENT);
params2.setTimeoutSec(TIMEOUT);
params2.setOperations(operations);
- params2.setWaitSecGet(WAIT_SEC_GETS);
- params2.setMaxGets(MAX_GETS);
- params2.setPathGet(PATH_GET);
+ params2.setPollWaitSec(POLL_WAIT_SEC);
+ params2.setMaxPolls(MAX_POLLS);
+ params2.setPollPath(POLL_PATH);
return params2;
}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoConfigTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.java
index 17fd9c9de..53be6c711 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoConfigTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingConfigTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.controlloop.actor.so;
+package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
@@ -32,12 +32,12 @@ import org.mockito.MockitoAnnotations;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
-public class SoConfigTest {
+public class HttpPollingConfigTest {
private static final String MY_CLIENT = "my-client";
private static final String MY_PATH = "my-path";
- private static final String GET_PATH = "get-path";
+ private static final String POLL_PATH = "poll-path";
private static final int TIMEOUT_SEC = 10;
- private static final int MAX_GETS = 20;
+ private static final int MAX_POLLS = 20;
private static final int WAIT_SEC = 30;
@Mock
@@ -47,8 +47,8 @@ public class SoConfigTest {
@Mock
private Executor executor;
- private SoParams params;
- private SoConfig config;
+ private HttpPollingParams params;
+ private HttpPollingConfig config;
/**
* Sets up.
@@ -59,24 +59,24 @@ public class SoConfigTest {
when(factory.get(MY_CLIENT)).thenReturn(client);
- params = SoParams.builder().maxGets(MAX_GETS).pathGet(GET_PATH).waitSecGet(WAIT_SEC).clientName(MY_CLIENT)
- .path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
- config = new SoConfig(executor, params, factory);
+ params = HttpPollingParams.builder().maxPolls(MAX_POLLS).pollPath(POLL_PATH).pollWaitSec(WAIT_SEC)
+ .clientName(MY_CLIENT).path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
+ config = new HttpPollingConfig(executor, params, factory);
}
@Test
public void test() {
- assertEquals(GET_PATH + "/", config.getPathGet());
- assertEquals(MAX_GETS, config.getMaxGets());
- assertEquals(WAIT_SEC, config.getWaitSecGet());
+ assertEquals(POLL_PATH + "/", config.getPollPath());
+ assertEquals(MAX_POLLS, config.getMaxPolls());
+ assertEquals(WAIT_SEC, config.getPollWaitSec());
// check value from superclass
assertSame(executor, config.getBlockingExecutor());
assertSame(client, config.getClient());
// path with trailing "/"
- params = params.toBuilder().pathGet(GET_PATH + "/").build();
- config = new SoConfig(executor, params, factory);
- assertEquals(GET_PATH + "/", config.getPathGet());
+ params = params.toBuilder().pollPath(POLL_PATH + "/").build();
+ config = new HttpPollingConfig(executor, params, factory);
+ assertEquals(POLL_PATH + "/", config.getPollPath());
}
}
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParamsTest.java
index 2b02ad8ff..e3fef83c5 100644
--- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpPollingParamsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.controlloop.actor.so;
+package org.onap.policy.controlloop.actorserviceprovider.parameters;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
@@ -29,56 +29,55 @@ import java.util.function.Function;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.parameters.ValidationResult;
-import org.onap.policy.controlloop.actor.so.SoParams.SoParamsBuilder;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams.HttpParamsBuilder;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams.HttpPollingParamsBuilder;
-public class SoParamsTest {
+public class HttpPollingParamsTest {
private static final String CONTAINER = "my-container";
private static final String CLIENT = "my-client";
private static final String PATH = "my-path";
- private static final String PATH_GET = "my-path-get";
- private static final int MAX_GETS = 3;
- private static final int WAIT_SEC_GETS = 20;
+ private static final String POLL_PATH = "my-poll-path";
+ private static final int MAX_POLLS = 3;
+ private static final int POLL_WAIT_SEC = 20;
private static final int TIMEOUT = 10;
- private SoParams params;
+ private HttpPollingParams params;
@Before
public void setUp() {
- params = SoParams.builder().pathGet(PATH_GET).maxGets(MAX_GETS).waitSecGet(WAIT_SEC_GETS).clientName(CLIENT)
- .path(PATH).timeoutSec(TIMEOUT).build();
+ params = HttpPollingParams.builder().pollPath(POLL_PATH).maxPolls(MAX_POLLS).pollWaitSec(POLL_WAIT_SEC)
+ .clientName(CLIENT).path(PATH).timeoutSec(TIMEOUT).build();
}
@Test
public void testValidate() {
assertTrue(params.validate(CONTAINER).isValid());
- testValidateField("pathGet", "null", bldr -> bldr.pathGet(null));
- testValidateField("maxGets", "minimum", bldr -> bldr.maxGets(-1));
- testValidateField("waitSecGet", "minimum", bldr -> bldr.waitSecGet(-1));
+ testValidateField("pollPath", "null", bldr -> bldr.pollPath(null));
+ testValidateField("maxPolls", "minimum", bldr -> bldr.maxPolls(-1));
+ testValidateField("pollWaitSec", "minimum", bldr -> bldr.pollWaitSec(-1));
// validate one of the superclass fields
testValidateField("clientName", "null", bldr -> bldr.clientName(null));
// check edge cases
- assertTrue(params.toBuilder().maxGets(0).build().validate(CONTAINER).isValid());
- assertFalse(params.toBuilder().waitSecGet(0).build().validate(CONTAINER).isValid());
- assertTrue(params.toBuilder().waitSecGet(1).build().validate(CONTAINER).isValid());
+ assertTrue(params.toBuilder().maxPolls(0).build().validate(CONTAINER).isValid());
+ assertFalse(params.toBuilder().pollWaitSec(0).build().validate(CONTAINER).isValid());
+ assertTrue(params.toBuilder().pollWaitSec(1).build().validate(CONTAINER).isValid());
}
@Test
public void testBuilder_testToBuilder() {
assertEquals(CLIENT, params.getClientName());
- assertEquals(PATH_GET, params.getPathGet());
- assertEquals(MAX_GETS, params.getMaxGets());
- assertEquals(WAIT_SEC_GETS, params.getWaitSecGet());
+ assertEquals(POLL_PATH, params.getPollPath());
+ assertEquals(MAX_POLLS, params.getMaxPolls());
+ assertEquals(POLL_WAIT_SEC, params.getPollWaitSec());
assertEquals(params, params.toBuilder().build());
}
private void testValidateField(String fieldName, String expected,
- @SuppressWarnings("rawtypes") Function<SoParamsBuilder, HttpParamsBuilder> makeInvalid) {
+ Function<HttpPollingParamsBuilder<?,?>, HttpPollingParamsBuilder<?,?>> makeInvalid) {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
diff --git a/models-interactions/model-actors/pom.xml b/models-interactions/model-actors/pom.xml
index b2c737930..950142869 100644
--- a/models-interactions/model-actors/pom.xml
+++ b/models-interactions/model-actors/pom.xml
@@ -1,7 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2020 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,18 +20,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
-
+
<parent>
<groupId>org.onap.policy.models</groupId>
<artifactId>policy-models-interactions</artifactId>
<version>2.3.0-SNAPSHOT</version>
</parent>
-
+
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
<properties>
- <jacoco.dataFile>${project.basedir}/../../../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
+ <jacoco.dataFile>${project.basedir}/../../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
</properties>
<modules>
diff --git a/models-interactions/model-impl/pom.xml b/models-interactions/model-impl/pom.xml
index 1bb9b33b7..32ee9cf24 100644
--- a/models-interactions/model-impl/pom.xml
+++ b/models-interactions/model-impl/pom.xml
@@ -3,14 +3,14 @@
controlloop-model-impl
================================================================================
Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation
+ Modifications Copyright (C) 2020 Nordix Foundation
================================================================================
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.
@@ -23,18 +23,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
-
+
<parent>
<groupId>org.onap.policy.models</groupId>
<artifactId>policy-models-interactions</artifactId>
<version>2.3.0-SNAPSHOT</version>
</parent>
-
+
<groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
<artifactId>model-impl</artifactId>
<properties>
- <jacoco.dataFile>${project.basedir}/../../../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
+ <jacoco.dataFile>${project.basedir}/../../../target/code-coverage/jacoco-ut.exec</jacoco.dataFile>
</properties>
<modules>
diff --git a/models-sim/models-sim-dmaap/src/main/package/docker/dmaap-sim.sh b/models-sim/models-sim-dmaap/src/main/package/docker/dmaap-sim.sh
index 0d152e1db..deb168f5d 100644
--- a/models-sim/models-sim-dmaap/src/main/package/docker/dmaap-sim.sh
+++ b/models-sim/models-sim-dmaap/src/main/package/docker/dmaap-sim.sh
@@ -2,6 +2,7 @@
#
# ============LICENSE_START=======================================================
# Copyright (C) 2019 Nordix Foundation.
+# Modifications copyright (C) 2020 Bell Canada. 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.
@@ -50,6 +51,5 @@ $JAVA_HOME/bin/java \
-Djavax.net.ssl.keyStorePassword="$KEYSTORE_PASSWD" \
-Djavax.net.ssl.trustStore="$TRUSTSTORE" \
-Djavax.net.ssl.trustStorePassword="$TRUSTSTORE_PASSWD" \
- -Dlogback.configurationFile=$DMAAP_SIM_HOME/etc/logback.xml \
org.onap.policy.models.sim.dmaap.startstop.Main \
-c $CONFIG_FILE
diff --git a/models-sim/models-sim-dmaap/src/main/package/tarball/assembly.xml b/models-sim/models-sim-dmaap/src/main/package/tarball/assembly.xml
index 8717701b6..08e202938 100644
--- a/models-sim/models-sim-dmaap/src/main/package/tarball/assembly.xml
+++ b/models-sim/models-sim-dmaap/src/main/package/tarball/assembly.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2019 Nordix Foundation.
+ Modifications copyright (C) 2020 Bell Canada. 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.
@@ -47,15 +48,6 @@
<fileMode>755</fileMode>
</fileSet>
<fileSet>
- <directory>${project.basedir}/src/main/resources
- </directory>
- <includes>
- <include>logback.xml</include>
- </includes>
- <outputDirectory>etc</outputDirectory>
- <lineEnding>unix</lineEnding>
- </fileSet>
- <fileSet>
<directory>${project.basedir}/src/main/resources/etc
</directory>
<includes>
diff --git a/models-sim/models-sim-dmaap/src/main/resources/logback.xml b/models-sim/models-sim-dmaap/src/main/resources/logback.xml
deleted file mode 100644
index 0e48d611f..000000000
--- a/models-sim/models-sim-dmaap/src/main/resources/logback.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2019 Nordix Foundation.
- ================================================================================
- 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.
-
- SPDX-License-Identifier: Apache-2.0
- ============LICENSE_END=========================================================
--->
-
-<configuration scan="true" scanPeriod="30 seconds" debug="false">
-
- <contextName>DMaaPSim</contextName>
- <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
- <property name="LOG_DIR" value="${java.io.tmpdir}/pf_logging/" />
-
- <!-- USE FOR STD OUT ONLY -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
- </encoder>
- </appender>
-
- <root level="info">
- <appender-ref ref="STDOUT" />
- </root>
-
- <logger name="org.eclipse.jetty" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.onap.policy.models.sim.dmaap" level="debug" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
-</configuration>
diff --git a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java
index 8eff1af42..2076df678 100644
--- a/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java
+++ b/models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorCommandLineArguments.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019, 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.
@@ -33,7 +33,6 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
-import org.apache.log4j.chainsaw.Main;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException;
@@ -140,7 +139,7 @@ public class PdpSimulatorCommandLineArguments {
}
if (commandLine.hasOption('h')) {
- return help(Main.class.getName());
+ return help(PdpSimulatorMain.class.getName());
}
if (commandLine.hasOption('v')) {
diff --git a/models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh b/models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh
index 3eac29ded..aaab6591e 100644
--- a/models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh
+++ b/models-sim/policy-models-sim-pdp/src/main/package/docker/pdp-sim.sh
@@ -2,6 +2,7 @@
#
# ============LICENSE_START=======================================================
# Copyright (C) 2019-2020 Nordix Foundation.
+# Modifications copyright (C) 2020 Bell Canada. 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.
@@ -50,6 +51,5 @@ $JAVA_HOME/bin/java \
-Djavax.net.ssl.keyStorePassword="$KEYSTORE_PASSWD" \
-Djavax.net.ssl.trustStore="$TRUSTSTORE" \
-Djavax.net.ssl.trustStorePassword="$TRUSTSTORE_PASSWD" \
- -Dlogback.configurationFile=$PDP_SIM_HOME/etc/logback.xml \
org.onap.policy.models.sim.pdp.PdpSimulatorMain \
-c $CONFIG_FILE
diff --git a/models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml b/models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml
index 2fc66d12b..240905357 100644
--- a/models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml
+++ b/models-sim/policy-models-sim-pdp/src/main/package/tarball/assembly.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2019 Nordix Foundation.
+ Modifications copyright (C) 2020 Bell Canada. 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.
@@ -37,15 +38,6 @@
</dependencySets>
<fileSets>
<fileSet>
- <directory>${project.basedir}/src/main/resources
- </directory>
- <includes>
- <include>logback.xml</include>
- </includes>
- <outputDirectory>etc</outputDirectory>
- <lineEnding>unix</lineEnding>
- </fileSet>
- <fileSet>
<directory>${project.basedir}/src/main/resources/config
</directory>
<includes>
diff --git a/models-sim/policy-models-sim-pdp/src/main/resources/logback.xml b/models-sim/policy-models-sim-pdp/src/main/resources/logback.xml
deleted file mode 100644
index 2b650d84c..000000000
--- a/models-sim/policy-models-sim-pdp/src/main/resources/logback.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- Copyright (C) 2019 Nordix Foundation.
- ================================================================================
- 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.
-
- SPDX-License-Identifier: Apache-2.0
- ============LICENSE_END=========================================================
--->
-
-<configuration scan="true" scanPeriod="30 seconds" debug="false">
-
- <contextName>DMaaPSim</contextName>
- <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
- <property name="LOG_DIR" value="${java.io.tmpdir}/pf_logging/" />
-
- <!-- USE FOR STD OUT ONLY -->
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
- </encoder>
- </appender>
-
- <root level="info">
- <appender-ref ref="STDOUT" />
- </root>
-
- <logger name="org.eclipse.jetty" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="org.onap.policy.models.sim.pdp" level="debug" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
-</configuration>
diff --git a/models-sim/policy-models-simulators/src/main/package/docker/simulators.sh b/models-sim/policy-models-simulators/src/main/package/docker/simulators.sh
index 57e742708..7e38f374c 100644
--- a/models-sim/policy-models-simulators/src/main/package/docker/simulators.sh
+++ b/models-sim/policy-models-simulators/src/main/package/docker/simulators.sh
@@ -4,6 +4,7 @@
# ONAP
# ================================================================================
# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+# Modifications copyright (C) 2020 Bell Canada. 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.
@@ -34,7 +35,6 @@ TRUSTSTORE_PASSWD="Pol1cy_0nap"
${JAVA_HOME}/bin/java \
-cp "${SIMULATOR_HOME}/etc:${SIMULATOR_HOME}/lib/*" \
- -Dlogback.configurationFile=${SIMULATOR_HOME}/etc/logback.xml \
-Djavax.net.ssl.keyStore="${KEYSTORE}" \
-Djavax.net.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \
-Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
diff --git a/models-sim/policy-models-simulators/src/main/package/tarball/assembly.xml b/models-sim/policy-models-simulators/src/main/package/tarball/assembly.xml
index 8496fd3c6..9a2fd65df 100644
--- a/models-sim/policy-models-simulators/src/main/package/tarball/assembly.xml
+++ b/models-sim/policy-models-simulators/src/main/package/tarball/assembly.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ Modifications copyright (C) 2020 Bell Canada. 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.
@@ -37,14 +38,6 @@
</dependencySets>
<fileSets>
<fileSet>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>logback.xml</include>
- </includes>
- <outputDirectory>etc</outputDirectory>
- <lineEnding>unix</lineEnding>
- </fileSet>
- <fileSet>
<directory>${project.basedir}/src/main/resources/ssl
</directory>
<includes>
diff --git a/models-sim/policy-models-simulators/src/main/resources/logback.xml b/models-sim/policy-models-simulators/src/main/resources/logback.xml
deleted file mode 100644
index da9821aef..000000000
--- a/models-sim/policy-models-simulators/src/main/resources/logback.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- 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.
-
- SPDX-License-Identifier: Apache-2.0
- ============LICENSE_END=========================================================
--->
-
-<configuration scan="true" scanPeriod="30 seconds" debug="false">
-
- <contextName>Simulators</contextName>
- <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
- <property name="logDir" value="${POLICY_LOGS}" />
-
- <appender name="DebugOut"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${logDir}/debug.log</file>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <fileNamePattern>${logDir}/debug.%d{yyyy-MM-dd}.%i.log.zip
- </fileNamePattern>
- <maxFileSize>50MB</maxFileSize>
- <maxHistory>10</maxHistory>
- <totalSizeCap>500MB</totalSizeCap>
- </rollingPolicy>
- <encoder>
- <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n
- </Pattern>
- </encoder>
- </appender>
-
- <root level="info">
- <appender-ref ref="DebugOut" />
- </root>
-
- <logger name="org.eclipse.jetty" level="info" additivity="false">
- <appender-ref ref="DebugOut" />
- </logger>
-
- <logger name="org.onap.policy.models.sim.dmaap" level="debug" additivity="false">
- <appender-ref ref="DebugOut" />
- </logger>
-
-</configuration>
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java
index f98a238ff..ba1042851 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifier.java
@@ -3,6 +3,7 @@
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,4 +84,9 @@ public class ToscaPolicyIdentifier implements Comparable<ToscaPolicyIdentifier>
return ObjectUtils.compare(getVersion(), other.getVersion());
}
+
+ @Override
+ public String toString() {
+ return this.name + " " + this.version;
+ }
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java
index ca3684a24..43e7114be 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyIdentifierOptVersion.java
@@ -3,6 +3,7 @@
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,4 +74,9 @@ public class ToscaPolicyIdentifierOptVersion implements Comparable<ToscaPolicyId
return ObjectUtils.compare(getVersion(), other.getVersion());
}
+
+ @Override
+ public String toString() {
+ return this.name + " " + this.version;
+ }
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java
index 4cd1764de..32dd7cbd7 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeIdentifier.java
@@ -3,6 +3,7 @@
* ONAP Policy Models
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,4 +84,9 @@ public class ToscaPolicyTypeIdentifier implements Comparable<ToscaPolicyTypeIden
return ObjectUtils.compare(getVersion(), other.getVersion());
}
+
+ @Override
+ public String toString() {
+ return this.name + " " + this.version;
+ }
}