lateinit var applicationContext: ApplicationContext
fun populateJythonComponentInstance(executionServiceInput: ExecutionServiceInput) {
- val bluePrintContext = bluePrintRuntimeService!!.bluePrintContext()
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val operationAssignment: OperationAssignment = bluePrintContext
.nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
val artifactName: String = operationAssignment.implementation?.primary
?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
- val artifactDefinition = bluePrintRuntimeService!!.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
+ val artifactDefinition = bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
val pythonFileName = artifactDefinition.file
?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
- val content: String? = bluePrintRuntimeService!!.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
+ val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
checkNotEmptyNThrow(content, "artifact ($artifactName) content is empty")
override fun process(executionServiceInput: ExecutionServiceInput) {
- log.info("Processing : ${operationInputs}")
+ log.info("Processing : $operationInputs")
checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
// Populate Component Instance
val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)\r
\r
val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)\r
- ?: throw BluePrintProcessorException("coundn't transform ${artifactPrefixNamesNode.asText()} to string array")\r
+ ?: throw BluePrintProcessorException("couldn't transform ${artifactPrefixNamesNode.asText()} to string array")\r
\r
- val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService!!, nodeTemplateName, artifactPrefixNames)\r
+ val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactPrefixNames)\r
\r
// Set Output Attributes\r
- bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,\r
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,\r
ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, resolvedParamContents.asJsonNode())\r
}\r
\r
open fun resourceDefinition(name: String): ResourceDefinition {
- return resourceDictionaries.get(name)
+ return resourceDictionaries[name]
?: throw BluePrintProcessorException("couldn't get resource definition($name)")
}
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api;\r
-\r
-import io.swagger.annotations.ApiOperation;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput;\r
-import org.springframework.http.MediaType;\r
-import org.springframework.web.bind.annotation.*;\r
-import reactor.core.publisher.Mono;\r
-\r
-/**\r
- * ExecutionServiceController\r
- *\r
- * @author Brinda Santh 8/14/2018\r
- */\r
-@RestController\r
-@RequestMapping("/api/v1/execution-service")\r
-public class ExecutionServiceController {\r
-\r
-\r
- @RequestMapping(path = "/ping", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)\r
- public @ResponseBody\r
- Mono<String> ping() {\r
- return Mono.just("Success");\r
- }\r
-\r
- @RequestMapping(path = "/process", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)\r
- @ApiOperation(value = "Resolve Resource Mappings",\r
- notes = "Takes the blueprint information and process as per the payload")\r
- public @ResponseBody\r
- Mono<ExecutionServiceOutput> process(@RequestBody ExecutionServiceInput executionServiceInput) {\r
- return Mono.just(new ExecutionServiceOutput());\r
- }\r
-}\r
import org.springframework.stereotype.Service
@Service
-class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration)
+class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
+ private val executionServiceHandler: ExecutionServiceHandler)
: BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
override fun process(request: ExecutionServiceInput,
responseObserver: StreamObserver<ExecutionServiceOutput>) {
- val json = JsonFormat.printer().print(request)
-
+ //val json = JsonFormat.printer().print(request)
//log.info("Received GRPC request ${json}")
//TODO( Handle Processing Response")
val response = ExecutionServiceOutput.newBuilder().setCommonHeader(request.commonHeader).build()
--- /dev/null
+/*
+ * 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.selfservice.api
+
+import io.swagger.annotations.ApiOperation
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.*
+import reactor.core.publisher.Mono
+
+@RestController
+@RequestMapping("/api/v1/execution-service")
+class ExecutionServiceController {
+
+ @Autowired
+ lateinit var executionServiceHandler: ExecutionServiceHandler
+
+
+ @RequestMapping(path = arrayOf("/ping"), method = arrayOf(RequestMethod.GET), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ @ResponseBody
+ fun ping(): Mono<String> {
+ return Mono.just("Success")
+ }
+
+ @RequestMapping(path = arrayOf("/process"), method = arrayOf(RequestMethod.POST), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE))
+ @ApiOperation(value = "Resolve Resource Mappings", notes = "Takes the blueprint information and process as per the payload")
+ @ResponseBody
+ fun process(@RequestBody executionServiceInput: ExecutionServiceInput): Mono<ExecutionServiceOutput> {
+ val executionServiceOutput = executionServiceHandler.process(executionServiceInput)
+ return Mono.just(executionServiceOutput)
+ }
+}
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockBluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockBlueprintDGExecutionService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.processing.api.CommonHeader
import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.CommonHeader
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintProcessingGRPCHandler::class, BluePrintCoreConfiguration::class])
+@ContextConfiguration(classes = [BluePrintProcessingGRPCHandler::class, ExecutionServiceHandler::class,
+ MockBlueprintDGExecutionService::class, MockBluePrintCatalogService::class,
+ BluePrintCoreConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class BluePrintProcessingGRPCHandlerTest {
@Transient\r
private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)\r
\r
- var executionServiceInput: ExecutionServiceInput? = null\r
+ lateinit var executionServiceInput: ExecutionServiceInput\r
var executionServiceOutput = ExecutionServiceOutput()\r
- var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null\r
- var processId: String = ""\r
- var workflowName: String = ""\r
- var stepName: String = ""\r
- var interfaceName: String = ""\r
- var operationName: String = ""\r
- var nodeTemplateName: String = ""\r
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>\r
+ lateinit var processId: String\r
+ lateinit var workflowName: String\r
+ lateinit var stepName: String\r
+ lateinit var interfaceName: String\r
+ lateinit var operationName: String\r
+ lateinit var nodeTemplateName: String\r
var operationInputs: MutableMap<String, JsonNode> = hashMapOf()\r
\r
override fun getName(): String {\r
\r
log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")\r
\r
- val operationInputs = bluePrintRuntimeService!!.get("$stepName-step-inputs")\r
+ val operationInputs = bluePrintRuntimeService.get("$stepName-step-inputs")\r
?: JsonNodeFactory.instance.objectNode()\r
\r
operationInputs.fields().forEach {\r
operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }\r
\r
-\r
- val operationResolvedProperties = bluePrintRuntimeService!!.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)\r
+ val operationResolvedProperties = bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)\r
\r
this.operationInputs.putAll(operationResolvedProperties)\r
\r
\r
override fun prepareResponse(): ExecutionServiceOutput {\r
log.info("Preparing Response...")\r
- executionServiceOutput.commonHeader = executionServiceInput!!.commonHeader\r
+ executionServiceOutput.commonHeader = executionServiceInput.commonHeader\r
\r
// Resolve the Output Expression\r
- val stepOutputs = bluePrintRuntimeService!!\r
+ val stepOutputs = bluePrintRuntimeService\r
.resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)\r
\r
- bluePrintRuntimeService!!.put("$stepName-step-outputs", stepOutputs.asJsonNode())\r
+ bluePrintRuntimeService.put("$stepName-step-outputs", stepOutputs.asJsonNode())\r
\r
// Populate Status\r
val status = Status()\r
}
@Service
-class DefaultBlueprintDGExecutionService(val blueprintSvcLogicService: BlueprintSvcLogicService) : BlueprintDGExecutionService {
+class DefaultBlueprintDGExecutionService(private val blueprintSvcLogicService: BlueprintSvcLogicService) : BlueprintDGExecutionService {
private val log = LoggerFactory.getLogger(DefaultBlueprintDGExecutionService::class.java)
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.sli.core.sli.*
-import org.onap.ccsdk.sli.core.sli.provider.*
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker
+import org.onap.ccsdk.sli.core.sli.provider.base.*
import org.slf4j.LoggerFactory
import org.slf4j.MDC
import org.springframework.beans.factory.annotation.Autowired
import java.util.*
import javax.annotation.PostConstruct
-interface BlueprintSvcLogicService : SvcLogicService {
+interface BlueprintSvcLogicService : SvcLogicServiceBase {
fun registerDefaultExecutors()
- fun registerExecutors(name: String, svcLogicNodeExecutor: SvcLogicNodeExecutor)
+ fun registerExecutors(name: String, svcLogicNodeExecutor: AbstractSvcLogicNodeExecutor)
fun unRegisterExecutors(name: String)
override fun execute(p0: String?, p1: String?, p2: String?, p3: String?, p4: Properties?): Properties {
TODO("not implemented")
}
-
- @Deprecated("Not used in Micro service Implementation")
- override fun execute(p0: String?, p1: String?, p2: String?, p3: String?, p4: Properties?, p5: DOMDataBroker?): Properties {
- TODO("not implemented")
- }
}
private val log = LoggerFactory.getLogger(DefaultBlueprintSvcLogicService::class.java)
- private val nodeExecutors: MutableMap<String, SvcLogicNodeExecutor> = hashMapOf()
+ private val nodeExecutors: MutableMap<String, AbstractSvcLogicNodeExecutor> = hashMapOf()
@Autowired
private lateinit var context: ApplicationContext
registerExecutors("exit", ExitNodeExecutor())
}
- override fun registerExecutors(name: String, svcLogicNodeExecutor: SvcLogicNodeExecutor) {
+ override fun registerExecutors(name: String, svcLogicNodeExecutor: AbstractSvcLogicNodeExecutor) {
log.info("Registering executors($name) with type(${svcLogicNodeExecutor.javaClass}")
- nodeExecutors.put(name, svcLogicNodeExecutor)
+ nodeExecutors[name] = svcLogicNodeExecutor
}
override fun unRegisterExecutors(name: String) {
if (node == null) {
return null
} else {
- if (log.isDebugEnabled()) {
- log.debug("Executing node {}", node.getNodeId())
+ if (log.isDebugEnabled) {
+ log.debug("Executing node {}", node.nodeId)
}
- val executor = this.nodeExecutors[node.getNodeType()]
+ val executor = this.nodeExecutors[node.nodeType]
if (executor != null) {
- log.debug("Executing node executor for node type {} - {}", node.getNodeType(), executor.javaClass.name)
+ log.debug("Executing node executor for node type {} - {}", node.nodeType, executor.javaClass.name)
return executor.execute(this, node, ctx)
} else {
- throw SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type")
+ throw SvcLogicException("Attempted to execute a node of type " + node.nodeType + ", but no executor was registered for this type")
}
}
}
override fun execute(graph: SvcLogicGraph, svcLogicContext: SvcLogicContext): SvcLogicContext {
MDC.put("currentGraph", graph.toString())
- var curNode: SvcLogicNode? = graph.getRootNode()
+ var curNode: SvcLogicNode? = graph.rootNode
log.info("About to execute graph {}", graph.toString())
try {
package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor
import com.fasterxml.jackson.databind.JsonNode
+import kotlinx.coroutines.async
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext
import org.onap.ccsdk.sli.core.sli.SvcLogicContext
import org.onap.ccsdk.sli.core.sli.SvcLogicException
import org.onap.ccsdk.sli.core.sli.SvcLogicNode
-import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor
-import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver
-import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService
+import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicExpressionResolver
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
}
@Throws(SvcLogicException::class)
- override fun execute(svc: SvcLogicService, node: SvcLogicNode, svcLogicContext: SvcLogicContext): SvcLogicNode {
+ override fun execute(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext)
+ : SvcLogicNode = runBlocking {
+ coroutineScope {
+ val job = async { executeAsy(svc, node, svcLogicContext) }
+ job.await()
+ }
+ }
+
+
+ private fun executeAsy(svc: SvcLogicServiceBase, node: SvcLogicNode, svcLogicContext: SvcLogicContext): SvcLogicNode {
var outValue: String
stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
- plugin.bluePrintRuntimeService!!.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
+ plugin.bluePrintRuntimeService.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
// Get the Request from the Context and Set to the Function Input and Invoke the function
val executionOutput = plugin.apply(executionInput)
private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
override fun process(executionRequest: ExecutionServiceInput) {
- log.info("Processing component : ${operationInputs}")
+ log.info("Processing component : $operationInputs")
- bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
"assignment-params", "params".asJsonPrimitive())
}
private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
override fun process(executionRequest: ExecutionServiceInput) {
- log.info("Processing component : ${operationInputs}")
+ log.info("Processing component : $operationInputs")
}
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
override fun process(executionRequest: ExecutionServiceInput) {
- log.info("Processing component : ${operationInputs}")
+ log.info("Processing component : $operationInputs")
}
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
<!-- encoders are assigned the type\r
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
<encoder>\r
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>\r
</encoder>\r
</appender>\r
\r
<grpc.version>1.16.1</grpc.version>
<protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
<eelf.version>1.0.0</eelf.version>
- <sli.version>0.3.1</sli.version>
+ <sli.version>0.4.0-SNAPSHOT</sli.version>
<guava.version>26.0-jre</guava.version>
<jython.version>2.7.1</jython.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>*</artifactId>
</exclusion>
- <!--<exclusion>-->
- <!--<groupId>org.opendaylight.controller</groupId>-->
- <!--<artifactId>*</artifactId>-->
- <!--</exclusion>-->
+ <exclusion>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>*</artifactId>