made max retries configurable via mso config 51/78251/1
authorBenjamin, Max (mb388a) <mb388a@us.att.com>
Mon, 11 Feb 2019 20:08:59 +0000 (15:08 -0500)
committerBenjamin, Max (mb388a) <mb388a@us.att.com>
Mon, 11 Feb 2019 20:09:16 +0000 (15:09 -0500)
fixed an error with the wrong variable being printed
made max retries configurable via mso config

Change-Id: Iec6d209ec2868200ec5956e269b6a048d7619307
Issue-ID: SO-1495
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn

index b210b5e..ee7999f 100644 (file)
@@ -55,6 +55,7 @@ public class ExecuteBuildingBlockRainyDay {
        private Environment environment;
        protected String retryDurationPath = "mso.rainyDay.retryDurationMultiplier";
        protected String defaultCode = "mso.rainyDay.defaultCode";
+       protected String maxRetries = "mso.rainyDay.maxRetries";
 
        public void setRetryTimer(DelegateExecution execution) {
                try {
@@ -172,10 +173,17 @@ public class ExecuteBuildingBlockRainyDay {
                        msoLogger.debug("RainyDayHandler Status Code is: " + handlingCode);
                        execution.setVariable(HANDLING_CODE, handlingCode);
                } catch (Exception e) {
-                       msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = Abort", e);
                        String code = this.environment.getProperty(defaultCode);
+                       msoLogger.error("Failed to determine RainyDayHandler Status. Seting handlingCode = "+ code, e);
                        execution.setVariable(HANDLING_CODE, code);
                }
+               try{
+                       int envMaxRetries = Integer.parseInt(this.environment.getProperty(maxRetries));
+                       execution.setVariable("maxRetries", envMaxRetries);
+               } catch (Exception ex) {
+                       msoLogger.error("Could not read maxRetries from config file. Setting max to 5 retries");
+                       execution.setVariable("maxRetries", 5);
+               }
        }
 
        public void setHandlingStatusSuccess(DelegateExecution execution) {
index 868aabf..6344a3f 100644 (file)
@@ -131,6 +131,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
                executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
                
                assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
+               assertEquals(5,delegateExecution.getVariable("maxRetries"));
        }
        
        @Test
index 943ce12..5189f8b 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2">
   <bpmn:process id="ExecuteBuildingBlock" name="ExecuteBuildingBlock" isExecutable="true">
     <bpmn:startEvent id="Start_ExecuteBuildingBlock" name="start">
       <bpmn:outgoing>SequenceFlow_0rq4c5r</bpmn:outgoing>
@@ -73,7 +73,7 @@
       <bpmn:sequenceFlow id="SequenceFlow_0ndt8ft" sourceRef="Task_SetRetryTimer" targetRef="IntermediateCatchEvent_RetryTimer" />
       <bpmn:sequenceFlow id="SequenceFlow_07a1ytc" sourceRef="IntermediateCatchEvent_RetryTimer" targetRef="EndEvent_1sez2lh" />
       <bpmn:sequenceFlow id="SequenceFlow_1wbevp0" name="yes" sourceRef="ExclusiveGateway_0ey4zpt" targetRef="Task_SetRetryTimer">
-        <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("retryCount")<5}]]></bpmn:conditionExpression>
+        <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("retryCount")<execution.getVariable("maxRetries")}]]></bpmn:conditionExpression>
       </bpmn:sequenceFlow>
       <bpmn:endEvent id="EndEvent_0mvmk3i">
         <bpmn:incoming>SequenceFlow_0h8v45y</bpmn:incoming>