Skip to content

Commit 4f4960c

Browse files
zhaomin1423yaooqinn
authored andcommitted
[KYUUBI #2368] [Improvement] Command OptionParser for launching Trino Backend Engine
### _Why are the changes needed?_ Command OptionParser for launching Trino Backend Engine ### _How was this patch tested?_ - [ ] 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.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #2417 from zhaomin1423/trino_option_parser. Closes #2368 c644c79 [Min Zhao] [KYUUBI #2368] [Improvement] Command OptionParser for launching Trino Backend Engine Authored-by: Min Zhao <zhaomin1423@163.com> Signed-off-by: Kent Yao <yao@apache.org>
1 parent bafc2f8 commit 4f4960c

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

externals/kyuubi-trino-engine/src/main/scala/org/apache/kyuubi/engine/trino/TrinoSqlEngine.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package org.apache.kyuubi.engine.trino
1919

2020
import java.util.concurrent.CountDownLatch
2121

22-
import org.apache.kyuubi.Logging
22+
import org.apache.kyuubi.{Logging, Utils}
2323
import org.apache.kyuubi.Utils.TRINO_ENGINE_SHUTDOWN_PRIORITY
2424
import org.apache.kyuubi.Utils.addShutdownHook
2525
import org.apache.kyuubi.config.KyuubiConf
@@ -72,6 +72,7 @@ object TrinoSqlEngine extends Logging {
7272
SignalRegister.registerLogger(logger)
7373

7474
try {
75+
Utils.fromCommandLineArgs(args, kyuubiConf)
7576
kyuubiConf.setIfMissing(KyuubiConf.FRONTEND_THRIFT_BINARY_BIND_PORT, 0)
7677
kyuubiConf.setIfMissing(HA_ZK_CONN_RETRY_POLICY, RetryPolicies.N_TIME.toString)
7778

kyuubi-server/src/main/scala/org/apache/kyuubi/engine/trino/TrinoProcessBuilder.scala

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,12 @@ class TrinoProcessBuilder(
5050
val buffer = new ArrayBuffer[String]()
5151
buffer += executable
5252

53-
// TODO: How shall we deal with proxyUser,
54-
// user.name
55-
// kyuubi.session.user
56-
// or just leave it, because we can handle it at operation layer
57-
buffer += s"-D$KYUUBI_SESSION_USER_KEY=$proxyUser"
58-
5953
val memory = conf.get(ENGINE_TRINO_MEMORY)
6054
buffer += s"-Xmx$memory"
6155
val javaOptions = conf.get(ENGINE_TRINO_JAVA_OPTIONS)
6256
if (javaOptions.isDefined) {
6357
buffer += javaOptions.get
6458
}
65-
// -Xmx5g
66-
// java options
67-
for ((k, v) <- conf.getAll) {
68-
buffer += s"-D$k=$v"
69-
}
7059

7160
buffer += "-cp"
7261
val classpathEntries = new LinkedHashSet[String]
@@ -92,6 +81,18 @@ class TrinoProcessBuilder(
9281

9382
buffer += classpathEntries.asScala.mkString(File.pathSeparator)
9483
buffer += mainClass
84+
85+
// TODO: How shall we deal with proxyUser,
86+
// user.name
87+
// kyuubi.session.user
88+
// or just leave it, because we can handle it at operation layer
89+
buffer += "--conf"
90+
buffer += s"$KYUUBI_SESSION_USER_KEY=$proxyUser"
91+
92+
for ((k, v) <- conf.getAll) {
93+
buffer += "--conf"
94+
buffer += s"$k=$v"
95+
}
9596
buffer.toArray
9697
}
9798

kyuubi-server/src/test/scala/org/apache/kyuubi/engine/trino/TrinoProcessBuilderSuite.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package org.apache.kyuubi.engine.trino
2020
import org.apache.kyuubi.KyuubiFunSuite
2121
import org.apache.kyuubi.config.KyuubiConf
2222
import org.apache.kyuubi.config.KyuubiConf._
23+
import org.apache.kyuubi.config.KyuubiReservedKeys.KYUUBI_SESSION_USER_KEY
2324

2425
class TrinoProcessBuilderSuite extends KyuubiFunSuite {
2526

@@ -30,7 +31,10 @@ class TrinoProcessBuilderSuite extends KyuubiFunSuite {
3031
val builder = new TrinoProcessBuilder("kyuubi", conf)
3132
val commands = builder.toString.split("\n")
3233
assert(commands.head.endsWith("java"))
33-
assert(commands.contains(s"-D${ENGINE_TRINO_CONNECTION_URL.key}=dummy_url"))
34+
assert(builder.toString.contains(s"--conf\n${KYUUBI_SESSION_USER_KEY}=kyuubi"))
35+
assert(builder.toString.contains(s"--conf\n${ENGINE_TRINO_CONNECTION_URL.key}=dummy_url"))
36+
assert(builder.toString.contains(
37+
s"--conf\n${ENGINE_TRINO_CONNECTION_CATALOG.key}=dummy_catalog"))
3438
}
3539

3640
test("capture error from trino process builder") {

0 commit comments

Comments
 (0)