You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2022/06/29 10:48:05 UTC
[incubator-kyuubi] branch master updated: [KYUUBI #2956] Support to config the connect/socket timeout of rest client for kyuubi-ctl
This is an automated email from the ASF dual-hosted git repository.
feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 6e4b5582d [KYUUBI #2956] Support to config the connect/socket timeout of rest client for kyuubi-ctl
6e4b5582d is described below
commit 6e4b5582dade5fd67fb6534ab94df4dfa1a20337
Author: Tianlin Liao <ti...@ebay.com>
AuthorDate: Wed Jun 29 18:47:58 2022 +0800
[KYUUBI #2956] Support to config the connect/socket timeout of rest client for kyuubi-ctl
### _Why are the changes needed?_
Close #2956
### _How was this patch tested?_
- [x] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #2958 from lightning-L/kyuubi-2956.
Closes #2956
a88de508 [Tianlin Liao] allow 0 timeout for rest client; increase default timeout
94a57cce [Tianlin Liao] update
d569abe8 [Tianlin Liao] [KYUUBI #2956] Support to config the connection/socket timeout of rest client for kyuubi-ctl
Authored-by: Tianlin Liao <ti...@ebay.com>
Signed-off-by: Fei Wang <fw...@ebay.com>
---
docs/deployment/settings.md | 2 ++
.../main/scala/org/apache/kyuubi/ctl/CtlConf.scala | 24 +++++++++++++++++++---
.../org/apache/kyuubi/ctl/RestClientFactory.scala | 6 ++++++
.../kyuubi/ctl/ControlCliArgumentsSuite.scala | 19 +++++++++++++++++
.../org/apache/kyuubi/client/KyuubiRestClient.java | 4 ++++
5 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/docs/deployment/settings.md b/docs/deployment/settings.md
index f4aaa3bdc..77fabff9d 100644
--- a/docs/deployment/settings.md
+++ b/docs/deployment/settings.md
@@ -190,8 +190,10 @@ Key | Default | Meaning | Type | Since
kyuubi.ctl.batch.log.query.interval|PT3S|The interval for fetching batch logs.|duration|1.6.0
kyuubi.ctl.rest.auth.schema|basic|The authentication schema. Valid values are: basic, spnego.|string|1.6.0
kyuubi.ctl.rest.base.url|<undefined>|The REST API base URL, which contains the scheme (http:// or https://), host name, port number|string|1.6.0
+kyuubi.ctl.rest.connect.timeout|PT30S|The timeout[ms] for establishing the connection with the kyuubi server.A timeout value of zero is interpreted as an infinite timeout.|duration|1.6.0
kyuubi.ctl.rest.request.attempt.wait|PT3S|How long to wait between attempts of ctl rest request.|duration|1.6.0
kyuubi.ctl.rest.request.max.attempts|3|The max attempts number for ctl rest request.|int|1.6.0
+kyuubi.ctl.rest.socket.timeout|PT2M|The timeout[ms] for waiting for data packets after connection is established.A timeout value of zero is interpreted as an infinite timeout.|duration|1.6.0
kyuubi.ctl.rest.spnego.host|<undefined>|When auth schema is spnego, need to config spnego host.|string|1.6.0
diff --git a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/CtlConf.scala b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/CtlConf.scala
index e09a89118..567aadd96 100644
--- a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/CtlConf.scala
+++ b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/CtlConf.scala
@@ -47,21 +47,39 @@ object CtlConf {
.stringConf
.createOptional
- val CTL_REST_CLIENT_REQUEST_MAX_ATTEMPTS =
+ val CTL_REST_CLIENT_CONNECT_TIMEOUT: ConfigEntry[Long] =
+ buildConf("kyuubi.ctl.rest.connect.timeout")
+ .doc("The timeout[ms] for establishing the connection with the kyuubi server." +
+ "A timeout value of zero is interpreted as an infinite timeout.")
+ .version("1.6.0")
+ .timeConf
+ .checkValue(_ >= 0, "must be 0 or positive number")
+ .createWithDefault(Duration.ofSeconds(30).toMillis)
+
+ val CTL_REST_CLIENT_SOCKET_TIMEOUT: ConfigEntry[Long] =
+ buildConf("kyuubi.ctl.rest.socket.timeout")
+ .doc("The timeout[ms] for waiting for data packets after connection is established." +
+ "A timeout value of zero is interpreted as an infinite timeout.")
+ .version("1.6.0")
+ .timeConf
+ .checkValue(_ >= 0, "must be 0 or positive number")
+ .createWithDefault(Duration.ofSeconds(120).toMillis)
+
+ val CTL_REST_CLIENT_REQUEST_MAX_ATTEMPTS: ConfigEntry[Int] =
buildConf("kyuubi.ctl.rest.request.max.attempts")
.doc("The max attempts number for ctl rest request.")
.version("1.6.0")
.intConf
.createWithDefault(3)
- val CTL_REST_CLIENT_REQUEST_ATTEMPT_WAIT =
+ val CTL_REST_CLIENT_REQUEST_ATTEMPT_WAIT: ConfigEntry[Long] =
buildConf("kyuubi.ctl.rest.request.attempt.wait")
.doc("How long to wait between attempts of ctl rest request.")
.version("1.6.0")
.timeConf
.createWithDefault(Duration.ofSeconds(3).toMillis)
- val CTL_BATCH_LOG_QUERY_INTERVAL =
+ val CTL_BATCH_LOG_QUERY_INTERVAL: ConfigEntry[Long] =
buildConf("kyuubi.ctl.batch.log.query.interval")
.doc("The interval for fetching batch logs.")
.version("1.6.0")
diff --git a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/RestClientFactory.scala b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/RestClientFactory.scala
index a3acbbe0a..5821598fa 100644
--- a/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/RestClientFactory.scala
+++ b/kyuubi-ctl/src/main/scala/org/apache/kyuubi/ctl/RestClientFactory.scala
@@ -64,6 +64,8 @@ object RestClientFactory {
val maxAttempts = conf.get(CTL_REST_CLIENT_REQUEST_MAX_ATTEMPTS)
val attemptWaitTime = conf.get(CTL_REST_CLIENT_REQUEST_ATTEMPT_WAIT).toInt
+ val connectionTimeout = conf.get(CTL_REST_CLIENT_CONNECT_TIMEOUT).toInt
+ val socketTimeout = conf.get(CTL_REST_CLIENT_SOCKET_TIMEOUT).toInt
var kyuubiRestClient: KyuubiRestClient = null
authSchema.toLowerCase match {
@@ -75,6 +77,8 @@ object RestClientFactory {
.authHeaderMethod(KyuubiRestClient.AuthHeaderMethod.BASIC)
.username(username)
.password(password)
+ .connectionTimeout(connectionTimeout)
+ .socketTimeout(socketTimeout)
.maxAttempts(maxAttempts)
.attemptWaitTime(attemptWaitTime)
.build()
@@ -85,6 +89,8 @@ object RestClientFactory {
.apiVersion(KyuubiRestClient.ApiVersion.valueOf(version))
.authHeaderMethod(KyuubiRestClient.AuthHeaderMethod.SPNEGO)
.spnegoHost(spnegoHost)
+ .connectionTimeout(connectionTimeout)
+ .socketTimeout(socketTimeout)
.maxAttempts(maxAttempts)
.attemptWaitTime(attemptWaitTime)
.build()
diff --git a/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ControlCliArgumentsSuite.scala b/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ControlCliArgumentsSuite.scala
index 17aa31d12..dc7f0fbed 100644
--- a/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ControlCliArgumentsSuite.scala
+++ b/kyuubi-ctl/src/test/scala/org/apache/kyuubi/ctl/ControlCliArgumentsSuite.scala
@@ -18,6 +18,7 @@
package org.apache.kyuubi.ctl
import org.apache.kyuubi.{KYUUBI_VERSION, KyuubiFunSuite}
+import org.apache.kyuubi.ctl.RestClientFactory.withKyuubiRestClient
import org.apache.kyuubi.ha.HighAvailabilityConf.HA_NAMESPACE
class ControlCliArgumentsSuite extends KyuubiFunSuite with TestPrematureExit {
@@ -468,4 +469,22 @@ class ControlCliArgumentsSuite extends KyuubiFunSuite with TestPrematureExit {
s"${CtlConf.CTL_REST_CLIENT_REQUEST_MAX_ATTEMPTS.key}")
testPrematureExitForControlCliArgs(args2.toArray, "Kyuubi config without '='")
}
+
+ test("test ctl client conf") {
+ val args = Seq(
+ "delete",
+ "batch",
+ "123",
+ "--hostUrl",
+ "https://kyuubi.test.com",
+ "--conf",
+ s"${CtlConf.CTL_REST_CLIENT_CONNECT_TIMEOUT.key}=5000")
+ val opArgs = new ControlCliArguments(args)
+ withKyuubiRestClient(opArgs.cliConfig, null, opArgs.command.conf) { kyuubiRestClient =>
+ assert(kyuubiRestClient.getConf.getConnectTimeout == 5000)
+ assert(kyuubiRestClient.getConf.getSocketTimeout == 120000)
+ assert(kyuubiRestClient.getConf.getMaxAttempts == 3)
+ assert(kyuubiRestClient.getConf.getAttemptWaitTime == 3000)
+ }
+ }
}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/KyuubiRestClient.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/KyuubiRestClient.java
index 93857297f..a6079e9e0 100644
--- a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/KyuubiRestClient.java
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/KyuubiRestClient.java
@@ -133,6 +133,10 @@ public class KyuubiRestClient implements AutoCloseable, Cloneable {
return httpClient;
}
+ public RestClientConf getConf() {
+ return conf;
+ }
+
public static Builder builder(String hostUrl) {
return new Builder(hostUrl);
}