Added changes for SO Request retries 13/16013/2
authorHockla, Ali (ah999m) <ah999m@att.com>
Wed, 27 Sep 2017 14:40:07 +0000 (09:40 -0500)
committerAli Hockla <ah999m@att.com>
Wed, 27 Sep 2017 15:39:40 +0000 (15:39 +0000)
This change will allow the control loop to increment the operation
attempts in the case of an SO failure in order to retry the
operation if defined in the yaml.

Issue-ID: POLICY-268

Change-Id: I1fee2ce64524e58fc3068f19c5cf31ed91159e0f
Signed-off-by: Hockla, Ali (ah999m) <ah999m@att.com>
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java

index 10cf173..add981c 100644 (file)
@@ -346,13 +346,16 @@ public class ControlLoopOperationManager implements Serializable {
                    return null;
                } else if (response instanceof SOResponse) {
                        SOResponse msoResponse = (SOResponse) response;
+                       
+                       Integer operationAttempt = this.attempts;
+
                        switch (msoResponse.httpResponseCode) {
                        case 200:
                        case 202:
                                //
                                // Consider it as success
                                //
-                               this.completeOperation(new Integer(1), msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS);
+                               this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS);
                                if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) {
                                        return null;
                                }
@@ -361,10 +364,12 @@ public class ControlLoopOperationManager implements Serializable {
                                //
                                // Consider it as failure
                                //
-                               this.completeOperation(new Integer(1), msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE);
+                               this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE);
                                if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) {
                                        return null;
                                }
+                               // increment operation attempts for retries
+                               this.attempts += 1;
                                return PolicyResult.FAILURE;
                        }