Fix: Run both sonar and clm scans in parallel
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / resource-resolution / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / resource / resolution / ResourceAssignmentRuntimeService.kt
index 3a3750a..1710c48 100644 (file)
@@ -4,12 +4,13 @@ import com.fasterxml.jackson.databind.JsonNode
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
 import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
+import java.util.concurrent.ConcurrentHashMap
 
-class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext)
-    DefaultBluePrintRuntimeService(id, bluePrintContext) {
+class ResourceAssignmentRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) :
+    DefaultBluePrintRuntimeService(id, bluePrintContext) {
 
     private lateinit var resolutionId: String
-    private var resourceStore: MutableMap<String, JsonNode> = hashMapOf()
+    private var resourceStore: MutableMap<String, JsonNode> = ConcurrentHashMap()
 
     fun createUniqueId(key: String) {
         resolutionId = "$id-$key"
@@ -23,9 +24,13 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
         resourceStore[key] = value
     }
 
+    fun getResolutionStore(): MutableMap<String, JsonNode> {
+        return resourceStore.mapValues { e -> e.value.deepCopy() as JsonNode }.toMutableMap()
+    }
+
     fun getResolutionStore(key: String): JsonNode {
         return resourceStore[key]
-                ?: throw BluePrintProcessorException("failed to get execution property ($key)")
+            ?: throw BluePrintProcessorException("failed to get execution property ($key)")
     }
 
     fun checkResolutionStore(key: String): Boolean {
@@ -58,7 +63,7 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
 
     fun getDictionaryStore(key: String): JsonNode {
         return resourceStore["dictionary-$key"]
-                ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
+            ?: throw BluePrintProcessorException("failed to get execution property (dictionary-$key)")
     }
 
     fun checkDictionaryStore(key: String): Boolean {
@@ -84,5 +89,4 @@ class ResourceAssignmentRuntimeService(private var id: String, private var blueP
     fun getDoubleFromDictionaryStore(key: String): Double? {
         return getResolutionStore("dictionary-$key").asDouble()
     }
-
 }