diff options
author | 2019-03-27 13:22:51 -0400 | |
---|---|---|
committer | 2019-04-01 10:43:53 -0400 | |
commit | 40072d3dcc1d0193bba1ea9432c13ac24857be55 (patch) | |
tree | 2fe78015e772c4cbab4fd52184530b9e52c8c3af /ms/blueprintsprocessor/functions/python-executor/src/main | |
parent | 38300292cbce3bb0500593f3cc44fe129cf5c877 (diff) |
Improve function interfaces
Change-Id: I24f45d39ac05491a4217101e00bcbf8d122e4e1a
Issue-ID: CCSDK-1137
Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/python-executor/src/main')
2 files changed, 51 insertions, 19 deletions
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt index 527f9dcc0..0a0c0bdf9 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt @@ -24,6 +24,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInpu import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.BlueprintJythonService import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts.PythonExecutorConstants +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmptyOrThrow import org.onap.ccsdk.cds.controllerblueprints.core.data.OperationAssignment @@ -40,24 +41,22 @@ open class ComponentJythonExecutor(private var applicationContext: ApplicationCo private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java) - private var componentFunction: AbstractComponentFunction? = null + private lateinit var componentFunction: JythonComponentFunction - override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput { - val request = super.prepareRequest(executionRequest) + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + + log.info("Processing : $operationInputs") // Populate Component Instance populateJythonComponentInstance() - return request - } - override fun process(executionRequest: ExecutionServiceInput) { - log.info("Processing : $operationInputs") // Invoke Jython Component Script - componentFunction!!.process(executionServiceInput) + componentFunction.executeScript(executionServiceInput) } - override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - componentFunction!!.recover(runtimeException, executionRequest) + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + bluePrintRuntimeService.getBluePrintError() + .addError("Failed in ComponentJythonExecutor : ${runtimeException.message}") } private fun populateJythonComponentInstance() { @@ -92,14 +91,14 @@ open class ComponentJythonExecutor(private var applicationContext: ApplicationCo } // Setup componentFunction - componentFunction = blueprintJythonService.jythonInstance(bluePrintContext, pythonClassName, - content!!, jythonInstance) - componentFunction?.bluePrintRuntimeService = bluePrintRuntimeService - componentFunction?.executionServiceInput = executionServiceInput - componentFunction?.stepName = stepName - componentFunction?.interfaceName = interfaceName - componentFunction?.operationName = operationName - componentFunction?.processId = processId - componentFunction?.workflowName = workflowName + componentFunction = blueprintJythonService.jythonInstance(bluePrintContext, pythonClassName, content!!, jythonInstance) + componentFunction.bluePrintRuntimeService = bluePrintRuntimeService + componentFunction.executionServiceInput = executionServiceInput + componentFunction.stepName = stepName + componentFunction.interfaceName = interfaceName + componentFunction.operationName = operationName + componentFunction.processId = processId + componentFunction.workflowName = workflowName + componentFunction.scriptType = BluePrintConstants.SCRIPT_JYTHON } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/JythonComponentFunction.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/JythonComponentFunction.kt new file mode 100644 index 000000000..7e00206ca --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/JythonComponentFunction.kt @@ -0,0 +1,33 @@ +/* + * 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. + * 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.cds.blueprintsprocessor.functions.python.executor + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException + +open class JythonComponentFunction : AbstractScriptComponentFunction() { + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + throw BluePrintException("Not Implemented required") + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + throw BluePrintException("Not Implemented required") + } + +}
\ No newline at end of file |