Improve bulk processing

Change-Id: Ia8bd447563072284aa71e00eab0ef9b93e1776b1
Issue-ID: CCSDK-1127
Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
diff --git a/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties b/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties
index 7ed4cc9..fc148bf 100755
--- a/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties
+++ b/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties
@@ -20,7 +20,7 @@
 # Web server config

 server.port=8080

 

-blueprintsprocessor.grpcEnable=true

+blueprintsprocessor.grpcEnable=false

 blueprintsprocessor.httpPort=8080

 blueprintsprocessor.grpcPort=9111

 

diff --git a/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml
index 0c8d93b..16e7d3d 100644
--- a/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml
+++ b/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml
@@ -19,7 +19,7 @@
         <!-- encoders are assigned the type

              ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->

         <encoder>

-            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>

+            <pattern>%d{HH:mm:ss.SSS} %-5level [%thread]  %logger{50} - %msg%n</pattern>

         </encoder>

     </appender>

 

diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
index 4b08ce8..be7451a 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2018-2019 IBM, Bell Canada.
+ *  Modifications Copyright © 2019 IBM.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -17,6 +18,7 @@
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor
 
 import com.fasterxml.jackson.databind.JsonNode
+import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
@@ -38,17 +40,17 @@
         return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
     }
 
-    fun resolveFromDatabase(resolutionKey: String, artifactName: String): String {
-        return resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
+    fun resolveFromDatabase(resolutionKey: String, artifactName: String): String = runBlocking {
+        resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
     }
 
-    fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String {
-        return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
+    fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String = runBlocking {
+        resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
                 artifactMapping, artifactTemplate)
     }
 
-    fun resolveAndGenerateMessage(artifactPrefix: String): String {
-        return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
+    fun resolveAndGenerateMessage(artifactPrefix: String): String = runBlocking {
+        resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
                 artifactPrefix, mapOf())
     }
 
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index dad8046..8a14ded 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -1,6 +1,6 @@
 /*
  *  Copyright © 2017-2018 AT&T Intellectual Property.
- *  Modifications Copyright © 2018 IBM.
+ *  Modifications Copyright © 2018-2019 IBM.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -17,7 +17,9 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
 
-import kotlinx.coroutines.runBlocking
+import kotlinx.coroutines.async
+import kotlinx.coroutines.awaitAll
+import kotlinx.coroutines.coroutineScope
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionResultService
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
@@ -39,22 +41,22 @@
 
     fun registeredResourceSources(): List<String>
 
-    fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
-                            resolutionKey: String): String
+    suspend fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
+                                    resolutionKey: String): String
 
-    fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
-                         artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
+    suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+                                 artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
 
-    fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
-                         artifactPrefix: String, properties: Map<String, Any>): String
+    suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+                                 artifactPrefix: String, properties: Map<String, Any>): String
 
-    fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
-                         artifactMapping: String, artifactTemplate: String?): String
+    suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+                                 artifactMapping: String, artifactTemplate: String?): String
 
-    fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
-                                   resourceDictionaries: MutableMap<String, ResourceDefinition>,
-                                   resourceAssignments: MutableList<ResourceAssignment>,
-                                   identifierName: String)
+    suspend fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
+                                           resourceDictionaries: MutableMap<String, ResourceDefinition>,
+                                           resourceAssignments: MutableList<ResourceAssignment>,
+                                           identifierName: String)
 }
 
 @Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
@@ -70,9 +72,15 @@
                 .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
     }
 
-    override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
-                                  artifactNames: List<String>,
-                                  properties: Map<String, Any>): MutableMap<String, String> {
+    override suspend fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+                                             artifactTemplate: String,
+                                             resolutionKey: String): String {
+        return resolutionResultService.read(bluePrintRuntimeService, artifactTemplate, resolutionKey)
+    }
+
+    override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+                                          artifactNames: List<String>,
+                                          properties: Map<String, Any>): MutableMap<String, String> {
 
         val resolvedParams: MutableMap<String, String> = hashMapOf()
         artifactNames.forEach { artifactName ->
@@ -82,8 +90,8 @@
         return resolvedParams
     }
 
-    override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
-                                  artifactPrefix: String, properties: Map<String, Any>): String {
+    override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+                                          artifactPrefix: String, properties: Map<String, Any>): String {
 
         // Velocity Artifact Definition Name
         val artifactTemplate = "$artifactPrefix-template"
@@ -95,20 +103,17 @@
         if (properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)
                 && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean) {
             resolutionResultService.write(properties, result, bluePrintRuntimeService, artifactPrefix)
+            log.info("resolution saved into database successfully : ($properties)")
         }
 
         return result
     }
 
-    override fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
-                                     resolutionKey: String): String {
-        return resolutionResultService.read(bluePrintRuntimeService, artifactTemplate, resolutionKey)
-    }
 
-    override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
-                                  artifactMapping: String, artifactTemplate: String?): String {
+    override suspend fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+                                          artifactMapping: String, artifactTemplate: String?): String {
 
-        var resolvedContent = ""
+        val resolvedContent: String
         log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
 
         val identifierName = artifactTemplate ?: "no-template"
@@ -128,7 +133,6 @@
 
         val resourceDictionaries: MutableMap<String, ResourceDefinition> =
                 JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
-                        ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
 
         // Resolve resources
         resolveResourceAssignments(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, identifierName)
@@ -153,46 +157,51 @@
      * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
      * request.
      */
-    override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
-                                            resourceDictionaries: MutableMap<String, ResourceDefinition>,
-                                            resourceAssignments: MutableList<ResourceAssignment>,
-                                            identifierName: String) {
+    override suspend fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
+                                                    resourceDictionaries: MutableMap<String, ResourceDefinition>,
+                                                    resourceAssignments: MutableList<ResourceAssignment>,
+                                                    identifierName: String) {
 
         val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
         val resourceAssignmentRuntimeService =
                 ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)
 
