[KYUUBI #1764] Reuse the workingDir in ProcBuilder
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> Reuse the workingDir in ProcBuilder for Trino ### _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 - [X] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1765 from hddong/reuse-workDir. Closes #1764 41152daf [hongdongdong] fix c687d4fa [hongdongdong] [KYUUBI #1764] Reuse the workingDir in ProcBuilder Authored-by: hongdongdong <hongdongdong@cmss.chinamobile.com> Signed-off-by: Kent Yao <yao@apache.org>
This commit is contained in:
parent
7ef612cdea
commit
4f2c2cb89e
@ -19,14 +19,12 @@ package org.apache.kyuubi.engine.trino
|
||||
|
||||
import java.net.URI
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
import org.apache.kyuubi.KYUUBI_VERSION
|
||||
import org.apache.kyuubi.KyuubiSQLException
|
||||
import org.apache.kyuubi.Logging
|
||||
import org.apache.kyuubi.SCALA_COMPILE_VERSION
|
||||
import org.apache.kyuubi.Utils
|
||||
import org.apache.kyuubi.config.KyuubiConf
|
||||
import org.apache.kyuubi.config.KyuubiConf.ENGINE_TRINO_CONNECTION_CATALOG
|
||||
import org.apache.kyuubi.config.KyuubiConf.ENGINE_TRINO_CONNECTION_URL
|
||||
@ -114,32 +112,6 @@ class TrinoProcessBuilder(
|
||||
|
||||
override protected def commands: Array[String] = Array(executable)
|
||||
|
||||
override protected val workingDir: Path = {
|
||||
env.get("KYUUBI_WORK_DIR_ROOT").map { root =>
|
||||
val workingRoot = Paths.get(root).toAbsolutePath
|
||||
if (!Files.exists(workingRoot)) {
|
||||
debug(s"Creating KYUUBI_WORK_DIR_ROOT at $workingRoot")
|
||||
Files.createDirectories(workingRoot)
|
||||
}
|
||||
if (Files.isDirectory(workingRoot)) {
|
||||
workingRoot.toString
|
||||
} else null
|
||||
}.map { rootAbs =>
|
||||
val working = Paths.get(rootAbs, proxyUser)
|
||||
if (!Files.exists(working)) {
|
||||
debug(s"Creating $proxyUser's working directory at $working")
|
||||
Files.createDirectories(working)
|
||||
}
|
||||
if (Files.isDirectory(working)) {
|
||||
working
|
||||
} else {
|
||||
Utils.createTempDir(rootAbs, proxyUser)
|
||||
}
|
||||
}.getOrElse {
|
||||
Utils.createTempDir(namePrefix = proxyUser)
|
||||
}
|
||||
}
|
||||
|
||||
override def toString: String = commands.map {
|
||||
case arg if arg.startsWith("--") => s"\\\n\t$arg"
|
||||
case arg => arg
|
||||
|
||||
Loading…
Reference in New Issue
Block a user