Skip to content

Commit

Permalink
addConfigsToBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Nov 24, 2023
1 parent a3657ee commit 299baa7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ trait WithFlinkSQLEngineOnYarn extends KyuubiFunSuite with WithFlinkTestResource
conf.set(k, v)
}

for ((k, v) <- conf.getAll) {
command ++= confKeyValue(k, v)
}
addConfigsToBuffer(command, conf.getAll)

processBuilder.command(command.toList.asJava)
processBuilder.redirectOutput(Redirect.INHERIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ class ChatProcessBuilder(

buffer ++= confKeyValue(KYUUBI_SESSION_USER_KEY, proxyUser)

conf.getAll.foreach { case (k, v) =>
buffer ++= confKeyValue(k, v)
}
addConfigsToBuffer(buffer, conf.getAll)
buffer.toArray
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,8 @@ class FlinkProcessBuilder(
buffer += s"${mainResource.get}"

buffer ++= confKeyValue(KYUUBI_SESSION_USER_KEY, proxyUser)
conf.getAll.foreach { case (k, v) =>
if (k.startsWith("kyuubi.")) {
buffer ++= confKeyValue(k, v)
}
}

addConfigsToBuffer(buffer, conf.getAll.filter(_._1.startsWith("kyuubi.")))

buffer.toArray

Expand Down Expand Up @@ -205,9 +202,8 @@ class FlinkProcessBuilder(

buffer ++= confKeyValue(KYUUBI_SESSION_USER_KEY, proxyUser)

conf.getAll.foreach { case (k, v) =>
buffer ++= confKeyValue(k, v)
}
addConfigsToBuffer(buffer, conf.getAll)

buffer.toArray
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ class JdbcProcessBuilder(

buffer ++= confKeyValue(KYUUBI_SESSION_USER_KEY, proxyUser)

for ((k, v) <- conf.getAll) {
buffer ++= confKeyValue(k, v)
}
addConfigsToBuffer(buffer, conf.getAll)

buffer.toArray
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ class TrinoProcessBuilder(
// or just leave it, because we can handle it at operation layer
buffer ++= confKeyValue(KYUUBI_SESSION_USER_KEY, proxyUser)

for ((k, v) <- conf.getAll) {
buffer ++= confKeyValue(k, v)
}
addConfigsToBuffer(buffer, conf.getAll)

buffer.toArray
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.kyuubi.util.command

import scala.collection.mutable

object CommandUtils {
val CONF = "--conf"

Expand All @@ -36,9 +38,14 @@ object CommandUtils {
* @param value
* @return
*/
def confKeyValue(key: String, value: String): Iterable[String] =
def confKeyValue(key: String, value: String): Traversable[String] =
Seq(CONF, getKeyValuePair(key, value))

def confKeyValueStr(key: String, value: String): String =
s"$CONF ${getKeyValuePair(key, value)}"

def addConfigsToBuffer(
commandBuffer: mutable.Buffer[String],
configs: Iterable[(String, String)]): Unit =
configs.foreach { case (k, v) => commandBuffer ++= confKeyValue(k, v) }
}

0 comments on commit 299baa7

Please sign in to comment.