From 095b4aa10f743b41f2eda31bc57be3657d0868a4 Mon Sep 17 00:00:00 2001 From: Oleg Mitsura Date: Thu, 30 Jan 2020 12:02:46 -0500 Subject: (elAlto) Scheduler for process. Healthcheck not blocked. Issue-ID: CCSDK-2052 Signed-off-by: Oleg Mitsura Change-Id: I7388e593116989e775850922a4ab28a34070da31 --- .../modules/inbounds/configs-api/pom.xml | 4 +- .../modules/inbounds/designer-api/pom.xml | 2 +- ms/blueprintsprocessor/modules/inbounds/pom.xml | 2 +- .../modules/inbounds/resource-api/pom.xml | 2 +- .../modules/inbounds/selfservice-api/pom.xml | 2 +- .../selfservice/api/ExecutionServiceController.kt | 48 +++++++++++++--------- 6 files changed, 34 insertions(+), 26 deletions(-) (limited to 'ms/blueprintsprocessor/modules/inbounds') diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml index 4fd567de4..8026a599e 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml @@ -19,12 +19,12 @@ org.onap.ccsdk.cds.blueprintsprocessor inbounds - 0.6.5-SNAPSHOT + 0.6.6-SNAPSHOT org.onap.ccsdk.cds.blueprintsprocessor configs-api - 0.6.5-SNAPSHOT + 0.6.6-SNAPSHOT jar Blueprints Processor Resource Configurations API Blueprints Processor Resource Configurations API diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml index e9bda82d6..efd052bbe 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/pom.xml @@ -18,7 +18,7 @@ inbounds org.onap.ccsdk.cds.blueprintsprocessor - 0.6.5-SNAPSHOT + 0.6.6-SNAPSHOT 4.0.0 designer-api diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml index fe139128e..46e20d96b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml @@ -20,7 +20,7 @@ org.onap.ccsdk.cds.blueprintsprocessor modules - 0.6.5-SNAPSHOT + 0.6.6-SNAPSHOT inbounds diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml index 8f8d86f2e..5a2994667 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/pom.xml @@ -19,7 +19,7 @@ org.onap.ccsdk.cds.blueprintsprocessor inbounds - 0.6.5-SNAPSHOT + 0.6.6-SNAPSHOT resource-api diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml index 583e179ac..6197770af 100755 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml @@ -22,7 +22,7 @@ org.onap.ccsdk.cds.blueprintsprocessor inbounds - 0.6.5-SNAPSHOT + 0.6.6-SNAPSHOT selfservice-api diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt index cc1229623..0b1fd18d3 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt @@ -35,15 +35,17 @@ import org.springframework.http.ResponseEntity import org.springframework.http.codec.multipart.FilePart import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.* +import reactor.core.publisher.Mono +import reactor.core.scheduler.Schedulers import java.util.concurrent.Phaser import javax.annotation.PreDestroy @RestController @RequestMapping("/api/v1/execution-service") @Api(value = "/api/v1/execution-service", - description = "Interaction with CBA.") + description = "Interaction with CBA.") open class ExecutionServiceController { - + private val scheduler = Schedulers.newElastic("bpthread") private val log = logger(ExecutionServiceController::class) private val ph = Phaser(1) @@ -52,8 +54,8 @@ open class ExecutionServiceController { lateinit var executionServiceHandler: ExecutionServiceHandler @RequestMapping(path = ["/health-check"], - method = [RequestMethod.GET], - produces = [MediaType.APPLICATION_JSON_VALUE]) + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE]) @ResponseBody @ApiOperation(value = "Health Check", hidden = true) fun executionServiceControllerHealthCheck(): JsonNode = runBlocking { @@ -64,8 +66,8 @@ open class ExecutionServiceController { @ResponseBody @PreAuthorize("hasRole('USER')") @ApiOperation(value = "Upload a CBA", - notes = "Upload the CBA package. This will also run validation on the CBA.", - produces = MediaType.APPLICATION_JSON_VALUE) + notes = "Upload the CBA package. This will also run validation on the CBA.", + produces = MediaType.APPLICATION_JSON_VALUE) fun upload(@ApiParam(value = "The ZIP file containing the overall CBA package.", required = true) @RequestPart("file") filePart: FilePart): JsonNode = runBlocking { val uploadId = executionServiceHandler.upload(filePart) @@ -74,8 +76,8 @@ open class ExecutionServiceController { @DeleteMapping("/name/{name}/version/{version}") @ApiOperation(value = "Delete a CBA", - notes = "Delete the CBA package identified by its name and version.", - produces = MediaType.APPLICATION_JSON_VALUE) + notes = "Delete the CBA package identified by its name and version.", + produces = MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("hasRole('USER')") fun deleteBlueprint(@ApiParam(value = "Name of the CBA.", required = true) @PathVariable(value = "name") name: String, @@ -86,24 +88,30 @@ open class ExecutionServiceController { @RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE]) @ApiOperation(value = "Execute a CBA workflow (action)", - notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.", - produces = MediaType.APPLICATION_JSON_VALUE, - response = ExecutionServiceOutput::class) + notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.", + produces = MediaType.APPLICATION_JSON_VALUE, + response = ExecutionServiceOutput::class) @ResponseBody @PreAuthorize("hasRole('USER')") fun process(@ApiParam(value = "ExecutionServiceInput payload.", required = true) - @RequestBody executionServiceInput: ExecutionServiceInput): ResponseEntity = - runBlocking { - if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) { - throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.") - } + @RequestBody executionServiceInput: ExecutionServiceInput): Mono> { + return Mono.fromSupplier { this.bpProcessBlockingWrapper(executionServiceInput) } + .subscribeOn(scheduler) + } - ph.register() - val processResult = executionServiceHandler.doProcess(executionServiceInput) - ph.arriveAndDeregister() - ResponseEntity(processResult, determineHttpStatusCode(processResult.status.code)) + private fun bpProcessBlockingWrapper(executionServiceInput: ExecutionServiceInput): ResponseEntity { + return runBlocking { + if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) { + throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.") } + ph.register() + val processResult = executionServiceHandler.doProcess(executionServiceInput) + ph.arriveAndDeregister() + ResponseEntity(processResult, determineHttpStatusCode(processResult.status.code)) + } + } + @PreDestroy fun preDestroy() { val name = "ExecutionServiceController" -- cgit 1.2.3-korg