summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java13
-rw-r--r--common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java23
-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/ExternalTaskServiceUtilsTest.java62
-rw-r--r--common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java2
6 files changed, 125 insertions, 22 deletions
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
index a72229a25c..9fceed1641 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
@@ -57,9 +57,6 @@ public class RequestParameters implements Serializable {
@JsonProperty("rebuildVolumeGroups")
private Boolean rebuildVolumeGroups;
- @JsonProperty("enforceValidNfValues")
- private Boolean enforceValidNfValues = false;
-
@Override
public String toString() {
return new ToStringBuilder(this).append("subscriptionServiceType", subscriptionServiceType)
@@ -67,15 +64,7 @@ public class RequestParameters implements Serializable {
.append("usePreload", usePreload).append("autoBuildVfModules", autoBuildVfModules)
.append("cascadeDelete", cascadeDelete).append("testApi", testApi)
.append("retainAssignments", retainAssignments).append("rebuildVolumeGroups", rebuildVolumeGroups)
- .append("enforceValidNfValues", enforceValidNfValues).toString();
- }
-
- public Boolean getEnforceValidNfValues() {
- return enforceValidNfValues;
- }
-
- public void setEnforceValidNfValues(Boolean enforceValidNfValues) {
- this.enforceValidNfValues = enforceValidNfValues;
+ .toString();
}
public String getSubscriptionServiceType() {
diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java
index e43b431821..4f13cec8f4 100644
--- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java
+++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java
@@ -1,6 +1,8 @@
package org.onap.so.utils;
import java.security.GeneralSecurityException;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.camunda.bpm.client.ExternalTaskClient;
import org.camunda.bpm.client.interceptor.ClientRequestInterceptor;
import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider;
@@ -8,21 +10,30 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
+
+
@Component
public class ExternalTaskServiceUtils {
@Autowired
public Environment env;
+ protected Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet();
+
+
private static final Logger logger = LoggerFactory.getLogger(ExternalTaskServiceUtils.class);
public ExternalTaskClient createExternalTaskClient() throws Exception {
String auth = getAuth();
ClientRequestInterceptor interceptor = createClientInterceptor(auth);
- return ExternalTaskClient.create().baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1)
- .addInterceptor(interceptor).asyncResponseTimeout(120000).build();
+ ExternalTaskClient client =
+ ExternalTaskClient.create().baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1)
+ .addInterceptor(interceptor).asyncResponseTimeout(120000).build();
+ taskClients.add(client);
+ return client;
}
protected ClientRequestInterceptor createClientInterceptor(String auth) {
@@ -42,5 +53,13 @@ public class ExternalTaskServiceUtils {
return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "3"));
}
+ @Scheduled(fixedDelay = 30000)
+ public void checkAllClientsActive() {
+ getClients().stream().filter(client -> !client.isActive()).forEach(ExternalTaskClient::start);
+ }
+
+ protected Set<ExternalTaskClient> getClients() {
+ return taskClients;
+ }
}
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/ExternalTaskServiceUtilsTest.java b/common/src/test/java/org/onap/so/utils/ExternalTaskServiceUtilsTest.java
new file mode 100644
index 0000000000..c9fc27ebe0
--- /dev/null
+++ b/common/src/test/java/org/onap/so/utils/ExternalTaskServiceUtilsTest.java
@@ -0,0 +1,62 @@
+package org.onap.so.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import org.camunda.bpm.client.ExternalTaskClient;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.springframework.core.env.Environment;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ExternalTaskServiceUtilsTest {
+
+ @Spy
+ @InjectMocks
+ private ExternalTaskServiceUtils utils = new ExternalTaskServiceUtils();
+
+ @Mock
+ private ExternalTaskClient actualClient1;
+
+ @Mock
+ private ExternalTaskClient actualClient2;
+
+ @Mock
+ private ExternalTaskClient actualClient3;
+
+ @Mock
+ private ExternalTaskClient actualClient4;
+
+ @Test
+ public void testCheckActiveClients() throws Exception {
+ Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet();
+ taskClients.add(actualClient1);
+ taskClients.add(actualClient2);
+ taskClients.add(actualClient3);
+ taskClients.add(actualClient4);
+ when(utils.getClients()).thenReturn(taskClients);
+ when(actualClient1.isActive()).thenReturn(false);
+ when(actualClient2.isActive()).thenReturn(true);
+ when(actualClient3.isActive()).thenReturn(false);
+ when(actualClient4.isActive()).thenReturn(true);
+ utils.checkAllClientsActive();
+ verify(actualClient1, times(1)).isActive();
+ verify(actualClient2, times(1)).isActive();
+ verify(actualClient3, times(1)).isActive();
+ verify(actualClient4, times(1)).isActive();
+ verify(actualClient1, times(1)).start();
+ verify(actualClient3, times(1)).start();
+ }
+
+}
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) {
};