wangzhigang1999 commented on code in PR #7385: URL: https://github.com/apache/kyuubi/pull/7385#discussion_r3063124977
########## kyuubi-server/src/main/scala/org/apache/kyuubi/engine/dataagent/DataAgentProcessBuilder.scala: ########## @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.kyuubi.engine.dataagent + +import java.io.File +import java.nio.file.{Files, Paths} + +import scala.collection.mutable + +import com.google.common.annotations.VisibleForTesting +import org.apache.commons.lang3.StringUtils + +import org.apache.kyuubi.{Logging, SCALA_COMPILE_VERSION, Utils} +import org.apache.kyuubi.config.KyuubiConf +import org.apache.kyuubi.config.KyuubiConf._ +import org.apache.kyuubi.config.KyuubiReservedKeys.{KYUUBI_ENGINE_ID, KYUUBI_SESSION_USER_KEY} +import org.apache.kyuubi.engine.ProcBuilder +import org.apache.kyuubi.operation.log.OperationLog +import org.apache.kyuubi.util.command.CommandLineUtils._ + +class DataAgentProcessBuilder( + override val proxyUser: String, + override val doAsEnabled: Boolean, + override val conf: KyuubiConf, + val engineRefId: String, + val extraEngineLog: Option[OperationLog] = None) + extends ProcBuilder with Logging { + + @VisibleForTesting + def this(proxyUser: String, doAsEnabled: Boolean, conf: KyuubiConf) = { + this(proxyUser, doAsEnabled, conf, "") + } + + override def shortName: String = "data-agent" + + override protected def module: String = "kyuubi-data-agent-engine" + + override protected def mainClass: String = + "org.apache.kyuubi.engine.dataagent.DataAgentEngine" + + override protected val commands: Iterable[String] = { + val buffer = new mutable.ListBuffer[String]() + buffer += executable + + val memory = conf.get(ENGINE_DATA_AGENT_MEMORY) + buffer += s"-Xmx$memory" + buffer += "-Dfile.encoding=UTF-8" + + val javaOptions = conf.get(ENGINE_DATA_AGENT_JAVA_OPTIONS).filter(StringUtils.isNotBlank(_)) + if (javaOptions.isDefined) { + buffer ++= parseOptionString(javaOptions.get) + } + + val classpathEntries = new mutable.LinkedHashSet[String] + mainResource.foreach(classpathEntries.add) + mainResource.foreach { path => + val parent = Paths.get(path).getParent + val devDepDir = parent + .resolve(s"scala-$SCALA_COMPILE_VERSION") + .resolve("jars") + if (Files.exists(devDepDir)) { + // add dev classpath + classpathEntries.add(s"$devDepDir${File.separator}*") + } else { + // add prod classpath + classpathEntries.add(s"$parent${File.separator}*") + } + } + + val extraCp = conf.get(ENGINE_DATA_AGENT_EXTRA_CLASSPATH) + extraCp.foreach(classpathEntries.add) + buffer ++= genClasspathOption(classpathEntries) + + buffer += mainClass + + buffer ++= confKeyValue(KYUUBI_SESSION_USER_KEY, proxyUser) + buffer ++= confKeyValue(KYUUBI_ENGINE_ID, engineRefId) + + buffer ++= confKeyValues(conf.getAll) + + buffer + } + + override def toString: String = { Review Comment: Here's the real launch command from a local run (API key redacted by `redactConfValues`): ``` 2026-04-10 14:58:04.968 INFO KyuubiSessionManager-exec-pool: Thread-86 org.apache.kyuubi.engine.EngineRef: Launching engine: /Users/zhigang/Library/Java/JavaVirtualMachines/azul-11.0.23/Contents/Home/bin/java \ -Xmx1g \ -Dfile.encoding=UTF-8 \ -Dkyuubi.frontend.thrift.binary.bind.host=127.0.0.1 \ -cp /Users/zhigang/IdeaProjects/kyuubi/externals/kyuubi-data-agent-engine/target/kyuubi-data-agent-engine_2.12-1.12.0-SNAPSHOT.jar:/Users/zhigang/IdeaProjects/kyuubi/externals/kyuubi-data-agent-engine/target/scala-2.12/jars/* \ org.apache.kyuubi.engine.dataagent.DataAgentEngine \ --conf kyuubi.session.user=anonymous \ --conf kyuubi.engine.id=d8d3181a-ba44-4335-a788-f475330caf21 \ --conf kyuubi.client.ipAddress=127.0.0.1 \ --conf kyuubi.engine.appMgrInfo=eyJyZXNvdXJjZU1hbmFnZXIiOm51bGwsImt1YmVybmV0ZXNJbmZvIjp7ImNvbnRleHQiOm51bGwsIm5hbWVzcGFjZSI6bnVsbH19 \ --conf kyuubi.engine.data.agent.java.options=-Dkyuubi.frontend.thrift.binary.bind.host=127.0.0.1 \ --conf kyuubi.engine.data.agent.jdbc.url=jdbc:sqlite:/Users/zhigang/PycharmProjects/data-insight/benchmarks/bird/minidev/MINIDEV/dev_databases/california_schools/california_schools.sqlite \ --conf kyuubi.engine.data.agent.llm.api.key=*********(redacted) \ --conf kyuubi.engine.data.agent.llm.api.url=https://dashscope.aliyuncs.com/compatible-mode/v1 \ --conf kyuubi.engine.data.agent.llm.model=qwen3.5-plus-2026-02-15 \ --conf kyuubi.engine.data.agent.max.iterations=100 \ --conf kyuubi.engine.data.agent.provider=openai_compatible \ --conf kyuubi.engine.submit.time=1775804284939 \ --conf kyuubi.engine.type=DATA_AGENT \ --conf kyuubi.ha.addresses=30.246.181.34:2181 \ --conf kyuubi.ha.engine.ref.id=d8d3181a-ba44-4335-a788-f475330caf21 \ --conf kyuubi.ha.namespace=/kyuubi_1.12.0-SNAPSHOT_USER_DATA_AGENT/anonymous/ds-2f23fd339a886fe9 \ --conf kyuubi.ha.zookeeper.auth.type=NONE \ --conf kyuubi.server.ipAddress=0.0.0.0 \ --conf kyuubi.session.connection.url=0.0.0.0:10099 \ --conf kyuubi.session.real.user=anonymous ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
