summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/commons/grpc-lib
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2020-09-22 19:05:47 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-22 19:05:47 +0000
commite515a85125e5487ecd3f7127b6af0b192d4a0993 (patch)
tree1fe08a7d54c28419a44845634037d77f8c434a4b /ms/blueprintsprocessor/modules/commons/grpc-lib
parent85d8f7f7701570fb745c3d6360d500f97bdf1b25 (diff)
parent1072867dfac0df993cbd3e44bcc11a5cac7465fd (diff)
Merge "Enabling Code Formatter"
Diffstat (limited to 'ms/blueprintsprocessor/modules/commons/grpc-lib')
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt1
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt7
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt1
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt93
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt40
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt57
-rw-r--r--ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt1
8 files changed, 109 insertions, 93 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
index a3823c6ac..e94400d9b 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibConfiguration.kt
@@ -44,6 +44,7 @@ fun BluePrintDependencyService.grpcClientService(jsonNode: JsonNode): BluePrintG
class GRPCLibConstants {
companion object {
+
const val SERVICE_BLUEPRINT_GRPC_LIB_PROPERTY = "blueprint-grpc-lib-property-service"
const val PROPERTY_GRPC_CLIENT_PREFIX = "blueprintsprocessor.grpcclient."
const val PROPERTY_GRPC_SERVER_PREFIX = "blueprintsprocessor.grpcserver."
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt
index f94d918a2..ebb9a5b32 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/BluePrintGrpcLibData.kt
@@ -25,12 +25,15 @@ open class GrpcServerProperties {
}
open class TokenAuthGrpcServerProperties : GrpcServerProperties() {
+
lateinit var token: String
}
open class TLSAuthGrpcServerProperties : GrpcServerProperties() {
+
lateinit var certChain: String
lateinit var privateKey: String
+
/** Below Used only for Mutual TLS */
var trustCertCollection: String? = null
}
@@ -44,17 +47,21 @@ open class GrpcClientProperties {
}
open class TokenAuthGrpcClientProperties : GrpcClientProperties() {
+
lateinit var token: String
}
open class TLSAuthGrpcClientProperties : GrpcClientProperties() {
+
var trustCertCollection: String? = null
+
/** Below Used only for Mutual TLS */
var clientCertChain: String? = null
var clientPrivateKey: String? = null
}
open class BasicAuthGrpcClientProperties : GrpcClientProperties() {
+
lateinit var username: String
lateinit var password: String
}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt
index 43e56606f..56384ceff 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcClientLoggingInterceptor.kt
@@ -28,6 +28,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.GrpcLoggerService
import org.onap.ccsdk.cds.controllerblueprints.core.logger
class GrpcClientLoggingInterceptor : ClientInterceptor {
+
val log = logger(GrpcClientLoggingInterceptor::class)
val loggingService = GrpcLoggerService()
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt
index a49b96743..aaa4d5f26 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/interceptor/GrpcServerLoggingInterceptor.kt
@@ -32,6 +32,7 @@ import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceIn
import org.slf4j.MDC
class GrpcServerLoggingInterceptor : ServerInterceptor {
+
val log = logger(GrpcServerLoggingInterceptor::class)
val loggingService = GrpcLoggerService()
@@ -42,59 +43,59 @@ class GrpcServerLoggingInterceptor : ServerInterceptor {
):
ServerCall.Listener<ReqT> {
- val forwardingServerCall = object : ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(call) {
- override fun sendHeaders(responseHeaders: Metadata) {
- loggingService.grpResponding(requestHeaders, responseHeaders)
- super.sendHeaders(responseHeaders)
+ val forwardingServerCall = object : ForwardingServerCall.SimpleForwardingServerCall<ReqT, RespT>(call) {
+ override fun sendHeaders(responseHeaders: Metadata) {
+ loggingService.grpResponding(requestHeaders, responseHeaders)
+ super.sendHeaders(responseHeaders)
+ }
}
- }
- return object :
- ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>(
- next.startCall(forwardingServerCall, requestHeaders)
- ) {
+ return object :
+ ForwardingServerCallListener.SimpleForwardingServerCallListener<ReqT>(
+ next.startCall(forwardingServerCall, requestHeaders)
+ ) {
- override fun onMessage(message: ReqT) {
- /** Get the requestId, SubRequestId and Originator Id and set in MDS context
- * If you are using other GRPC services, Implement own Logging Interceptors to get tracing.
- * */
- when (message) {
- is ExecutionServiceInput -> {
- val commonHeader = message.commonHeader
- ?: throw BluePrintProcessorException("missing common header in request")
- loggingService.grpcRequesting(call, commonHeader, next)
- }
- is BluePrintUploadInput -> {
- val commonHeader = message.commonHeader
- ?: throw BluePrintProcessorException("missing common header in request")
- loggingService.grpcRequesting(call, commonHeader, next)
- }
- is BluePrintDownloadInput -> {
- val commonHeader = message.commonHeader
- ?: throw BluePrintProcessorException("missing common header in request")
- loggingService.grpcRequesting(call, commonHeader, next)
- }
- is BluePrintRemoveInput -> {
- val commonHeader = message.commonHeader
- ?: throw BluePrintProcessorException("missing common header in request")
- loggingService.grpcRequesting(call, commonHeader, next)
- }
- else -> {
- loggingService.grpcRequesting(call, requestHeaders, next)
+ override fun onMessage(message: ReqT) {
+ /** Get the requestId, SubRequestId and Originator Id and set in MDS context
+ * If you are using other GRPC services, Implement own Logging Interceptors to get tracing.
+ * */
+ when (message) {
+ is ExecutionServiceInput -> {
+ val commonHeader = message.commonHeader
+ ?: throw BluePrintProcessorException("missing common header in request")
+ loggingService.grpcRequesting(call, commonHeader, next)
+ }
+ is BluePrintUploadInput -> {
+ val commonHeader = message.commonHeader
+ ?: throw BluePrintProcessorException("missing common header in request")
+ loggingService.grpcRequesting(call, commonHeader, next)
+ }
+ is BluePrintDownloadInput -> {
+ val commonHeader = message.commonHeader
+ ?: throw BluePrintProcessorException("missing common header in request")
+ loggingService.grpcRequesting(call, commonHeader, next)
+ }
+ is BluePrintRemoveInput -> {
+ val commonHeader = message.commonHeader
+ ?: throw BluePrintProcessorException("missing common header in request")
+ loggingService.grpcRequesting(call, commonHeader, next)
+ }
+ else -> {
+ loggingService.grpcRequesting(call, requestHeaders, next)
+ }
}
+ super.onMessage(message)
}
- super.onMessage(message)
- }
- override fun onComplete() {
- MDC.clear()
- super.onComplete()
- }
+ override fun onComplete() {
+ MDC.clear()
+ super.onComplete()
+ }
- override fun onCancel() {
- MDC.clear()
- super.onCancel()
+ override fun onCancel() {
+ MDC.clear()
+ super.onCancel()
+ }
}
}
- }
}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
index 79da447a1..a102ee6da 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyService.kt
@@ -88,15 +88,15 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
private fun blueprintGrpcServerService(grpcServerProperties: GrpcServerProperties):
BluePrintGrpcServerService {
- when (grpcServerProperties) {
- is TLSAuthGrpcServerProperties -> {
- return TLSAuthGrpcServerService(grpcServerProperties)
- }
- else -> {
- throw BluePrintProcessorException("couldn't get grpc client service for properties $grpcServerProperties")
+ when (grpcServerProperties) {
+ is TLSAuthGrpcServerProperties -> {
+ return TLSAuthGrpcServerService(grpcServerProperties)
+ }
+ else -> {
+ throw BluePrintProcessorException("couldn't get grpc client service for properties $grpcServerProperties")
+ }
}
}
- }
/** GRPC Client Lib Property Service */
@@ -152,21 +152,21 @@ open class BluePrintGrpcLibPropertyService(private var bluePrintPropertiesServic
fun blueprintGrpcClientService(grpcClientProperties: GrpcClientProperties):
BluePrintGrpcClientService {
- return when (grpcClientProperties) {
- is TokenAuthGrpcClientProperties -> {
- TokenAuthGrpcClientService(grpcClientProperties)
- }
- is TLSAuthGrpcClientProperties -> {
- TLSAuthGrpcClientService(grpcClientProperties)
- }
- is BasicAuthGrpcClientProperties -> {
- BasicAuthGrpcClientService(grpcClientProperties)
- }
- else -> {
- throw BluePrintProcessorException("couldn't get grpc service for type(${grpcClientProperties.type})")
+ return when (grpcClientProperties) {
+ is TokenAuthGrpcClientProperties -> {
+ TokenAuthGrpcClientService(grpcClientProperties)
+ }
+ is TLSAuthGrpcClientProperties -> {
+ TLSAuthGrpcClientService(grpcClientProperties)
+ }
+ is BasicAuthGrpcClientProperties -> {
+ BasicAuthGrpcClientService(grpcClientProperties)
+ }
+ else -> {
+ throw BluePrintProcessorException("couldn't get grpc service for type(${grpcClientProperties.type})")
+ }
}
}
- }
private fun tokenAuthGrpcClientProperties(prefix: String): TokenAuthGrpcClientProperties {
return bluePrintPropertiesService.propertyBeanType(prefix, TokenAuthGrpcClientProperties::class.java)
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt
index e71525f0a..d2db14a53 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcService.kt
@@ -21,9 +21,11 @@ import io.grpc.ManagedChannel
import io.grpc.netty.NettyServerBuilder
interface BluePrintGrpcServerService {
+
fun serverBuilder(): NettyServerBuilder
}
interface BluePrintGrpcClientService {
+
suspend fun channel(): ManagedChannel
}
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
index d9a8082d4..30722c8e3 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/BluePrintGrpcLibPropertyServiceTest.kt
@@ -40,36 +40,39 @@ import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@ContextConfiguration(
- classes = [BluePrintGrpcLibConfiguration::class,
- BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class]
+ classes = [
+ BluePrintGrpcLibConfiguration::class,
+ BluePrintPropertyConfiguration::class, BluePrintPropertiesService::class
+ ]
)
@TestPropertySource(
properties =
- ["blueprintsprocessor.grpcclient.sample.type=basic-auth",
- "blueprintsprocessor.grpcclient.sample.host=127.0.0.1",
- "blueprintsprocessor.grpcclient.sample.port=50505",
- "blueprintsprocessor.grpcclient.sample.username=sampleuser",
- "blueprintsprocessor.grpcclient.sample.password=sampleuser",
-
- "blueprintsprocessor.grpcclient.token.type=token-auth",
- "blueprintsprocessor.grpcclient.token.host=127.0.0.1",
- "blueprintsprocessor.grpcclient.token.port=50505",
- "blueprintsprocessor.grpcclient.token.username=sampleuser",
- "blueprintsprocessor.grpcclient.token.password=sampleuser",
-
- "blueprintsprocessor.grpcserver.tls-sample.type=tls-auth",
- "blueprintsprocessor.grpcserver.tls-sample.port=50505",
- "blueprintsprocessor.grpcserver.tls-sample.certChain=server1.pem",
- "blueprintsprocessor.grpcserver.tls-sample.privateKey=server1.key",
- "blueprintsprocessor.grpcserver.tls-sample.trustCertCollection=ca.pem",
-
- "blueprintsprocessor.grpcclient.tls-sample.type=tls-auth",
- "blueprintsprocessor.grpcclient.tls-sample.host=127.0.0.1",
- "blueprintsprocessor.grpcclient.tls-sample.port=50505",
- "blueprintsprocessor.grpcclient.tls-sample.trustCertCollection=ca.pem",
- "blueprintsprocessor.grpcclient.tls-sample.clientCertChain=client.pem",
- "blueprintsprocessor.grpcclient.tls-sample.clientPrivateKey=client.key"
- ]
+ [
+ "blueprintsprocessor.grpcclient.sample.type=basic-auth",
+ "blueprintsprocessor.grpcclient.sample.host=127.0.0.1",
+ "blueprintsprocessor.grpcclient.sample.port=50505",
+ "blueprintsprocessor.grpcclient.sample.username=sampleuser",
+ "blueprintsprocessor.grpcclient.sample.password=sampleuser",
+
+ "blueprintsprocessor.grpcclient.token.type=token-auth",
+ "blueprintsprocessor.grpcclient.token.host=127.0.0.1",
+ "blueprintsprocessor.grpcclient.token.port=50505",
+ "blueprintsprocessor.grpcclient.token.username=sampleuser",
+ "blueprintsprocessor.grpcclient.token.password=sampleuser",
+
+ "blueprintsprocessor.grpcserver.tls-sample.type=tls-auth",
+ "blueprintsprocessor.grpcserver.tls-sample.port=50505",
+ "blueprintsprocessor.grpcserver.tls-sample.certChain=server1.pem",
+ "blueprintsprocessor.grpcserver.tls-sample.privateKey=server1.key",
+ "blueprintsprocessor.grpcserver.tls-sample.trustCertCollection=ca.pem",
+
+ "blueprintsprocessor.grpcclient.tls-sample.type=tls-auth",
+ "blueprintsprocessor.grpcclient.tls-sample.host=127.0.0.1",
+ "blueprintsprocessor.grpcclient.tls-sample.port=50505",
+ "blueprintsprocessor.grpcclient.tls-sample.trustCertCollection=ca.pem",
+ "blueprintsprocessor.grpcclient.tls-sample.clientCertChain=client.pem",
+ "blueprintsprocessor.grpcclient.tls-sample.clientPrivateKey=client.key"
+ ]
)
class BluePrintGrpcLibPropertyServiceTest {
diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt
index fb7282f75..78fa27d3a 100644
--- a/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt
+++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/grpc/service/MockTLSBluePrintProcessingServer.kt
@@ -51,6 +51,7 @@ fun main() {
}
class MockTLSBluePrintProcessingServer : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
+
override fun process(responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {