From 4d15e5a578dc2c94af2b7f1c7ad02fb44d384501 Mon Sep 17 00:00:00 2001 From: Piotr Jaszczyk Date: Wed, 7 Nov 2018 15:08:43 +0100 Subject: Update project and dependencies * Changed version from 4.0.0-SNAPSHOT to 1.1.0-SNAPSHOT as per Vijay suggestion * Updated Reactor to BOM Californium-SR2 * Updated mockito-kotlin to 2.0.0 * Introduced some fixes to support OpenJDK 11 compilation Change-Id: Ib25979ef50c7241a019bf98efd9759e0b8792d58 Issue-ID: DCAEGEN2-961 Signed-off-by: Piotr Jaszczyk --- .../healthcheck/factory/HealthCheckApiServer.kt | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'hv-collector-health-check/src') diff --git a/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/factory/HealthCheckApiServer.kt b/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/factory/HealthCheckApiServer.kt index 753f73ef..b4d7c142 100644 --- a/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/factory/HealthCheckApiServer.kt +++ b/hv-collector-health-check/src/main/kotlin/org/onap/dcae/collectors/veshv/healthcheck/factory/HealthCheckApiServer.kt @@ -27,26 +27,30 @@ import org.onap.dcae.collectors.veshv.utils.NettyServerHandle import org.onap.dcae.collectors.veshv.utils.ServerHandle import reactor.core.publisher.Flux import reactor.core.publisher.Mono -import reactor.ipc.netty.http.server.HttpServer -import reactor.ipc.netty.http.server.HttpServerRequest -import reactor.ipc.netty.http.server.HttpServerResponse +import reactor.netty.http.server.HttpServer +import reactor.netty.http.server.HttpServerRequest +import reactor.netty.http.server.HttpServerResponse +import java.net.SocketAddress import java.util.concurrent.atomic.AtomicReference /** * @author Jakub Dudycz * @since August 2018 */ -class HealthCheckApiServer(private val healthState: HealthState, private val port: Int) { +class HealthCheckApiServer(private val healthState: HealthState, + private val listenAddress: SocketAddress) { private val healthDescription: AtomicReference = AtomicReference(HealthDescription.STARTING) fun start(): IO = IO { healthState().subscribe(healthDescription::set) - val ctx = HttpServer.create(port).startRouter { routes -> - routes.get("/health/ready", ::readinessHandler) - routes.get("/health/alive", ::livenessHandler) - } - NettyServerHandle(ctx) + val ctx = HttpServer.create() + .tcpConfiguration { it.addressSupplier { listenAddress } } + .route { routes -> + routes.get("/health/ready", ::readinessHandler) + routes.get("/health/alive", ::livenessHandler) + } + NettyServerHandle(ctx.bindNow()) } private fun readinessHandler(req: HttpServerRequest, resp: HttpServerResponse) = @@ -55,6 +59,6 @@ class HealthCheckApiServer(private val healthState: HealthState, private val por } private fun livenessHandler(req: HttpServerRequest, resp: HttpServerResponse) = - resp.status(HttpResponseStatus.NOT_IMPLEMENTED).sendString(Mono.just("Not implemented yet")) + resp.status(HttpResponseStatus.NOT_IMPLEMENTED).sendString(Mono.just("Not implemented yet")) } -- cgit