Yikf commented on code in PR #6275: URL: https://github.com/apache/kyuubi/pull/6275#discussion_r1557173950
########## externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/deploy/JdbcYarnModeSubmitter.scala: ########## @@ -0,0 +1,77 @@ +/* + * 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.jdbc.deploy + +import java.io.File + +import scala.collection.mutable.ListBuffer + +import org.apache.hadoop.security.UserGroupInformation + +import org.apache.kyuubi.Utils +import org.apache.kyuubi.config.KyuubiConf +import org.apache.kyuubi.config.KyuubiConf.ENGINE_JDBC_EXTRA_CLASSPATH +import org.apache.kyuubi.engine.deploy.yarn.EngineYarnModeSubmitter +import org.apache.kyuubi.engine.jdbc.JdbcSQLEngine + +object JdbcYarnModeSubmitter extends EngineYarnModeSubmitter { + + def main(args: Array[String]): Unit = { + Utils.fromCommandLineArgs(args, kyuubiConf) + + if (UserGroupInformation.isSecurityEnabled) { + require( + kyuubiConf.get(KyuubiConf.ENGINE_PRINCIPAL).isDefined + && kyuubiConf.get(KyuubiConf.ENGINE_KEYTAB).isDefined, + s"${KyuubiConf.ENGINE_PRINCIPAL.key} and " + + s"${KyuubiConf.ENGINE_KEYTAB.key} must be set when submit " + + s"${JdbcSQLEngine.getClass.getSimpleName.stripSuffix("$")} to YARN") + } + run() + } + + override var engineType: String = "jdbc" + + override def engineMainClass(): String = JdbcSQLEngine.getClass.getName + + /** + * Jar list for the Hive engine. + */ + override def engineExtraJars(): Seq[File] = { + val hadoopCp = sys.env.get("HIVE_HADOOP_CLASSPATH") + val extraCp = kyuubiConf.get(ENGINE_JDBC_EXTRA_CLASSPATH) + val jars = new ListBuffer[File] + hadoopCp.foreach(cp => parseClasspath(cp, jars)) + extraCp.foreach(cp => parseClasspath(cp, jars)) + jars.toSeq + } + + private[jdbc] def parseClasspath(classpath: String, jars: ListBuffer[File]): Unit = { Review Comment: Should this be a public function? ########## externals/kyuubi-jdbc-engine/src/main/scala/org/apache/kyuubi/engine/jdbc/deploy/JdbcYarnModeSubmitter.scala: ########## @@ -0,0 +1,77 @@ +/* + * 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.jdbc.deploy + +import java.io.File + +import scala.collection.mutable.ListBuffer + +import org.apache.hadoop.security.UserGroupInformation + +import org.apache.kyuubi.Utils +import org.apache.kyuubi.config.KyuubiConf +import org.apache.kyuubi.config.KyuubiConf.ENGINE_JDBC_EXTRA_CLASSPATH +import org.apache.kyuubi.engine.deploy.yarn.EngineYarnModeSubmitter +import org.apache.kyuubi.engine.jdbc.JdbcSQLEngine + +object JdbcYarnModeSubmitter extends EngineYarnModeSubmitter { + + def main(args: Array[String]): Unit = { + Utils.fromCommandLineArgs(args, kyuubiConf) + + if (UserGroupInformation.isSecurityEnabled) { + require( + kyuubiConf.get(KyuubiConf.ENGINE_PRINCIPAL).isDefined + && kyuubiConf.get(KyuubiConf.ENGINE_KEYTAB).isDefined, + s"${KyuubiConf.ENGINE_PRINCIPAL.key} and " + + s"${KyuubiConf.ENGINE_KEYTAB.key} must be set when submit " + + s"${JdbcSQLEngine.getClass.getSimpleName.stripSuffix("$")} to YARN") + } + run() + } + + override var engineType: String = "jdbc" + + override def engineMainClass(): String = JdbcSQLEngine.getClass.getName + + /** + * Jar list for the Hive engine. + */ + override def engineExtraJars(): Seq[File] = { + val hadoopCp = sys.env.get("HIVE_HADOOP_CLASSPATH") Review Comment: nit ########## kyuubi-server/src/main/scala/org/apache/kyuubi/engine/jdbc/JdbcProcessBuilder.scala: ########## @@ -113,3 +116,55 @@ class JdbcProcessBuilder( } } } + +object JdbcProcessBuilder extends Logging { + + final val JDBC_ENGINE_NAME = "jdbc.engine.name" + + def apply( + proxyUser: String, + doAsEnabled: Boolean, + conf: KyuubiConf, + engineRefId: String, + extraEngineLog: Option[OperationLog], + defaultEngineName: String): JdbcProcessBuilder = { + checkKeytab(proxyUser, conf) + DeployMode.withName(conf.get(ENGINE_JDBC_DEPLOY_MODE)) match { + case LOCAL => + new JdbcProcessBuilder(proxyUser, doAsEnabled, conf, engineRefId, extraEngineLog) + case YARN => + warn(s"Hive on YARN model is experimental.") Review Comment: nit: Hive -> JDBC Engine ########## kyuubi-server/src/main/scala/org/apache/kyuubi/engine/jdbc/JdbcYarnModeProcessBuilder.scala: ########## @@ -0,0 +1,135 @@ +/* + * 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.jdbc + +import java.io.File +import java.nio.file.Paths +import java.util + +import scala.collection.JavaConverters._ +import scala.collection.mutable.ArrayBuffer + +import org.apache.kyuubi.{Logging, SCALA_COMPILE_VERSION, Utils} +import org.apache.kyuubi.config.KyuubiConf +import org.apache.kyuubi.config.KyuubiConf.{ENGINE_JDBC_EXTRA_CLASSPATH, ENGINE_JDBC_MEMORY} +import org.apache.kyuubi.config.KyuubiReservedKeys.{KYUUBI_ENGINE_ID, KYUUBI_SESSION_USER_KEY} +import org.apache.kyuubi.engine.{ApplicationManagerInfo, KyuubiApplicationManager} +import org.apache.kyuubi.engine.deploy.yarn.EngineYarnModeSubmitter._ +import org.apache.kyuubi.operation.log.OperationLog +import org.apache.kyuubi.util.command.CommandLineUtils.{confKeyValue, confKeyValues} + +/** + * A process builder for Hive on Yarn. Review Comment: nit. You can check overall if the ported code has been modified from Hive to JDBC. ########## kyuubi-common/src/main/scala/org/apache/kyuubi/engine/deploy/yarn/EngineYarnModeSubmitter.scala: ########## @@ -315,8 +315,10 @@ abstract class EngineYarnModeSubmitter extends Logging { } // respect the following priority loading configuration, and distinct files // hive configuration -> hadoop configuration -> yarn configuration - val hiveConf = kyuubiConf.getOption(KYUUBI_ENGINE_DEPLOY_YARN_MODE_HIVE_CONF_KEY) - listDistinctFiles(hiveConf.get).foreach(putEntry) + if ("hive".equalsIgnoreCase(engineType)) { Review Comment: For this class, we want it to be as generic as possible. Can it be better abstracted? This would allow different subclasses to implement varying logic. ########## externals/kyuubi-jdbc-engine/src/test/scala/org/apache/kyuubi/engine/jdbc/deploy/JdbcYarnModeSubmitterSuite.scala: ########## @@ -0,0 +1,40 @@ +/* + * 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.jdbc.deploy + +import java.io.File + +import scala.collection.mutable.ListBuffer + +import org.apache.kyuubi.{KYUUBI_VERSION, KyuubiFunSuite, SCALA_COMPILE_VERSION} +import org.apache.kyuubi.util.JavaUtils + +class JdbcYarnModeSubmitterSuite extends KyuubiFunSuite { Review Comment: If those functions become public, this suite will no longer be necessary. ########## integration-tests/kyuubi-jdbc-it/src/test/scala/org/apache/kyuubi/it/jdbc/doris/WithKyuubiServerAndDorisContainerYarnMode.scala: ########## @@ -0,0 +1,64 @@ +/* + * 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.it.jdbc.doris + +import java.nio.file.{Files, Path, Paths} + +import org.apache.kyuubi.WithKyuubiServerAndHadoopMiniCluster +import org.apache.kyuubi.config.KyuubiConf +import org.apache.kyuubi.config.KyuubiConf.{ENGINE_IDLE_TIMEOUT, ENGINE_JDBC_EXTRA_CLASSPATH, ENGINE_TYPE, KYUUBI_ENGINE_ENV_PREFIX, KYUUBI_HOME} +import org.apache.kyuubi.engine.deploy.DeployMode +import org.apache.kyuubi.engine.jdbc.doris.WithDorisEngine + +trait WithKyuubiServerAndDorisContainerYarnMode extends WithKyuubiServerAndHadoopMiniCluster Review Comment: Perhaps we only need to validate one JDBC engine? Because the logic for yarn mode is the same. -- 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]
