aboutsummaryrefslogtreecommitdiffstats
path: root/common/src
diff options
context:
space:
mode:
authorBoslet, Cory <cory.boslet@att.com>2020-02-06 10:04:42 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-02-07 09:03:42 -0500
commit8e34d4cd37809e854340170ae39fff7ae0a3c71a (patch)
treeee9bd2e51559a15e99c90c76e289c56b7115407e /common/src
parent526148c73d077343c083484aedb5745f7a759f0c (diff)
add retry sequence levels
Added retry sequence levels so that the different services can specify their desire. Updated to be medium and added to be long sequence in audit. Change retry level to be final and changed default constructor to private Changed default constructor to public so its visible. Updated unit test to reflect change and get verify job to pass Added and updated the unit test for add graph Issue-ID: SO-2649 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I981b90a5dbb1dca5354fba37589b26dabbfc0b0e
Diffstat (limited to 'common/src')
-rw-r--r--common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java41
-rw-r--r--common/src/main/java/org/onap/so/utils/RetrySequenceLevel.java6
-rw-r--r--common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java2
3 files changed, 41 insertions, 8 deletions
diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java
index a2aed638fe..9488187003 100644
--- a/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java
+++ b/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java
@@ -1,10 +1,7 @@
package org.onap.so.utils;
-import org.camunda.bpm.client.task.ExternalTask;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@@ -17,6 +14,16 @@ public abstract class ExternalTaskUtils {
private static final Logger logger = LoggerFactory.getLogger(ExternalTaskUtils.class);
+ private final RetrySequenceLevel retrySequenceLevel;
+
+ public ExternalTaskUtils() {
+ this.retrySequenceLevel = RetrySequenceLevel.MEDIUM;
+ }
+
+ public ExternalTaskUtils(RetrySequenceLevel retrySequenceLevel) {
+ this.retrySequenceLevel = retrySequenceLevel;
+ }
+
public long calculateRetryDelay(int currentRetries) {
int retrySequence = getRetrySequence().length - currentRetries;
return Integer.parseInt(getRetrySequence()[retrySequence]) * getRetryMutiplier();
@@ -27,10 +34,30 @@ public abstract class ExternalTaskUtils {
}
protected String[] getRetrySequence() {
- String[] seq = {"1", "1", "2", "3", "5", "8", "13", "20"};
- if (env.getProperty("mso.workflow.topics.retrySequence") != null) {
- seq = env.getProperty("mso.workflow.topics.retrySequence", String[].class);
+ switch (retrySequenceLevel) {
+ case SHORT:
+ String[] seqShort = {"1", "1"};
+ if (env.getProperty("mso.workflow.topics.retrySequence.short") != null) {
+ seqShort = env.getProperty("mso.workflow.topics.retrySequence.short", String[].class);
+ }
+ return seqShort;
+ case MEDIUM:
+ String[] seqInter = {"1", "1", "2", "3", "5"};
+ if (env.getProperty("mso.workflow.topics.retrySequence.medium") != null) {
+ seqInter = env.getProperty("mso.workflow.topics.retrySequence.medium", String[].class);
+ }
+ return seqInter;
+ case LONG:
+ String[] seqLong = {"1", "1", "2", "3", "5", "8", "13", "20"};
+ if (env.getProperty("mso.workflow.topics.retrySequence") != null) {
+ seqLong = env.getProperty("mso.workflow.topics.retrySequence", String[].class);
+ }
+ return seqLong;
+ default:
+ String[] seq = {"1"};
+ return seq;
}
- return seq;
+
}
+
}
diff --git a/common/src/main/java/org/onap/so/utils/RetrySequenceLevel.java b/common/src/main/java/org/onap/so/utils/RetrySequenceLevel.java
new file mode 100644
index 0000000000..02964693d2
--- /dev/null
+++ b/common/src/main/java/org/onap/so/utils/RetrySequenceLevel.java
@@ -0,0 +1,6 @@
+package org.onap.so.utils;
+
+public enum RetrySequenceLevel {
+ SHORT, MEDIUM, LONG
+
+}
diff --git a/common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java b/common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java
index f918781b39..e27caa6458 100644
--- a/common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java
+++ b/common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java
@@ -16,7 +16,7 @@ public class ExternalTaskUtilsTest {
private Environment mockenv;
@InjectMocks
- private ExternalTaskUtils externalTaskUtilsAnony = new ExternalTaskUtils() {
+ private ExternalTaskUtils externalTaskUtilsAnony = new ExternalTaskUtils(RetrySequenceLevel.LONG) {
};