From d44afdb346e10d0e0bed90e314421c98ed8a4395 Mon Sep 17 00:00:00 2001 From: ulysses-you Date: Tue, 26 Jan 2021 18:39:19 +0800 Subject: [PATCH] [KYUUBI #303] Add host:port msg if we failed to initialize ![ulysses-you](https://badgen.net/badge/Hello/ulysses-you/green) [![PR 303](https://badgen.net/badge/Preview/PR%20303/blue)](https://github.com/yaooqinn/kyuubi/pull/303) [❨?❩](https://pullrequestbadge.com/?utm_medium=github&utm_source=yaooqinn&utm_campaign=badge_info) Fixes #303 Before this PR, if we start Kyuubi with an already used port, we will get this error msg. It's better to print host:port which we bind. ``` Exception in thread "main" org.apache.kyuubi.KyuubiException: Failed to initialize frontend service at org.apache.kyuubi.service.FrontendService.initialize(FrontendService.scala:102) at org.apache.kyuubi.service.CompositeService.$anonfun$initialize$1(CompositeService.scala:40) at org.apache.kyuubi.service.CompositeService.$anonfun$initialize$1$adapted(CompositeService.scala:40) at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62) at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55) at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49) at org.apache.kyuubi.service.CompositeService.initialize(CompositeService.scala:40) at org.apache.kyuubi.service.Serverable.initialize(Serverable.scala:37) at org.apache.kyuubi.server.KyuubiServer.initialize(KyuubiServer.scala:88) at org.apache.kyuubi.server.KyuubiServer$.startServer(KyuubiServer.scala:45) at org.apache.kyuubi.server.KyuubiServer$.main(KyuubiServer.scala:74) at org.apache.kyuubi.server.KyuubiServer.main(KyuubiServer.scala) Caused by: java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.ServerSocket.bind(ServerSocket.java:375) at java.net.ServerSocket.(ServerSocket.java:237) at org.apache.kyuubi.service.FrontendService.initialize(FrontendService.scala:77) ... 11 more ``` - Add some test cases that check the changes thoroughly including negative and positive cases if possible - Add screenshots for manual tests if appropriate - [Run test](https://kyuubi.readthedocs.io/en/latest/tools/testing.html#running-tests) locally before make a pull request Squashed commit of the following: commit c3f5ffa3dae5d9822ae9b0d8eec879e971ccdea2 Author: ulysses-you Date: Tue Jan 26 18:23:40 2021 +0800 fix commit 42d333de2c1edc0373c737053ff6c28b48a41cf7 Author: ulysses-you Date: Tue Jan 26 14:44:35 2021 +0800 err msg --- .../main/scala/org/apache/kyuubi/service/FrontendService.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala index 84f0c178c..107f46513 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala @@ -99,7 +99,8 @@ class FrontendService private (name: String, be: BackendService, oomHook: Runnab s" [$minThreads, $maxThreads] worker threads") } catch { case e: Throwable => - throw new KyuubiException("Failed to initialize frontend service", e) + throw new KyuubiException( + s"Failed to initialize frontend service on $serverAddr:$portNum.", e) } super.initialize(conf) }