summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-02-10 13:38:36 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-10 13:38:36 +0000
commit980aa7b6d011d4760a82033189a0b116fedb9613 (patch)
tree394ff8f21c767d74160777a265662e61a6feb0b5
parent0772e8876fa155fd93b7abb5816a6d9a040aa7f6 (diff)
parent8e34d4cd37809e854340170ae39fff7ae0a3c71a (diff)
Merge "add retry sequence levels"
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java5
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java5
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java4
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java5
-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
8 files changed, 64 insertions, 8 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
index 0c05df959f..ddd9fb1b5e 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java
@@ -25,6 +25,7 @@ import java.util.Optional;
import org.onap.so.objects.audit.AAIObjectAudit;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.onap.so.utils.ExternalTaskUtils;
+import org.onap.so.utils.RetrySequenceLevel;
import org.onap.logging.filter.base.ONAPComponents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,6 +48,10 @@ public abstract class AbstractAuditService extends ExternalTaskUtils {
@Autowired
public Environment env;
+ public AbstractAuditService() {
+ super(RetrySequenceLevel.LONG);
+ }
+
/**
* @param auditHeatStackFailed
* @param auditList
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
index 43b362cbaf..8291fa9882 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java
@@ -32,6 +32,7 @@ import org.onap.so.audit.beans.AuditInventory;
import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.externaltasks.logging.AuditMDCSetup;
import org.onap.so.objects.audit.AAIObjectAuditList;
+import org.onap.so.utils.RetrySequenceLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -48,6 +49,10 @@ public class AuditCreateStackService extends AbstractAuditService {
@Autowired
private AuditMDCSetup mdcSetup;
+ public AuditCreateStackService() {
+ super();
+ }
+
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java
index da5e8bb3a2..cf077915c9 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java
@@ -56,6 +56,10 @@ public class AuditDeleteStackService extends AbstractAuditService {
@Autowired
protected Environment env;
+ public AuditDeleteStackService() {
+ super();
+ }
+
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java
index 8699f8b953..1c69a3e5e7 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java
@@ -28,6 +28,10 @@ public class AuditQueryStackService extends AbstractAuditService {
@Autowired
protected AuditDataService auditDataService;
+ public AuditQueryStackService() {
+ super();
+ }
+
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
AuditInventory auditInventory = externalTask.getVariable("auditInventory");
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
index 3d2d1d2aa3..e02258c619 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java
@@ -29,6 +29,7 @@ import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvide
import org.onap.so.externaltasks.logging.AuditMDCSetup;
import org.onap.so.objects.audit.AAIObjectAuditList;
import org.onap.so.utils.ExternalTaskUtils;
+import org.onap.so.utils.RetrySequenceLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +50,10 @@ public class CreateInventoryTask extends ExternalTaskUtils {
@Autowired
private AuditMDCSetup mdcSetup;
+ public CreateInventoryTask() {
+ super(RetrySequenceLevel.SHORT);
+ }
+
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
boolean success = true;
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) {
};