[KYUUBI #1757] Extract workingDir from engine specific process builde…
…r into 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. --> ### _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.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1758 from yanghua/KYUUBI-1757. Closes #1757 14d3673c [yanghua] Fix CI issue d6696919 [yanghua] [KYUUBI #1757] Extract workingDir from engine specific process builder into ProcBuilder Authored-by: yanghua <yanghua1127@gmail.com> Signed-off-by: Kent Yao <yao@apache.org>
This commit is contained in:
parent
11556034e3
commit
e032a6218f
@ -20,7 +20,7 @@ package org.apache.kyuubi.engine
|
||||
import java.io.{File, IOException}
|
||||
import java.lang.ProcessBuilder.Redirect
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.nio.file.{Files, Path}
|
||||
import java.nio.file.{Files, Path, Paths}
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.util.matching.Regex
|
||||
@ -28,7 +28,7 @@ import scala.util.matching.Regex
|
||||
import com.google.common.collect.EvictingQueue
|
||||
import org.apache.commons.lang3.StringUtils.containsIgnoreCase
|
||||
|
||||
import org.apache.kyuubi.{KyuubiSQLException, Logging}
|
||||
import org.apache.kyuubi.{KyuubiSQLException, Logging, Utils}
|
||||
import org.apache.kyuubi.config.KyuubiConf
|
||||
import org.apache.kyuubi.operation.log.OperationLog
|
||||
import org.apache.kyuubi.util.NamedThreadFactory
|
||||
@ -57,7 +57,31 @@ trait ProcBuilder {
|
||||
|
||||
protected val extraEngineLog: Option[OperationLog]
|
||||
|
||||
protected val workingDir: Path
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
final lazy val processBuilder: ProcessBuilder = {
|
||||
val pb = new ProcessBuilder(commands: _*)
|
||||
|
||||
@ -19,7 +19,7 @@ package org.apache.kyuubi.engine.flink
|
||||
|
||||
import java.io.{File, FilenameFilter}
|
||||
import java.net.URI
|
||||
import java.nio.file.{Files, Path, Paths}
|
||||
import java.nio.file.{Files, Paths}
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting
|
||||
|
||||
@ -99,32 +99,6 @@ class FlinkProcessBuilder(
|
||||
|
||||
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
|
||||
|
||||
@ -19,7 +19,7 @@ package org.apache.kyuubi.engine.spark
|
||||
|
||||
import java.io.{File, FilenameFilter, IOException}
|
||||
import java.net.URI
|
||||
import java.nio.file.{Files, Path, Paths}
|
||||
import java.nio.file.{Files, Paths}
|
||||
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
||||
@ -98,32 +98,6 @@ class SparkProcessBuilder(
|
||||
}
|
||||
}
|
||||
|
||||
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 protected def commands: Array[String] = {
|
||||
val buffer = new ArrayBuffer[String]()
|
||||
buffer += executable
|
||||
|
||||
Loading…
Reference in New Issue
Block a user