From cbac2b13eca6867a5ce77a587acbb1fd3ddd284f Mon Sep 17 00:00:00 2001 From: Cheng Pan Date: Thu, 15 Feb 2024 12:46:03 +0800 Subject: [PATCH 1/2] Make Jetty server stop timeout configurable --- docs/configuration/settings.md | 2 ++ .../org/apache/kyuubi/config/KyuubiConf.scala | 14 ++++++++++++++ .../kyuubi/server/KyuubiRestFrontendService.scala | 3 ++- .../kyuubi/server/KyuubiTrinoFrontendService.scala | 5 +++-- .../org/apache/kyuubi/server/ui/JettyServer.scala | 8 +++++++- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/configuration/settings.md b/docs/configuration/settings.md index 9ef97866195..f5e2863c56c 100644 --- a/docs/configuration/settings.md +++ b/docs/configuration/settings.md @@ -248,6 +248,7 @@ You can configure the Kyuubi properties in `$KYUUBI_HOME/conf/kyuubi-defaults.co | kyuubi.frontend.proxy.http.client.ip.header | X-Real-IP | The HTTP header to record the real client IP address. If your server is behind a load balancer or other proxy, the server will see this load balancer or proxy IP address as the client IP address, to get around this common issue, most load balancers or proxies offer the ability to record the real remote IP address in an HTTP header that will be added to the request for other devices to use. Note that, because the header value can be specified to any IP address, so it will not be used for authentication. | string | 1.6.0 | | kyuubi.frontend.rest.bind.host | <undefined> | Hostname or IP of the machine on which to run the REST frontend service. | string | 1.4.0 | | kyuubi.frontend.rest.bind.port | 10099 | Port of the machine on which to run the REST frontend service. | int | 1.4.0 | +| kyuubi.frontend.rest.jetty.stopTimeout | 5s | Stop timeout for Jetty server used by the RESTful frontend service. | duration | 1.8.1 | | kyuubi.frontend.rest.max.worker.threads | 999 | Maximum number of threads in the frontend worker thread pool for the rest frontend service | int | 1.6.2 | | kyuubi.frontend.ssl.keystore.algorithm | <undefined> | SSL certificate keystore algorithm. | string | 1.7.0 | | kyuubi.frontend.ssl.keystore.password | <undefined> | SSL certificate keystore password. | string | 1.7.0 | @@ -284,6 +285,7 @@ You can configure the Kyuubi properties in `$KYUUBI_HOME/conf/kyuubi-defaults.co | kyuubi.frontend.thrift.worker.keepalive.time | PT1M | Keep-alive time (in milliseconds) for an idle worker thread | duration | 1.4.0 | | kyuubi.frontend.trino.bind.host | <undefined> | Hostname or IP of the machine on which to run the TRINO frontend service. | string | 1.7.0 | | kyuubi.frontend.trino.bind.port | 10999 | Port of the machine on which to run the TRINO frontend service. | int | 1.7.0 | +| kyuubi.frontend.trino.jetty.stopTimeout | 5s | Stop timeout for Jetty server used by the Trino frontend service. | duration | 1.8.1 | | kyuubi.frontend.trino.max.worker.threads | 999 | Maximum number of threads in the frontend worker thread pool for the Trino frontend service | int | 1.7.0 | | kyuubi.frontend.worker.keepalive.time | PT1M | (deprecated) Keep-alive time (in milliseconds) for an idle worker thread | duration | 1.0.0 | diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala index caeecf9f0ad..f7c2fb07a7d 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala @@ -571,6 +571,13 @@ object KyuubiConf { .version("1.6.2") .fallbackConf(FRONTEND_MAX_WORKER_THREADS) + val FRONTEND_REST_JETTY_STOP_TIMEOUT: ConfigEntry[Long] = + buildConf("kyuubi.frontend.rest.jetty.stopTimeout") + .doc("Stop timeout for Jetty server used by the RESTful frontend service.") + .version("1.8.1") + .timeConf + .createWithDefaultString("5s") + val FRONTEND_WORKER_KEEPALIVE_TIME: ConfigEntry[Long] = buildConf("kyuubi.frontend.worker.keepalive.time") .doc("(deprecated) Keep-alive time (in milliseconds) for an idle worker thread") @@ -1124,6 +1131,13 @@ object KyuubiConf { .version("1.7.0") .fallbackConf(FRONTEND_MAX_WORKER_THREADS) + val FRONTEND_TRINO_JETTY_STOP_TIMEOUT: ConfigEntry[Long] = + buildConf("kyuubi.frontend.trino.jetty.stopTimeout") + .doc("Stop timeout for Jetty server used by the Trino frontend service.") + .version("1.8.1") + .timeConf + .createWithDefaultString("5s") + val KUBERNETES_CONTEXT: OptionalConfigEntry[String] = buildConf("kyuubi.kubernetes.context") .doc("The desired context from your kubernetes config file used to configure the K8s " + diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala index 83aee66fef0..a3dd4038995 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala @@ -89,7 +89,8 @@ class KyuubiRestFrontendService(override val serverable: Serverable) getName, host, port, - conf.get(FRONTEND_REST_MAX_WORKER_THREADS)) + conf.get(FRONTEND_REST_MAX_WORKER_THREADS), + conf.get(FRONTEND_REST_JETTY_STOP_TIMEOUT)) super.initialize(conf) } diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala index 95f6d590265..bef0b6f9354 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTrinoFrontendService.scala @@ -21,7 +21,7 @@ import java.util.concurrent.atomic.AtomicBoolean import org.apache.kyuubi.{KyuubiException, Utils} import org.apache.kyuubi.config.KyuubiConf -import org.apache.kyuubi.config.KyuubiConf.{FRONTEND_ADVERTISED_HOST, FRONTEND_TRINO_BIND_HOST, FRONTEND_TRINO_BIND_PORT, FRONTEND_TRINO_MAX_WORKER_THREADS} +import org.apache.kyuubi.config.KyuubiConf.{FRONTEND_ADVERTISED_HOST, FRONTEND_TRINO_BIND_HOST, FRONTEND_TRINO_BIND_PORT, FRONTEND_TRINO_JETTY_STOP_TIMEOUT, FRONTEND_TRINO_MAX_WORKER_THREADS} import org.apache.kyuubi.server.trino.api.v1.ApiRootResource import org.apache.kyuubi.server.ui.JettyServer import org.apache.kyuubi.service.{AbstractFrontendService, Serverable, Service} @@ -54,7 +54,8 @@ class KyuubiTrinoFrontendService(override val serverable: Serverable) getName, host, port, - conf.get(FRONTEND_TRINO_MAX_WORKER_THREADS)) + conf.get(FRONTEND_TRINO_MAX_WORKER_THREADS), + conf.get(FRONTEND_TRINO_JETTY_STOP_TIMEOUT)) super.initialize(conf) } 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 00b172f2c94..7f4043534a6 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 @@ -73,11 +73,17 @@ private[kyuubi] case class JettyServer( object JettyServer { - def apply(name: String, host: String, port: Int, poolSize: Int): JettyServer = { + def apply( + name: String, + host: String, + port: Int, + poolSize: Int, + stopTimeout: Long): JettyServer = { val pool = new QueuedThreadPool(poolSize) pool.setName(name) pool.setDaemon(true) val server = new Server(pool) + server.setStopTimeout(stopTimeout) val errorHandler = new ErrorHandler() errorHandler.setShowStacks(true) From 47d15f9aa9b846ad3ad5c37beb8b4828b48d8252 Mon Sep 17 00:00:00 2001 From: Cheng Pan Date: Thu, 15 Feb 2024 13:04:38 +0800 Subject: [PATCH 2/2] fix --- docs/configuration/settings.md | 4 ++-- .../src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/configuration/settings.md b/docs/configuration/settings.md index f5e2863c56c..a2dd795f507 100644 --- a/docs/configuration/settings.md +++ b/docs/configuration/settings.md @@ -248,7 +248,7 @@ You can configure the Kyuubi properties in `$KYUUBI_HOME/conf/kyuubi-defaults.co | kyuubi.frontend.proxy.http.client.ip.header | X-Real-IP | The HTTP header to record the real client IP address. If your server is behind a load balancer or other proxy, the server will see this load balancer or proxy IP address as the client IP address, to get around this common issue, most load balancers or proxies offer the ability to record the real remote IP address in an HTTP header that will be added to the request for other devices to use. Note that, because the header value can be specified to any IP address, so it will not be used for authentication. | string | 1.6.0 | | kyuubi.frontend.rest.bind.host | <undefined> | Hostname or IP of the machine on which to run the REST frontend service. | string | 1.4.0 | | kyuubi.frontend.rest.bind.port | 10099 | Port of the machine on which to run the REST frontend service. | int | 1.4.0 | -| kyuubi.frontend.rest.jetty.stopTimeout | 5s | Stop timeout for Jetty server used by the RESTful frontend service. | duration | 1.8.1 | +| kyuubi.frontend.rest.jetty.stopTimeout | PT5S | Stop timeout for Jetty server used by the RESTful frontend service. | duration | 1.8.1 | | kyuubi.frontend.rest.max.worker.threads | 999 | Maximum number of threads in the frontend worker thread pool for the rest frontend service | int | 1.6.2 | | kyuubi.frontend.ssl.keystore.algorithm | <undefined> | SSL certificate keystore algorithm. | string | 1.7.0 | | kyuubi.frontend.ssl.keystore.password | <undefined> | SSL certificate keystore password. | string | 1.7.0 | @@ -285,7 +285,7 @@ You can configure the Kyuubi properties in `$KYUUBI_HOME/conf/kyuubi-defaults.co | kyuubi.frontend.thrift.worker.keepalive.time | PT1M | Keep-alive time (in milliseconds) for an idle worker thread | duration | 1.4.0 | | kyuubi.frontend.trino.bind.host | <undefined> | Hostname or IP of the machine on which to run the TRINO frontend service. | string | 1.7.0 | | kyuubi.frontend.trino.bind.port | 10999 | Port of the machine on which to run the TRINO frontend service. | int | 1.7.0 | -| kyuubi.frontend.trino.jetty.stopTimeout | 5s | Stop timeout for Jetty server used by the Trino frontend service. | duration | 1.8.1 | +| kyuubi.frontend.trino.jetty.stopTimeout | PT5S | Stop timeout for Jetty server used by the Trino frontend service. | duration | 1.8.1 | | kyuubi.frontend.trino.max.worker.threads | 999 | Maximum number of threads in the frontend worker thread pool for the Trino frontend service | int | 1.7.0 | | kyuubi.frontend.worker.keepalive.time | PT1M | (deprecated) Keep-alive time (in milliseconds) for an idle worker thread | duration | 1.0.0 | diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala index f7c2fb07a7d..5346d19a20b 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/config/KyuubiConf.scala @@ -576,7 +576,7 @@ object KyuubiConf { .doc("Stop timeout for Jetty server used by the RESTful frontend service.") .version("1.8.1") .timeConf - .createWithDefaultString("5s") + .createWithDefaultString("PT5S") val FRONTEND_WORKER_KEEPALIVE_TIME: ConfigEntry[Long] = buildConf("kyuubi.frontend.worker.keepalive.time") @@ -1136,7 +1136,7 @@ object KyuubiConf { .doc("Stop timeout for Jetty server used by the Trino frontend service.") .version("1.8.1") .timeConf - .createWithDefaultString("5s") + .createWithDefaultString("PT5S") val KUBERNETES_CONTEXT: OptionalConfigEntry[String] = buildConf("kyuubi.kubernetes.context")