From 4e50a58565461839df6a1fe65f571a04b2404616 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Thu, 14 May 2020 19:08:02 -0400 Subject: SO poll should not require request ID When SO is polled for the result of a previous request, it does not necessarily include the originally returned request ID in the response. This causes the SO actor to generate a "missing request ID in response" exception. Modified the actor to only extract the request ID from the first response and cache it for subsequeent responses. Testing this required the SO simulator to be modified so that it would return an INCOMPLETE on the initial request, forcing the actor to poll until it returns a COMPLETE. Made this a settable flag so that it could be enabled just to test the SO actor without impacting other components (e.g., drools-apps, CSITs). Also fixed a couple of checkstyle issues in the simulators. Issue-ID: POLICY-2568 Change-Id: Ifad8b3c0c2c0b03cb82da693c2cf5ced44ede105 Signed-off-by: Jim Hahn --- .../org/onap/policy/controlloop/actor/so/SoOperation.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'models-interactions/model-actors/actor.so/src/main') 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 86b910176..a4c802c9a 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 @@ -116,6 +116,7 @@ public abstract class SoOperation extends HttpOperation { */ protected void resetGetCount() { getCount = 0; + setSubRequestId(null); } /** @@ -214,7 +215,7 @@ public abstract class SoOperation extends HttpOperation { // still incomplete // need a request ID with which to query - if (!extractSubRequestId(response)) { + if (getSubRequestId() == null && !extractSubRequestId(response)) { throw new IllegalArgumentException("missing request ID in response"); } @@ -227,7 +228,7 @@ public abstract class SoOperation extends HttpOperation { } // sleep and then perform a "get" operation - Function> doGet = unused -> issueGet(outcome, response); + Function> doGet = unused -> issueGet(outcome); return sleep(getWaitMsGet(), TimeUnit.MILLISECONDS).thenComposeAsync(doGet); } @@ -257,18 +258,16 @@ public abstract class SoOperation extends HttpOperation { * 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 issueGet(OperationOutcome outcome, SoResponse response) { - String path = getPathGet() + response.getRequestReferences().getRequestId(); + private CompletableFuture 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); - // TODO should this use "path" or the full "url"? return handleResponse(outcome, url, callback -> getClient().get(callback, path, null)); } -- cgit 1.2.3-korg