From 6fcfbc12e20e5a853c9204469dac6867b7eb6ccb Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Fri, 12 Apr 2019 22:25:17 -0400 Subject: Integration Test - Component Executor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icbe745b30c7bbb973bc9bb29bf547340b32f1b0f Issue-ID: CCSDK-1164 Signed-off-by: Alexis de Talhouët --- .../execution/RemoteScriptExecutionService.kt | 27 ++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'ms/blueprintsprocessor/modules/services') diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt index 46969b1c5..7db5f52a4 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/RemoteScriptExecutionService.kt @@ -48,8 +48,8 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi private val log = LoggerFactory.getLogger(GrpcRemoteScriptExecutionService::class.java)!! - lateinit var channel: ManagedChannel - lateinit var commandExecutorServiceGrpc: CommandExecutorServiceGrpc.CommandExecutorServiceFutureStub + private var channel: ManagedChannel? = null + private lateinit var commandExecutorServiceGrpc: CommandExecutorServiceGrpc.CommandExecutorServiceFutureStub override suspend fun init(selector: String) { // Get the GRPC Client Service based on selector @@ -94,10 +94,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi } override suspend fun close() { - // TODO('Verify the correct way to close the client conncetion") - if (channel != null) { - channel.shutdownNow() - } + channel?.shutdownNow() } @@ -105,7 +102,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi val correlationId = this.correlationId ?: this.requestId return PrepareEnvInput.newBuilder() - .setIdentifiers(this.remoteIdentifier.asGrpcData()) + .setIdentifiers(this.remoteIdentifier!!.asGrpcData()) .setRequestId(this.requestId) .setCorrelationId(correlationId) .setScriptType(ScriptType.valueOf(this.remoteScriptType.name)) @@ -120,7 +117,7 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi return ExecutionInput.newBuilder() .setRequestId(this.requestId) .setCorrelationId(correlationId) - .setIdentifiers(this.remoteIdentifier.asGrpcData()) + .setIdentifiers(this.remoteIdentifier!!.asGrpcData()) .setScriptType(ScriptType.valueOf(this.remoteScriptType.name)) .setCommand(this.command) .setTimeOut(this.timeOut.toInt()) @@ -129,15 +126,11 @@ class GrpcRemoteScriptExecutionService(private val bluePrintGrpcLibPropertyServi .build() } - fun RemoteIdentifier?.asGrpcData(): Identifiers? { - return if (this != null) { - Identifiers.newBuilder() - .setBlueprintName(this.blueprintName) - .setBlueprintVersion(this.blueprintVersion) - .build() - } else { - null - } + fun RemoteIdentifier.asGrpcData(): Identifiers? { + return Identifiers.newBuilder() + .setBlueprintName(this.blueprintName) + .setBlueprintVersion(this.blueprintVersion) + .build() } fun Map.asGrpcData(): Struct { -- cgit 1.2.3-korg