X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ms%2Fblueprintsprocessor%2Fmodules%2Fservices%2Fworkflow-service%2Fsrc%2Fmain%2Fkotlin%2Forg%2Fonap%2Fccsdk%2Fcds%2Fblueprintsprocessor%2Fservices%2Fworkflow%2FImperativeWorkflowExecutionService.kt;h=2aa408527d77f16aeeb19882b2f7ebfa1ae6a2ea;hb=fbbdf23b57c799362a368a98ae53290d5dc48909;hp=6bee17f4b6a995101254e3585ea291d5acd13218;hpb=d02e575d359c5a7707112e5e0afc53713d7796e7;p=ccsdk%2Fcds.git 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 6bee17f4b..2aa408527 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 @@ -20,23 +20,33 @@ import kotlinx.coroutines.CompletableDeferred 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.core.* +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.asGraph +import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintWorkflowExecutionService -import org.onap.ccsdk.cds.controllerblueprints.core.service.* -import org.springframework.beans.factory.config.ConfigurableBeanFactory -import org.springframework.context.annotation.Scope +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.controllerblueprints.core.service.AbstractBluePrintWorkFlowService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService +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 @Service("imperativeWorkflowExecutionService") class ImperativeWorkflowExecutionService( - private val imperativeBluePrintWorkflowService: BluePrintWorkFlowService) - : BluePrintWorkflowExecutionService { + private val nodeTemplateExecutionService: NodeTemplateExecutionService +) : + BluePrintWorkflowExecutionService { - override suspend fun executeBluePrintWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, - executionServiceInput: ExecutionServiceInput, - properties: MutableMap): ExecutionServiceOutput { + override suspend fun executeBluePrintWorkflow( + bluePrintRuntimeService: BluePrintRuntimeService<*>, + executionServiceInput: ExecutionServiceInput, + properties: MutableMap + ): ExecutionServiceOutput { val bluePrintContext = bluePrintRuntimeService.bluePrintContext() @@ -44,23 +54,25 @@ class ImperativeWorkflowExecutionService( val graph = bluePrintContext.workflowByName(workflowName).asGraph() - return imperativeBluePrintWorkflowService.executeWorkflow(graph, bluePrintRuntimeService, - executionServiceInput) + return ImperativeBluePrintWorkflowService(nodeTemplateExecutionService) + .executeWorkflow(graph, bluePrintRuntimeService, executionServiceInput) } } -@Service -@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) -open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService) - : AbstractBluePrintWorkFlowService() { +open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionService: NodeTemplateExecutionService) : + AbstractBluePrintWorkFlowService() { + val log = logger(ImperativeBluePrintWorkflowService::class) lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> lateinit var executionServiceInput: ExecutionServiceInput lateinit var workflowName: String - override suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BluePrintRuntimeService<*>, - input: ExecutionServiceInput): ExecutionServiceOutput { + override suspend fun executeWorkflow( + graph: Graph, + bluePrintRuntimeService: BluePrintRuntimeService<*>, + input: ExecutionServiceInput + ): ExecutionServiceOutput { this.graph = graph this.bluePrintRuntimeService = bluePrintRuntimeService this.executionServiceInput = input @@ -93,6 +105,7 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS } else { message = BluePrintConstants.STATUS_SUCCESS } + eventType = EventType.EVENT_COMPONENT_EXECUTED.name } return ExecutionServiceOutput().apply { commonHeader = executionServiceInput.commonHeader @@ -101,8 +114,8 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS } } - override suspend fun prepareNodeExecutionMessage(node: Graph.Node) - : NodeExecuteMessage { + override suspend fun prepareNodeExecutionMessage(node: Graph.Node): + NodeExecuteMessage { val nodeOutput = ExecutionServiceOutput().apply { commonHeader = executionServiceInput.commonHeader actionIdentifiers = executionServiceInput.actionIdentifiers @@ -110,8 +123,8 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS return NodeExecuteMessage(node, executionServiceInput, nodeOutput) } - override suspend fun prepareNodeSkipMessage(node: Graph.Node) - : NodeSkipMessage { + override suspend fun prepareNodeSkipMessage(node: Graph.Node): + NodeSkipMessage { val nodeOutput = ExecutionServiceOutput().apply { commonHeader = executionServiceInput.commonHeader actionIdentifiers = executionServiceInput.actionIdentifiers @@ -119,15 +132,18 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS return NodeSkipMessage(node, executionServiceInput, nodeOutput) } - override suspend fun executeNode(node: Graph.Node, nodeInput: ExecutionServiceInput, - nodeOutput: ExecutionServiceOutput): EdgeLabel { - log.info("Executing workflow($workflowName[${this.workflowId}])'s step($${node.id})") + override suspend fun executeNode( + node: Graph.Node, + nodeInput: ExecutionServiceInput, + nodeOutput: ExecutionServiceOutput + ): EdgeLabel { + log.info("Executing workflow($workflowName[${this.workflowId}])'s step(${node.id})") val step = bluePrintRuntimeService.bluePrintContext().workflowStepByName(this.workflowName, node.id) checkNotEmpty(step.target) { "couldn't get step target for workflow(${this.workflowName})'s step(${node.id})" } val nodeTemplateName = step.target!! /** execute node template */ val executionServiceOutput = nodeTemplateExecutionService - .executeNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeInput) + .executeNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeInput) return when (executionServiceOutput.status.message) { BluePrintConstants.STATUS_FAILURE -> EdgeLabel.FAILURE @@ -135,18 +151,27 @@ open class ImperativeBluePrintWorkflowService(private val nodeTemplateExecutionS } } - override suspend fun skipNode(node: Graph.Node, nodeInput: ExecutionServiceInput, - nodeOutput: ExecutionServiceOutput): EdgeLabel { + override suspend fun skipNode( + node: Graph.Node, + nodeInput: ExecutionServiceInput, + nodeOutput: ExecutionServiceOutput + ): EdgeLabel { return EdgeLabel.SUCCESS } - override suspend fun cancelNode(node: Graph.Node, nodeInput: ExecutionServiceInput, - nodeOutput: ExecutionServiceOutput): EdgeLabel { + override suspend fun cancelNode( + node: Graph.Node, + nodeInput: ExecutionServiceInput, + nodeOutput: ExecutionServiceOutput + ): EdgeLabel { TODO("not implemented") } - override suspend fun restartNode(node: Graph.Node, nodeInput: ExecutionServiceInput, - nodeOutput: ExecutionServiceOutput): EdgeLabel { + override suspend fun restartNode( + node: Graph.Node, + nodeInput: ExecutionServiceInput, + nodeOutput: ExecutionServiceOutput + ): EdgeLabel { TODO("not implemented") } -} \ No newline at end of file +}