-        bulkSequenced.map { batchResourceAssignments ->
-            batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
-                    .forEach { resourceAssignment ->
-                        val dictionaryName = resourceAssignment.dictionaryName
-                        val dictionarySource = resourceAssignment.dictionarySource
-                        /**
-                         * Get the Processor name
-                         */
-                        val processorName = processorName(dictionaryName!!, dictionarySource!!, resourceDictionaries)
+        coroutineScope {
+            bulkSequenced.forEach { batchResourceAssignments ->
+                // Execute Non Dependent Assignments in parallel ( ie asynchronously )
+                val deferred = batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
+                        .map { resourceAssignment ->
+                            async {
+                                val dictionaryName = resourceAssignment.dictionaryName
+                                val dictionarySource = resourceAssignment.dictionarySource
+                                /**
+                                 * Get the Processor name
+                                 */
+                                val processorName = processorName(dictionaryName!!, dictionarySource!!, resourceDictionaries)
 
-                        val resourceAssignmentProcessor =
-                                applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
-                                        ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
-                                                "for resource assignment(${resourceAssignment.name})")
-                        try {
-                            // Set BluePrint Runtime Service
-                            resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
-                            // Set Resource Dictionaries
-                            resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
-                            // TODO ("Implement suspend function")
-                            runBlocking {
-                                // Invoke Apply Method
-                                resourceAssignmentProcessor.applyNB(resourceAssignment)
+                                val resourceAssignmentProcessor =
+                                        applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+                                                ?: throw BluePrintProcessorException("failed to get resource processor ($processorName) " +
+                                                        "for resource assignment(${resourceAssignment.name})")
+                                try {
+                                    // Set BluePrint Runtime Service
+                                    resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+                                    // Set Resource Dictionaries
+                                    resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
+                                    // Invoke Apply Method
+                                    resourceAssignmentProcessor.applyNB(resourceAssignment)
+                                    // Set errors from RA
+                                    blueprintRuntimeService.setBluePrintError(resourceAssignmentRuntimeService.getBluePrintError())
+                                } catch (e: RuntimeException) {
+                                    throw BluePrintProcessorException(e)
+                                }
                             }
-                            // Set errors from RA
-                            blueprintRuntimeService.setBluePrintError(resourceAssignmentRuntimeService.getBluePrintError())
-                        } catch (e: RuntimeException) {
-                            throw BluePrintProcessorException(e)
                         }
-                    }
+                log.debug("Resolving (${deferred.size})resources parallel.")
+                deferred.awaitAll()
+            }
         }
+
     }
 
 
@@ -202,13 +211,12 @@
      */
     private fun processorName(dictionaryName: String, dictionarySource: String,
                               resourceDictionaries: MutableMap<String, ResourceDefinition>): String {
-        var processorName: String? = null
-        when (dictionarySource) {
+        val processorName: String = when (dictionarySource) {
             "input" -> {
-                processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
+                "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
             }
             "default" -> {
-                processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
+                "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
             }
             else -> {
                 val resourceDefinition = resourceDictionaries[dictionaryName]
@@ -217,8 +225,7 @@
                 val resourceSource = resourceDefinition.sources[dictionarySource]
                         ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
 
-                processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
-                        .plus(resourceSource.type)
+                ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR.plus(resourceSource.type)
             }
         }
         checkNotEmptyOrThrow(processorName,
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt
index 225251f..cbc68bb 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2019 Bell Canada.
+ * Modifications Copyright © 2019 IBM.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +16,8 @@
  */
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db
 
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.withContext
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
@@ -26,8 +29,8 @@
 @Service
 class ResourceResolutionResultService(private val resourceResolutionRepository: ResourceResolutionRepository) {
 
-    fun write(properties: Map<String, Any>, result: String, bluePrintRuntimeService: BluePrintRuntimeService<*>,
-              artifactPrefix: String) {
+    suspend fun write(properties: Map<String, Any>, result: String, bluePrintRuntimeService: BluePrintRuntimeService<*>,
+                      artifactPrefix: String) = withContext(Dispatchers.IO) {
 
         val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
 
@@ -37,7 +40,7 @@
         resourceResolutionResult.blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
         resourceResolutionResult.blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
         resourceResolutionResult.resolutionKey =
-            properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY].toString()
+                properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY].toString()
         resourceResolutionResult.result = result
 
         try {
@@ -47,18 +50,18 @@
         }
     }
 
-    fun read(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactPrefix: String,
-             resolutionKey: String): String {
+    suspend fun read(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactPrefix: String,
+                     resolutionKey: String): String = withContext(Dispatchers.IO) {
 
         val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
 
         val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
         val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
 
-        return resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
-            resolutionKey,
-            blueprintName,
-            blueprintVersion,
-            artifactPrefix).result!!
+        resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+                resolutionKey,
+                blueprintName,
+                blueprintVersion,
+                artifactPrefix).result!!
     }
 }
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index 433ee1d..5ad9b3a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -17,6 +17,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution
 
+import kotlinx.coroutines.runBlocking
 import org.junit.Assert
 import org.junit.Test
 import org.junit.runner.RunWith
@@ -72,20 +73,22 @@
     @Test
     @Throws(Exception::class)
     fun testResolveResource() {
+        runBlocking {
 
-        Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+            Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
 
-        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
-                "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+            val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                    "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
 
-        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
-                ExecutionServiceInput::class.java)!!
+            val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+                    ExecutionServiceInput::class.java)!!
 
-        // Prepare Inputs
-        PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+            // Prepare Inputs
+            PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
 
-        resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig", mapOf())
+            resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig", mapOf())
 
+        }
     }
 
 }
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml
index 0c8d93b..c37e0b5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml
@@ -19,13 +19,14 @@
         <!-- encoders are assigned the type

              ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->

         <encoder>

