summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-06-11 19:00:41 -0400
committerJim Hahn <jrh3@att.com>2020-06-12 18:40:29 -0400
commite9af3a2b3a430626c740b18ccf8592706db1dfb1 (patch)
treeff0d351b54f4862de8512666d3a7c1371ef73118 /models-interactions/model-actors/actor.so/src/main/java
parentc34fdc19686d70af12e8873b0b01b96dd54c1aa3 (diff)
Moving common polling code into HttpOperation
SO and VFC have duplicate code for polling. Moved it into the common superclass. Issue-ID: POLICY-2632 Change-Id: I27128bfb2d54ef522b6b44ff569819a8463f3454 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.so/src/main/java')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorParams.java56
-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/SoConfig.java63
-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/SoParams.java55
-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
8 files changed, 55 insertions, 337 deletions
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/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorParams.java
deleted file mode 100644
index 3e82fe1a6..000000000
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorParams.java
+++ /dev/null
@@ -1,56 +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 lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.Setter;
-import org.onap.policy.common.parameters.annotations.Min;
-import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams;
-
-@Getter
-@Setter
-@EqualsAndHashCode(callSuper = true)
-public class SoActorParams extends HttpActorParams {
-
- /*
- * Optional, default values that are used if missing from the operation-specific
- * parameters.
- */
-
- /**
- * Path to use for the "get" request.
- */
- private String pathGet = "/orchestrationRequests/v5/";
-
- /**
- * Maximum number of "get" requests permitted, after the initial request, to retrieve
- * the response.
- */
- @Min(0)
- private int maxGets = 20;
-
- /**
- * Time, in seconds, to wait between issuing "get" requests.
- */
- @Min(1)
- private int waitSecGet = 20;
-}
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/SoConfig.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.java
deleted file mode 100644
index 959cd454a..000000000
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoConfig.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.so;
-
-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 SoConfig 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;
-
-
- /**
- * Constructs the object.
- *
- * @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 SoConfig(Executor blockingExecutor, SoParams 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.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/SoParams.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoParams.java
deleted file mode 100644
index 53f6e932f..000000000
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoParams.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.so;
-
-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 SoParams 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.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;
}
/**