blob: 349767fc5b6e73b03104f45016d5a6df24f17baf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
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;
@Component
public abstract class ExternalTaskUtils {
@Autowired
Environment env;
private static final Logger logger = LoggerFactory.getLogger(ExternalTaskUtils.class);
public long calculateRetryDelay(int currentRetries) {
int retrySequence = getRetrySequence().length - currentRetries;
return Integer.parseInt(getRetrySequence()[retrySequence]) * getRetryMutiplier();
}
protected Long getRetryMutiplier() {
return Long.parseLong(env.getProperty("mso.workflow.topics.retryMultiplier", "6000"));
}
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);
}
return seq;
}
protected void setupMDC(ExternalTask externalTask) {
logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
String msoRequestId = externalTask.getVariable("mso-request-id");
if (msoRequestId != null && !msoRequestId.isEmpty()) {
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
}
MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName());
}
}
|