-            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>

+            <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern>

         </encoder>

     </appender>

 

 

     <logger name="org.springframework" level="warn"/>

     <logger name="org.hibernate" level="info"/>

+    <logger name="org.onap.ccsdk.cds.controllerblueprints" level="warn"/>

     <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>

 

     <root level="warn">

diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
index b958792..3895c39 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
@@ -17,6 +17,7 @@
 
 package org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor
 
+import kotlinx.coroutines.runBlocking
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestLibConstants
@@ -38,21 +39,21 @@
         return bluePrintRestLibPropertyService().blueprintWebClientService(selector)
     }
 
-    fun resolveFromDatabase(resolutionKey: String, artifactName: String): String {
-        return resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
+    fun resolveFromDatabase(resolutionKey: String, artifactName: String): String = runBlocking {
+        resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
     }
 
     fun generateMessage(artifactName: String): String {
         return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
     }
 
-    fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String {
-        return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
+    fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String = runBlocking {
+        resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
                 artifactMapping, artifactTemplate)
     }
 
-    fun resolveAndGenerateMessage(artifactPrefix: String): String {
-        return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
+    fun resolveAndGenerateMessage(artifactPrefix: String): String = runBlocking {
+        resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
                 artifactPrefix, mapOf())
     }
 }
\ No newline at end of file
diff --git a/ms/controllerblueprints/application/src/test/resources/logback.xml b/ms/controllerblueprints/application/src/test/resources/logback-test.xml
similarity index 92%
rename from ms/controllerblueprints/application/src/test/resources/logback.xml
rename to ms/controllerblueprints/application/src/test/resources/logback-test.xml
index 55b008d..2252939 100644
--- a/ms/controllerblueprints/application/src/test/resources/logback.xml
+++ b/ms/controllerblueprints/application/src/test/resources/logback-test.xml
@@ -1,35 +1,35 @@
-<!--

-  ~ Copyright © 2017-2018 AT&T Intellectual Property.

-  ~

-  ~ Licensed under the Apache License, Version 2.0 (the "License");

-  ~ you may not use this file except in compliance with the License.

-  ~ You may obtain a copy of the License at

-  ~

-  ~     http://www.apache.org/licenses/LICENSE-2.0

-  ~

-  ~ Unless required by applicable law or agreed to in writing, software

-  ~ distributed under the License is distributed on an "AS IS" BASIS,

-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

-  ~ See the License for the specific language governing permissions and

-  ~ limitations under the License.

-  -->

-

-<configuration>

-    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">

-        <!-- encoders are assigned the type

