Skip to content

Commit

Permalink
use Iterable as data type of process builder's commands
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Nov 24, 2023
1 parent 4d48796 commit d2d0fe2
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ object Utils extends Logging {

private val PATTERN_FOR_KEY_VALUE_ARG = "(.+?)=(.+)".r

def redactCommandLineArgs(conf: KyuubiConf, commands: Array[String]): Array[String] = {
def redactCommandLineArgs(conf: KyuubiConf, commands: Iterable[String]): Iterable[String] = {
val redactionPattern = conf.get(SERVER_SECRET_REDACTION_PATTERN)
var nextKV = false
commands.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class UtilsSuite extends KyuubiFunSuite {
buffer += "--conf"
buffer += "kyuubi.regular.property2=regular_value"

val commands = buffer.toArray
val commands = buffer

// Redact sensitive information
val redactedCmdArgs = Utils.redactCommandLineArgs(conf, commands)
Expand All @@ -183,7 +183,7 @@ class UtilsSuite extends KyuubiFunSuite {
expectBuffer += "--conf"
expectBuffer += "kyuubi.regular.property2=regular_value"

assert(expectBuffer.toArray === redactedCmdArgs)
assert(expectBuffer === redactedCmdArgs)
}

test("redact sensitive information") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ trait ProcBuilder {

protected def proxyUser: String

protected val commands: Array[String]
protected val commands: Iterable[String]

def conf: KyuubiConf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ChatProcessBuilder(
*/
override protected def mainClass: String = "org.apache.kyuubi.engine.chat.ChatEngine"

override protected val commands: Array[String] = {
override protected val commands: Iterable[String] = {
val buffer = new ArrayBuffer[String]()
buffer += executable

Expand Down Expand Up @@ -98,7 +98,7 @@ class ChatProcessBuilder(
buffer += "--conf"
buffer += s"$k=$v"
}
buffer.toArray
buffer
}

override def toString: String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class FlinkProcessBuilder(
ApplicationManagerInfo(clusterManager())
}

override protected val commands: Array[String] = {
override protected val commands: Iterable[String] = {
KyuubiApplicationManager.tagApplication(engineRefId, shortName, clusterManager(), conf)
// unset engine credentials because Flink doesn't support them at the moment
conf.unset(KyuubiReservedKeys.KYUUBI_ENGINE_CREDENTIALS_KEY)
Expand Down Expand Up @@ -143,7 +143,7 @@ class FlinkProcessBuilder(
}
}

buffer.toArray
buffer

case _ =>
val buffer = new ArrayBuffer[String]()
Expand Down Expand Up @@ -211,7 +211,7 @@ class FlinkProcessBuilder(
buffer += "--conf"
buffer += s"$k=$v"
}
buffer.toArray
buffer
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class HiveProcessBuilder(

override protected def mainClass: String = "org.apache.kyuubi.engine.hive.HiveSQLEngine"

override protected val commands: Array[String] = {
override protected val commands: Iterable[String] = {
KyuubiApplicationManager.tagApplication(engineRefId, shortName, clusterManager(), conf)
val buffer = new ArrayBuffer[String]()
buffer += executable
Expand Down Expand Up @@ -113,7 +113,7 @@ class HiveProcessBuilder(
buffer += "--conf"
buffer += s"$k=$v"
}
buffer.toArray
buffer
}

override def shortName: String = "hive"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class JdbcProcessBuilder(
*/
override protected def mainClass: String = "org.apache.kyuubi.engine.jdbc.JdbcSQLEngine"

override protected val commands: Array[String] = {
override protected val commands: Iterable[String] = {
require(
conf.get(ENGINE_JDBC_CONNECTION_URL).nonEmpty,
s"Jdbc server url can not be null! Please set ${ENGINE_JDBC_CONNECTION_URL.key}")
Expand Down Expand Up @@ -101,7 +101,7 @@ class JdbcProcessBuilder(
buffer += "--conf"
buffer += s"$k=$v"
}
buffer.toArray
buffer
}

override def toString: String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SparkBatchProcessBuilder(
extends SparkProcessBuilder(proxyUser, conf, batchId, extraEngineLog) {
import SparkProcessBuilder._

override protected lazy val commands: Array[String] = {
override protected lazy val commands: Iterable[String] = {
val buffer = new ArrayBuffer[String]()
buffer += executable
Option(mainClass).foreach { cla =>
Expand Down Expand Up @@ -66,7 +66,7 @@ class SparkBatchProcessBuilder(

batchArgs.foreach { arg => buffer += arg }

buffer.toArray
buffer
}

private def sparkAppNameConf(): Map[String, String] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class SparkProcessBuilder(
file.isDirectory && r.findFirstMatchIn(file.getName).isDefined
}

override protected lazy val commands: Array[String] = {
override protected lazy val commands: Iterable[String] = {
// complete `spark.master` if absent on kubernetes
completeMasterUrl(conf)

Expand All @@ -149,7 +149,7 @@ class SparkProcessBuilder(

mainResource.foreach { r => buffer += r }

buffer.toArray
buffer
}

override protected def module: String = "kyuubi-spark-sql-engine"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TrinoProcessBuilder(

override protected def mainClass: String = "org.apache.kyuubi.engine.trino.TrinoSqlEngine"

override protected val commands: Array[String] = {
override protected val commands: Iterable[String] = {
KyuubiApplicationManager.tagApplication(engineRefId, shortName, clusterManager(), conf)
require(
conf.get(ENGINE_TRINO_CONNECTION_URL).nonEmpty,
Expand Down Expand Up @@ -104,7 +104,7 @@ class TrinoProcessBuilder(
buffer += "--conf"
buffer += s"$k=$v"
}
buffer.toArray
buffer
}

override def shortName: String = "trino"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,5 @@ class SparkProcessBuilderSuite extends KerberizedTestHelper with MockitoSugar {

class FakeSparkProcessBuilder(config: KyuubiConf)
extends SparkProcessBuilder("fake", config) {
override protected lazy val commands: Array[String] = Array("ls")
override protected lazy val commands: Iterable[String] = Seq("ls")
}

0 comments on commit d2d0fe2

Please sign in to comment.