summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-12-04 12:22:20 +0200
committerEylon Malin <eylon.malin@intl.att.com>2019-12-04 12:22:20 +0200
commitda3f5a40d2b98369842c640729f14823034138af (patch)
tree30e0100f4aeb76a614934c457ee1d95a9d4e248b /vid-app-common/src
parent4e2d89221395442475eb2d681dfe61a3584d2496 (diff)
make sure request id is unique per each async job execution
Issue-ID: VID-253 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com> Change-Id: I1e7e98876c6557ff18a9e1646d7b815ed9af830d
Diffstat (limited to 'vid-app-common/src')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt4
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java30
2 files changed, 21 insertions, 13 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
index a266dd002..97c9f99ce 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/ResourceCommand.kt
@@ -23,7 +23,6 @@ package org.onap.vid.job.command
import com.fasterxml.jackson.module.kotlin.convertValue
import org.apache.commons.lang3.ObjectUtils.defaultIfNull
-import org.onap.logging.ref.slf4j.ONAPLogConstants
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
import org.onap.vid.changeManagement.RequestDetailsWrapper
import org.onap.vid.exceptions.AbortingException
@@ -38,7 +37,6 @@ import org.onap.vid.mso.RestMsoImplementation
import org.onap.vid.mso.model.ModelInfo
import org.onap.vid.utils.JACKSON_OBJECT_MAPPER
import org.onap.vid.utils.getEnumFromMapOfStrings
-import org.slf4j.MDC
import org.springframework.http.HttpMethod
import java.util.*
@@ -362,8 +360,6 @@ abstract class ResourceCommand(
}
protected fun executeAndHandleMsoInstanceRequest(restCallPlan: MsoRestCallPlan): JobStatus {
- //make sure requestIds are unique
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, UUID.randomUUID().toString())
val msoResponse = restMso.restCall(
restCallPlan.httpMethod,
RequestReferencesContainer::class.java,
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java
index 0b277b4d2..80d8cc53c 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/impl/JobWorker.java
@@ -20,23 +20,28 @@
package org.onap.vid.job.impl;
+import static org.onap.vid.job.Job.JobStatus.FAILED;
+import static org.onap.vid.job.Job.JobStatus.STOPPED;
+import static org.onap.vid.job.command.ResourceCommandKt.ACTION_PHASE;
+import static org.onap.vid.job.command.ResourceCommandKt.INTERNAL_STATE;
+
+import java.util.Optional;
+import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.vid.job.*;
+import org.onap.vid.job.Job;
+import org.onap.vid.job.JobCommand;
+import org.onap.vid.job.JobException;
+import org.onap.vid.job.JobsBrokerService;
+import org.onap.vid.job.NextCommand;
import org.onap.vid.job.command.JobCommandFactory;
import org.quartz.JobExecutionContext;
+import org.slf4j.MDC;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;
-import java.util.Optional;
-import java.util.UUID;
-
-import static org.onap.vid.job.Job.JobStatus.FAILED;
-import static org.onap.vid.job.Job.JobStatus.STOPPED;
-import static org.onap.vid.job.command.ResourceCommandKt.ACTION_PHASE;
-import static org.onap.vid.job.command.ResourceCommandKt.INTERNAL_STATE;
-
@Component
public class JobWorker extends QuartzJobBean {
@@ -80,6 +85,8 @@ public class JobWorker extends QuartzJobBean {
}
protected Job executeJobAndGetNext(Job job) {
+ setThreadWithRandomRequestId();
+
Object internalState = job.getData().get(INTERNAL_STATE);
Object actionPhase = job.getData().get(ACTION_PHASE);
LOGGER.debug(EELFLoggerDelegate.debugLogger, "going to execute job {} of {}: {}/{} {}/{}",
@@ -96,6 +103,11 @@ public class JobWorker extends QuartzJobBean {
return setNextCommandInJob(nextCommand, job);
}
+ private void setThreadWithRandomRequestId() {
+ //make sure requestIds in outgoing requests are not reused
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, UUID.randomUUID().toString());
+ }
+
private NextCommand executeCommandAndGetNext(Job job) {
NextCommand nextCommand;
try {