From 49f43c856c8ca793bc6972d9d4b47c2d0d4c0816 Mon Sep 17 00:00:00 2001 From: kjaniak Date: Wed, 3 Apr 2019 15:48:28 +0200 Subject: Creation of server module Issue-ID: DCAEGEN2-1390 Change-Id: I07410b16ed6566b933d5f1efa35bddb965225794 Signed-off-by: kjaniak Signed-off-by: Filip Krzywka --- sources/hv-collector-main/pom.xml | 4 +- .../org/onap/dcae/collectors/veshv/main/main.kt | 13 +++- .../veshv/main/servers/HealthCheckServer.kt | 2 +- .../collectors/veshv/main/servers/VesServer.kt | 69 ---------------------- 4 files changed, 13 insertions(+), 75 deletions(-) delete mode 100644 sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt (limited to 'sources/hv-collector-main') diff --git a/sources/hv-collector-main/pom.xml b/sources/hv-collector-main/pom.xml index 3fe8932f..d99bf855 100644 --- a/sources/hv-collector-main/pom.xml +++ b/sources/hv-collector-main/pom.xml @@ -83,12 +83,12 @@ ${project.groupId} - hv-collector-core + hv-collector-health-check ${project.version} ${project.groupId} - hv-collector-health-check + hv-collector-server ${project.version} diff --git a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt index dfb388d8..123d2dc9 100644 --- a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt +++ b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/main.kt @@ -19,14 +19,16 @@ */ package org.onap.dcae.collectors.veshv.main +import org.onap.dcae.collectors.veshv.api.ServersFactory import org.onap.dcae.collectors.veshv.config.api.ConfigurationModule import org.onap.dcae.collectors.veshv.config.api.ConfigurationStateListener import org.onap.dcae.collectors.veshv.config.api.model.HvVesConfiguration import org.onap.dcae.collectors.veshv.healthcheck.api.HealthDescription import org.onap.dcae.collectors.veshv.healthcheck.api.HealthState +import org.onap.dcae.collectors.veshv.main.metrics.MicrometerMetrics import org.onap.dcae.collectors.veshv.main.servers.HealthCheckServer -import org.onap.dcae.collectors.veshv.main.servers.VesServer -import org.onap.dcae.collectors.veshv.model.ServiceContext +import org.onap.dcae.collectors.veshv.ssl.boundary.SslContextFactory +import org.onap.dcae.collectors.veshv.domain.logging.ServiceContext import org.onap.dcae.collectors.veshv.utils.ServerHandle import org.onap.dcae.collectors.veshv.utils.logging.Logger import org.onap.dcae.collectors.veshv.utils.registerShutdownHook @@ -41,6 +43,7 @@ private val logger = Logger("$VES_HV_PACKAGE.main") private val hvVesServer = AtomicReference() private val configurationModule = ConfigurationModule() +private val sslContextFactory = SslContextFactory() private val maxCloseTime = Duration.ofSeconds(10) fun main(args: Array) { @@ -81,7 +84,11 @@ private fun startServer(config: HvVesConfiguration): Mono = private fun deferredVesServer(config: HvVesConfiguration) = Mono.defer { Logger.setLogLevel(VES_HV_PACKAGE, config.logLevel) logger.debug(ServiceContext::mdc) { "Configuration: $config" } - VesServer.start(config) + ServersFactory.createHvVesServer( + config, + sslContextFactory, + MicrometerMetrics.INSTANCE + ).start() } private fun stopRunningServer() = Mono.defer { diff --git a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/HealthCheckServer.kt b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/HealthCheckServer.kt index c970e5c8..2ed6ea70 100644 --- a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/HealthCheckServer.kt +++ b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/HealthCheckServer.kt @@ -22,7 +22,7 @@ package org.onap.dcae.collectors.veshv.main.servers import org.onap.dcae.collectors.veshv.healthcheck.api.HealthState import org.onap.dcae.collectors.veshv.healthcheck.factory.HealthCheckApiServer import org.onap.dcae.collectors.veshv.main.metrics.MicrometerMetrics -import org.onap.dcae.collectors.veshv.model.ServiceContext +import org.onap.dcae.collectors.veshv.domain.logging.ServiceContext import org.onap.dcae.collectors.veshv.utils.ServerHandle import org.onap.dcae.collectors.veshv.utils.logging.Logger import java.net.InetSocketAddress diff --git a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt b/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt deleted file mode 100644 index 98a094b2..00000000 --- a/sources/hv-collector-main/src/main/kotlin/org/onap/dcae/collectors/veshv/main/servers/VesServer.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * dcaegen2-collectors-veshv - * ================================================================================ - * Copyright (C) 2018-2019 NOKIA - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ -package org.onap.dcae.collectors.veshv.main.servers - -import org.onap.dcae.collectors.veshv.boundary.Server -import org.onap.dcae.collectors.veshv.config.api.model.HvVesConfiguration -import org.onap.dcae.collectors.veshv.factory.HvVesCollectorFactory -import org.onap.dcae.collectors.veshv.factory.ServerFactory -import org.onap.dcae.collectors.veshv.factory.AdapterFactory -import org.onap.dcae.collectors.veshv.main.metrics.MicrometerMetrics -import org.onap.dcae.collectors.veshv.model.ServiceContext -import org.onap.dcae.collectors.veshv.utils.ServerHandle -import org.onap.dcae.collectors.veshv.utils.logging.Logger -import reactor.core.publisher.Mono - -/** - * @author Piotr Jaszczyk - * @since August 2018 - */ -object VesServer { - - private val logger = Logger(VesServer::class) - - fun start(config: HvVesConfiguration): Mono = - createVesServer(config) - .start() - .doOnNext(::logServerStarted) - - private fun createVesServer(config: HvVesConfiguration): Server = - createCollectorProvider(config) - .let { collectorProvider -> - ServerFactory.createNettyTcpServer( - config.server, - config.security, - collectorProvider, - MicrometerMetrics.INSTANCE - ) - } - - private fun createCollectorProvider(config: HvVesConfiguration): HvVesCollectorFactory = - HvVesCollectorFactory( - config.collector, - AdapterFactory.sinkCreatorFactory(), - MicrometerMetrics.INSTANCE - ) - - private fun logServerStarted(handle: ServerHandle) = - logger.info(ServiceContext::mdc) { - "HighVolume VES Collector is up and listening on ${handle.host}:${handle.port}" - } - -} -- cgit 1.2.3-korg