From 87822f6fe24d2bc9fe0cb1b26e1ba96889cda250 Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Wed, 9 Oct 2024 11:35:49 +0800 Subject: [PATCH] [CELEBORN-1615] Start the http server after all handlers added ### What changes were proposed in this pull request? Start the http server after all handlers added. ### Why are the changes needed? Do not expose the RESTful server before all handlers initialized. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Existing UT. Closes #2764 from turboFei/metrics_not_found. Authored-by: Wang, Fei Signed-off-by: Shuang --- .../org/apache/celeborn/server/common/HttpService.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/service/src/main/scala/org/apache/celeborn/server/common/HttpService.scala b/service/src/main/scala/org/apache/celeborn/server/common/HttpService.scala index 3c8c02a0b..bb98e88f6 100644 --- a/service/src/main/scala/org/apache/celeborn/server/common/HttpService.scala +++ b/service/src/main/scala/org/apache/celeborn/server/common/HttpService.scala @@ -209,7 +209,6 @@ abstract class HttpService extends Service with Logging { httpSslKeyStoreAlgorithm(), httpSslDisallowedProtocols(), httpSslIncludedCipherSuites()) - httpServer.start() startInternal() // block until the HTTP server is started, otherwise, we may get // the wrong HTTP server port -1 @@ -348,9 +347,13 @@ abstract class HttpService extends Service with Logging { if (metricsSystem.running) { metricsSystem.getServletContextHandlers.foreach { handler => + logInfo(s"Adding metrics servlet handler with path ${handler.getContextPath}") httpServer.addHandler(handler) } } + + // start the http server after all handlers are added + httpServer.start() } override def initialize(): Unit = {