import kotlinx.coroutines.channels.actor
import kotlinx.coroutines.channels.consumeEach
import kotlinx.coroutines.launch
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel
import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeStatus
import org.onap.ccsdk.cds.controllerblueprints.core.data.Graph
import org.onap.ccsdk.cds.controllerblueprints.core.startNodes
import kotlin.coroutines.CoroutineContext
-interface BlueprintWorkFlowService<In, Out> {
+interface BluePrintWorkFlowService<In, Out> {
/** Executes imperative workflow graph [graph] for the bluePrintRuntimeService [bluePrintRuntimeService]
* and workflow input [input]*/
- suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BlueprintRuntimeService<*>, input: In): Out
+ suspend fun executeWorkflow(graph: Graph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: In): Out
suspend fun initializeWorkflow(input: In): EdgeLabel
}
/** Abstract workflow service implementation */
-abstract class AbstractBlueprintWorkFlowService<In, Out> : CoroutineScope, BlueprintWorkFlowService<In, Out> {
+abstract class AbstractBluePrintWorkFlowService<In, Out> : CoroutineScope, BluePrintWorkFlowService<In, Out> {
lateinit var graph: Graph
- private val log = logger(AbstractBlueprintWorkFlowService::class)
+ private val log = logger(AbstractBluePrintWorkFlowService::class)
private val job = Job()
// Wait for workflow completion or Error
nodeActor.invokeOnClose { exception ->
launch {
- if (exception != null) exceptions.add(BlueprintProcessorException(exception))
+ if (exception != null) exceptions.add(BluePrintProcessorException(exception))
log.info("workflow($workflowId) nodes completed with (${exceptions.size})exceptions")
val workflowOutput = prepareWorkflowOutput()
workflowExecuteMessage.output.complete(workflowOutput)
suspend fun executeNodeWorker(message: NodeExecuteMessage<In, Out>) {
val node = message.node
node.status = NodeStatus.EXECUTING
- val nodeState = if (node.id == BlueprintConstants.GRAPH_START_NODE_NAME ||
- node.id == BlueprintConstants.GRAPH_END_NODE_NAME
+ val nodeState = if (node.id == BluePrintConstants.GRAPH_START_NODE_NAME ||
+ node.id == BluePrintConstants.GRAPH_END_NODE_NAME
) {
EdgeLabel.SUCCESS
} else {
// Close the current channel
channel.close()
} else if (!edgePresent) {
- throw BlueprintProcessorException("node(${node.id}) outgoing edge($nodeState) is missing.")
+ throw BluePrintProcessorException("node(${node.id}) outgoing edge($nodeState) is missing.")
} else {
val skippingEdges = graph.outgoingEdgesNotInLabels(node.id, arrayListOf(nodeState))
log.debug("Skipping node($node)'s outgoing edges($skippingEdges)")