diff options
author | KAPIL SINGAL <ks220y@att.com> | 2020-12-14 19:06:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-12-14 19:06:51 +0000 |
commit | cc4d609141f18b6644f906bfdbbe1f9b4741631c (patch) | |
tree | 317c1e04435c4dc7b510301ca96b6ba60a60e213 /ms/blueprintsprocessor/modules | |
parent | 65459aee0025ff1cf0b09930b60835e2485f1389 (diff) | |
parent | b88c96aebb6efeea96bbc481b729e17b8898dc13 (diff) |
Merge "Pass on MDCContext to imperative workflow"
Diffstat (limited to 'ms/blueprintsprocessor/modules')
2 files changed, 14 insertions, 4 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt index 98e5e5aec..f3e4e59aa 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintWorkflowService.kt @@ -103,7 +103,7 @@ abstract class AbstractBluePrintWorkFlowService<In, Out> : CoroutineScope, BlueP var exceptions: MutableList<Exception> = arrayListOf() - final override val coroutineContext: CoroutineContext + override val coroutineContext: CoroutineContext get() = job + CoroutineName("Wf") fun cancel() { diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt index 0146358a8..464ae8ddc 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/workflow/ImperativeWorkflowExecutionService.kt @@ -17,12 +17,14 @@ package org.onap.ccsdk.cds.blueprintsprocessor.services.workflow import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.coroutineScope import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.Status import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.MDCContext import org.onap.ccsdk.cds.controllerblueprints.core.asGraph import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel @@ -35,6 +37,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.NodeExecuteMessage import org.onap.ccsdk.cds.controllerblueprints.core.service.NodeSkipMessage import org.onap.ccsdk.cds.controllerblueprints.core.service.WorkflowExecuteMessage import org.springframework.stereotype.Service +import kotlin.coroutines.CoroutineContext @Service("imperativeWorkflowExecutionService") class ImperativeWorkflowExecutionService( @@ -54,14 +57,21 @@ class ImperativeWorkflowExecutionService( val graph = bluePrintContext.workflowByName(workflowName).asGraph() - return ImperativeBluePrintWorkflowService(nodeTemplateExecutionService) - .executeWorkflow(graph, bluePrintRuntimeService, executionServiceInput) + return coroutineScope { + ImperativeBluePrintWorkflowService( + nodeTemplateExecutionService, + this.coroutineContext[MDCContext] + ) + }.let { it.executeWorkflow(graph, bluePrintRuntimeService, executionServiceInput) } } } -open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService) : +open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService, private val mdcContext: CoroutineContext?) : AbstractBluePrintWorkFlowService<ExecutionServiceInput, ExecutionServiceOutput>() { + final override val coroutineContext: CoroutineContext + get() = mdcContext?.let { super.coroutineContext + it } ?: super.coroutineContext + val log = logger(ImperativeBluePrintWorkflowService::class) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> |