Add functionality for VFC request retries 69/16069/1
authorRitu Sood <ritu.sood@intel.com>
Wed, 27 Sep 2017 10:19:57 +0000 (03:19 -0700)
committerRitu Sood <ritu.sood@intel.com>
Wed, 27 Sep 2017 10:23:27 +0000 (03:23 -0700)
This allows the control loop to track operation
attempts in case of VFC failures. This will
allow retries of the operation if required in the
YAML file.

Issue-ID: POLICY-270
Change-Id: Ieeaf6770a8d03fa4eecc976535301d9236d19972
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java

index add981c..e13352a 100644 (file)
@@ -375,11 +375,12 @@ public class ControlLoopOperationManager implements Serializable {
 
                } else if (response instanceof VFCResponse) {
                        VFCResponse vfcResponse = (VFCResponse) response;
+                       Integer operationAttempt = this.attempts;
                        if (vfcResponse.responseDescriptor.getStatus().equalsIgnoreCase("finished")) {
                                //
                                // Consider it as success
                                //
-                               this.completeOperation(new Integer(1), " Success", PolicyResult.SUCCESS);
+                               this.completeOperation(operationAttempt, " Success", PolicyResult.SUCCESS);
                                if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) {
                                        return null;
                                }
@@ -388,10 +389,12 @@ public class ControlLoopOperationManager implements Serializable {
                                //
                                // Consider it as failure
                                //
-                               this.completeOperation(new Integer(1), " Failed", PolicyResult.FAILURE);
+                               this.completeOperation(operationAttempt, " 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;
                        }
                }