This is an automated email from the ASF dual-hosted git repository.
feiwang pushed a commit to branch branch-1.10
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.10 by this push:
new 1b49310951 [KYUUBI #7017] Using mutable JettyServer uri to prevent
batch kyuubi instance mismatch
1b49310951 is described below
commit 1b493109518bb10dda6dbeb1df0bc750042ccd6f
Author: Wang, Fei <[email protected]>
AuthorDate: Wed Apr 9 10:27:09 2025 -0700
[KYUUBI #7017] Using mutable JettyServer uri to prevent batch kyuubi
instance mismatch
### Why are the changes needed?
To fix the batch kyuubi instance port is negative issue.
<img width="697" alt="image"
src="https://github.com/user-attachments/assets/ef992390-8d20-44b3-8640-35496caff85d"
/>
It happen after I stop the kyuubi service.
We should use variable instead of function for jetty server serverUri.
After the server connector stopped, the localPort would be `-2`.

### How was this patch tested?
Existing UT.
### Was this patch authored or co-authored using generative AI tooling?
No.
Closes #7017 from turboFei/server_port_negative.
Closes #7017
3d34c4031 [Wang, Fei] warn
e58298646 [Wang, Fei] mutable server uri
2cbaf772a [Wang, Fei] Revert "hard code the server uri"
b64d91b32 [Wang, Fei] hard code the server uri
Authored-by: Wang, Fei <[email protected]>
Signed-off-by: Wang, Fei <[email protected]>
(cherry picked from commit 0cc52d035cf2011e6f9fa9f4fd44394485b756b3)
Signed-off-by: Wang, Fei <[email protected]>
---
.../scala/org/apache/kyuubi/server/ui/JettyServer.scala | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala
index e74a2f3c45..c1bac1275c 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/ui/JettyServer.scala
@@ -22,18 +22,22 @@ import
org.eclipse.jetty.server.handler.{ContextHandlerCollection, ErrorHandler}
import org.eclipse.jetty.util.component.LifeCycle
import org.eclipse.jetty.util.thread.{QueuedThreadPool,
ScheduledExecutorScheduler}
+import org.apache.kyuubi.Logging
import org.apache.kyuubi.util.JavaUtils
private[kyuubi] class JettyServer(
server: Server,
connector: ServerConnector,
- rootHandler: ContextHandlerCollection) {
+ rootHandler: ContextHandlerCollection) extends Logging {
def start(): Unit = synchronized {
try {
server.start()
connector.start()
server.addConnector(connector)
+ val localPort = connector.getLocalPort
+ require(localPort > 0, "Jetty server port should be positive, but got "
+ localPort)
+ _serverUri = connector.getHost + ":" + localPort
} catch {
case e: Exception =>
stop()
@@ -49,7 +53,13 @@ private[kyuubi] class JettyServer(
case _ =>
}
}
- def getServerUri: String = connector.getHost + ":" + connector.getLocalPort
+
+ @volatile private var _serverUri: String = _
+ def getServerUri: String = Option(_serverUri).getOrElse {
+ val uri = connector.getHost + ":" + connector.getLocalPort
+ warn("Jetty server is not started yet, returning " + uri)
+ uri
+ }
def addHandler(handler: Handler): Unit = synchronized {
rootHandler.addHandler(handler)