-             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->

-        <encoder>

-            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>

-        </encoder>

-    </appender>

-

-

-    <logger name="org.springframework" level="warn"/>

-    <logger name="org.hibernate" level="info"/>

-    <logger name="org.onap.ccsdk.cds.controllerblueprints" level="info"/>

-

-    <root level="warn">

-        <appender-ref ref="STDOUT"/>

-    </root>

-

-</configuration>

+<!--
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <!-- encoders are assigned the type
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+
+    <logger name="org.springframework" level="warn"/>
+    <logger name="org.hibernate" level="info"/>
+    <logger name="org.onap.ccsdk.cds.controllerblueprints" level="info"/>
+
+    <root level="warn">
+        <appender-ref ref="STDOUT"/>
+    </root>
+
+</configuration>
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt
index 08b77bd..5da4348 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt
@@ -17,20 +17,22 @@
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
 import org.junit.Test
+import org.slf4j.LoggerFactory
 
 class TopologicalSortingUtilsTest {
-    
+
+    private val log = LoggerFactory.getLogger(TopologicalSortingUtilsTest::class.java)
     @Test
-    fun testSorting(): Unit {
+    fun testSorting() {
         val graph: TopologicalSortingUtils<String> = TopologicalSortingUtils()
         graph.add("bundle-id", "bundle-mac")
         graph.add("bundle-id", "bundle-ip")
         graph.add("bundle-mac", "bundle-ip")
         graph.add("bundle-ip", "bundle-mac")
 
-        println("The current graph: " + graph)
-        println("In-degrees: " + graph.inDegree())
-        println("Out-degrees: " + graph.outDegree())
-        println("A topological sort of the vertices: " + graph.topSort())
+        log.debug("The current graph: $graph")
+        log.debug("In-degrees: " + graph.inDegree())
+        log.debug("Out-degrees: " + graph.outDegree())
+        log.debug("A topological sort of the vertices: " + graph.topSort())
     }
 }
\ No newline at end of file
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/logback-test.xml
similarity index 64%
copy from ms/controllerblueprints/modules/service/src/test/resources/logback.xml
copy to ms/controllerblueprints/modules/blueprint-core/src/test/resources/logback-test.xml
index e661279..83e0bc6 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/logback-test.xml
@@ -1,6 +1,5 @@
 <!--
-  ~  Copyright © 2018 IBM.
-  ~  Modifications Copyright © 2017-2018 AT&T Intellectual Property.
+  ~  Copyright © 2019 IBM.
   ~
   ~  Licensed under the Apache License, Version 2.0 (the "License");
   ~  you may not use this file except in compliance with the License.
@@ -16,24 +15,16 @@
   -->
 
 <configuration>
-
-    <property name="localPattern" value="[%-8thread] %d{HH:mm:ss.SSS} %-5level %logger{50} - %msg%n" />
-
     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
         <!-- encoders are assigned the type
              ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
         <encoder>
-            <pattern>${localPattern}</pattern>
+            <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern>
         </encoder>
     </appender>
 
-
-    <logger name="org.springframework" level="warn"/>
-    <logger name="org.springframework.web" level="warn"/>
-    <logger name="org.hibernate" level="error"/>
-    <logger name="org.onap.ccsdk.cds" level="info"/>
-
-    <root level="warn">
+    <logger name="org.onap.ccsdk.cds.controllerblueprints" level="info"/>
+    <root level="info">
         <appender-ref ref="STDOUT"/>
     </root>
 
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml b/ms/controllerblueprints/modules/service/src/test/resources/logback-test.xml
similarity index 78%
rename from ms/controllerblueprints/modules/service/src/test/resources/logback.xml
rename to ms/controllerblueprints/modules/service/src/test/resources/logback-test.xml
index e661279..feb4514 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml
+++ b/ms/controllerblueprints/modules/service/src/test/resources/logback-test.xml
@@ -17,13 +17,11 @@
 
 <configuration>
 
-    <property name="localPattern" value="[%-8thread] %d{HH:mm:ss.SSS} %-5level %logger{50} - %msg%n" />
-
-    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
         <!-- encoders are assigned the type
              ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
         <encoder>
-            <pattern>${localPattern}</pattern>
+            <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern>
         </encoder>
     </appender>
 
@@ -31,7 +29,8 @@
     <logger name="org.springframework" level="warn"/>
     <logger name="org.springframework.web" level="warn"/>
     <logger name="org.hibernate" level="error"/>
-    <logger name="org.onap.ccsdk.cds" level="info"/>
+    <logger name="org.onap.ccsdk.cds.controllerblueprints.core" level="warn"/>
+    <logger name="org.onap.ccsdk.cds.controllerblueprints" level="info"/>
 
     <root level="warn">
         <appender-ref ref="STDOUT"/>