aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-11-15 13:12:09 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-11-15 13:12:09 -0500
commit13f780024e7ca0943f5409691fafbd503c26d837 (patch)
tree8a826a788d3ce0fdc65a151c09cedae4db2fa840 /ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin
parentec92866fa0bc8d8cd7a6ce4d5d5fd014d8eacef1 (diff)
Blueprints Processor Microservice
Implement Resource Resolution Processor Interface definitions. Change-Id: Ic2eb7915d48b9473639494ee9d159003bf56e81e Issue-ID: CCSDK-724 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt37
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt25
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt34
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt)23
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt18
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt18
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt)21
7 files changed, 79 insertions, 97 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
index ff1a01d5..a485fa62 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
@@ -1,39 +1,32 @@
/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * 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
+ * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.springframework.stereotype.Component
@Component("component-resource-resolution")
-open class ResourceResolutionComponent : ComponentNode {
- override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+open class ResourceResolutionComponent : AbstractComponentFunction() {
+ override fun process(executionRequest: ExecutionServiceInput) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
- override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt
new file mode 100644
index 00000000..e234d056
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+
+class ResourceResolutionConstants {
+ companion object {
+ const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
index 3ee7e41f..155b3b03 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
@@ -20,10 +20,12 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
/**
@@ -33,7 +35,11 @@ import org.springframework.stereotype.Service
*/
@Service
-class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {
+class ResourceResolutionService {
+
+
+ @Autowired
+ private lateinit var applicationContext: ApplicationContext
fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
val resourceResolutionOutput = ResourceResolutionOutput()
@@ -43,7 +49,7 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory:
val context = hashMapOf<String, Any>()
- process(resourceResolutionOutput.resourceAssignments, context)
+ process(resourceResolutionOutput.resourceAssignments)
val status = Status()
status.code = 200
@@ -53,7 +59,13 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory:
return resourceResolutionOutput
}
- fun process(resourceAssignments: MutableList<ResourceAssignment>, context: MutableMap<String, Any>): Unit {
+ fun registeredResourceSources(): List<String> {
+ return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ }
+
+ fun process(resourceAssignments: MutableList<ResourceAssignment>) {
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
@@ -61,18 +73,18 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory:
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
.map { resourceAssignment ->
val dictionarySource = resourceAssignment.dictionarySource
- val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource)
- val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName)
+ val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)
+
+ val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor
?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
"for resource assignment(${resourceAssignment.name})")
try {
- resourceAssignmentProcessor.validate(resourceAssignment, context)
- resourceAssignmentProcessor.process(resourceAssignment, context)
- } catch (e: Exception) {
- resourceAssignmentProcessor.errorHandle(resourceAssignment, context)
+ // Invoke Apply Method
+ resourceAssignmentProcessor.apply(resourceAssignment)
+ } catch (e: RuntimeException) {
+ resourceAssignmentProcessor.recover(e, resourceAssignment)
throw BluePrintProcessorException(e)
}
-
}
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt
index 4b11f580..66e43f1b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2018 IBM.
+ * Modifications 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.
@@ -16,35 +17,21 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
-import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
- * SdncResourceAssignmentProcessor
+ * DataBaseResourceAssignmentProcessor
*
* @author Brinda Santh
*/
@Service("resource-assignment-processor-db")
-open class SdncResourceAssignmentProcessor : ResourceAssignmentProcessor {
+open class DataBaseResourceAssignmentProcessor : ResourceAssignmentProcessor(){
- private val log = EELFManager.getInstance().getLogger(SdncResourceAssignmentProcessor::class.java)
-
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Validation Resource Assignments")
- }
-
- override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Processing Resource Assignments")
+ override fun process(executionRequest: ResourceAssignment) {
}
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("ErrorHandle Resource Assignments")
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
}
-
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Re Trigger Resource Assignments")
- }
-
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
index 9580ca49..e701e718 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
@@ -17,7 +17,6 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
-import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
@@ -28,22 +27,11 @@ import org.springframework.stereotype.Service
* @author Brinda Santh
*/
@Service("resource-assignment-processor-default")
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor {
- private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java)
+open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Validation Resource Assignments")
+ override fun process(executionRequest: ResourceAssignment) {
}
- override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Processing Resource Assignments")
- }
-
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("ErrorHandle Resource Assignments")
- }
-
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Re Trigger Resource Assignments")
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
index 05f7d5cd..9e177d46 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
@@ -17,7 +17,6 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
-import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
@@ -28,22 +27,11 @@ import org.springframework.stereotype.Service
* @author Brinda Santh
*/
@Service("resource-assignment-processor-input")
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor {
- private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java)
+open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Validation Resource Assignments")
+ override fun process(executionRequest: ResourceAssignment) {
}
- override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Processing Resource Assignments")
- }
-
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("ErrorHandle Resource Assignments")
- }
-
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Re Trigger Resource Assignments")
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
index 9d54cd46..e1b9a8ef 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2018 IBM.
+ * Modifications 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.
@@ -16,33 +17,21 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
-import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
- * MDSALResourceAssignmentProcessor
+ * SimpleRestResourceAssignmentProcessor
*
* @author Brinda Santh
*/
@Service("resource-assignment-processor-mdsal")
-open class MDSALResourceAssignmentProcessor : ResourceAssignmentProcessor {
- private val log = EELFManager.getInstance().getLogger(MDSALResourceAssignmentProcessor::class.java)
+open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() {
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Validation Resource Assignments")
+ override fun process(executionRequest: ResourceAssignment) {
}
- override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Processing Resource Assignments")
- }
-
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("ErrorHandle Resource Assignments")
- }
-
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Re Trigger Resource Assignments")
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
}
} \ No newline at end of file