aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2022-05-23 16:21:40 +0000
committerGerrit Code Review <gerrit@onap.org>2022-05-23 16:21:40 +0000
commit009c9b41e3219bbf889ba040e95d397eebb25d2e (patch)
tree8e86555a2d4ec354e153878f96fe258b327b3100 /ms
parentb4cbb0ee94eb086a2355998189bd94fedc503c79 (diff)
parentdab10311925fe9603e0750a29e566f5e45c2e567 (diff)
Merge "Enable force-resolution"
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt24
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt8
4 files changed, 28 insertions, 7 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
index 0435d1d2c..e060cdcc5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -63,6 +63,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
val resolutionKey =
getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY)?.returnNullIfMissing()?.textValue() ?: ""
val storeResult = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)?.asBoolean() ?: false
+ val forceResolution = getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION)?.asBoolean() ?: false
val resourceId =
getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID)?.returnNullIfMissing()?.textValue() ?: ""
@@ -73,6 +74,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
val properties: MutableMap<String, Any> = mutableMapOf()
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = storeResult
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION] = forceResolution
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY] = resolutionKey
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] = resourceId
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] = resourceType
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index e2a8920f5..9f22b8134 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -27,6 +27,7 @@ object ResourceResolutionConstants {
const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
const val RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY = "resolution-key"
const val RESOURCE_RESOLUTION_INPUT_STORE_RESULT = "store-result"
+ const val RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION = "force-resolution"
const val RESOURCE_RESOLUTION_INPUT_OCCURRENCE = "occurrence"
const val RESOURCE_RESOLUTION_INPUT_RESOURCE_ID = "resource-id"
const val RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE = "resource-type"
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 df07b8e03..8923a1143 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
@@ -199,6 +199,7 @@ open class ResourceResolutionServiceImpl(
val artifactTemplate = "$artifactPrefix-template"
// Resource Assignment Artifact Definition Name
val artifactMapping = "$artifactPrefix-mapping"
+ val forceResolution = isForceResolution(properties)
log.info("Resolving resource with resource assignment artifact($artifactMapping)")
@@ -213,10 +214,16 @@ open class ResourceResolutionServiceImpl(
if (isToStore(properties)) {
val existingResourceResolution = isNewResolution(bluePrintRuntimeService, properties, artifactPrefix)
if (existingResourceResolution.isNotEmpty()) {
- updateResourceAssignmentWithExisting(
- bluePrintRuntimeService as ResourceAssignmentRuntimeService,
- existingResourceResolution, resourceAssignments
- )
+ if (forceResolution) {
+ resourceResolutionDBService.deleteResourceResolutionList(existingResourceResolution)
+ log.info("Force resolution is enabled - will resolve all resources.")
+ } else {
+ updateResourceAssignmentWithExisting(
+ bluePrintRuntimeService as ResourceAssignmentRuntimeService,
+ existingResourceResolution, resourceAssignments
+ )
+ log.info("Force resolution is disabled - will resolve all resources not already resolved.")
+ }
}
}
@@ -407,6 +414,10 @@ open class ResourceResolutionServiceImpl(
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean
}
+ private fun isForceResolution(properties: Map<String, Any>): Boolean =
+ properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION) &&
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_FORCE_RESOLUTION] as Boolean
+
// Check whether resolution already exist in the database for the specified resolution-key or resourceId/resourceType
private suspend fun isNewResolution(
bluePrintRuntimeService: BluePrintRuntimeService<*>,
@@ -428,7 +439,7 @@ open class ResourceResolutionServiceImpl(
)
if (existingResourceAssignments.isNotEmpty()) {
log.info(
- "Resolution with resolutionKey=($resolutionKey) already exist - will resolve all resources not already resolved.",
+ "Resolution with resolutionKey=($resolutionKey) already exist",
resolutionKey
)
}
@@ -445,8 +456,7 @@ open class ResourceResolutionServiceImpl(
)
if (existingResourceAssignments.isNotEmpty()) {
log.info(
- "Resolution with resourceId=($resourceId) and resourceType=($resourceType) already " +
- "exist - will resolve all resources not already resolved."
+ "Resolution with resourceId=($resourceId) and resourceType=($resourceType) already exist"
)
}
return existingResourceAssignments
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
index bfe9da35c..b5d4e4515 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
@@ -221,4 +221,12 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
resolutionKey
)
}
+
+ suspend fun deleteResourceResolutionList(listResourceResolution: List<ResourceResolution>) = withContext(Dispatchers.IO) {
+ try {
+ resourceResolutionRepository.deleteInBatch(listResourceResolution)
+ } catch (ex: Exception) {
+ throw BluePrintException("Failed to batch delete resource resolution", ex)
+ }
+ }
}