Skip to content

Commit 679d23f

Browse files
a49ayaooqinn
authored andcommitted
[KYUUBI #2433] HiveSQLEngine load required jars from HIVE_HADOOP_CLASSPATH
### _Why are the changes needed?_ We submit a hive job to yarn, when we don't set `kyuubi.engine.hive.extra.classpath`, HiveSQLEngine will throw an error. My improvement is supporting set `HIVE_HADOOP_CLASSPATH` ### _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 - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #2446 from deadwind4/hive-cp. Closes #2433 7caa7fb [Ada Wang] update template 45598cb [Ada Wang] update template c7d3409 [Ada Wang] [KYUUBI #2433] Load jars from HIVE_HADOOP_CLASSPATH Authored-by: Ada Wang <wang4luning@gmail.com> Signed-off-by: Kent Yao <yao@apache.org>
1 parent 7b70a6a commit 679d23f

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

conf/kyuubi-env.sh.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
# - FLINK_HOME Flink distribution which you would like to use in Kyuubi.
4747
# - FLINK_CONF_DIR Optional directory where the Flink configuration lives.
4848
# (Default: $FLINK_HOME/conf)
49+
# - HIVE_HOME Hive distribution which you would like to use in Kyuubi.
50+
# - HIVE_CONF_DIR Optional directory where the Hive configuration lives.
51+
# (Default: $HIVE_HOME/conf)
52+
# - HIVE_HADOOP_CLASSPATH Required Hadoop jars when you use the Kyuubi Hive engine.
4953
#
5054

5155

@@ -54,6 +58,8 @@
5458
# export JAVA_HOME=/usr/jdk64/jdk1.8.0_152
5559
# export SPARK_HOME=/opt/spark
5660
# export FLINK_HOME=/opt/flink
61+
# export HIVE_HOME=/opt/hive
62+
# export HIVE_HADOOP_CLASSPATH=${HADOOP_HOME}/share/hadoop/common/lib/commons-collections-3.2.2.jar:${HADOOP_HOME}/share/hadoop/client/hadoop-client-runtime-3.1.0.jar:${HADOOP_HOME}/share/hadoop/client/hadoop-client-api-3.1.0.jar:${HADOOP_HOME}/share/hadoop/common/lib/htrace-core4-4.1.0-incubating.jar
5763
# export HADOOP_CONF_DIR=/usr/ndp/current/mapreduce_client/conf
5864
# export YARN_CONF_DIR=/usr/ndp/current/yarn/conf
5965
# export KYUUBI_JAVA_OPTS="-Xmx10g -XX:+UnlockDiagnosticVMOptions -XX:ParGCCardsPerStrideChunk=4096 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSInitiatingOccupancyOnly -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:+UseCondCardMark -XX:MaxDirectMemorySize=1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./logs -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -Xloggc:./logs/kyuubi-server-gc-%t.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=5M -XX:NewRatio=3 -XX:MetaspaceSize=512m"

docs/deployment/settings.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ You can configure the environment variables in `$KYUUBI_HOME/conf/kyuubi-env.sh`
8181
# - FLINK_HOME Flink distribution which you would like to use in Kyuubi.
8282
# - FLINK_CONF_DIR Optional directory where the Flink configuration lives.
8383
# (Default: $FLINK_HOME/conf)
84+
# - HIVE_HOME Hive distribution which you would like to use in Kyuubi.
85+
# - HIVE_CONF_DIR Optional directory where the Hive configuration lives.
86+
# (Default: $HIVE_HOME/conf)
87+
# - HIVE_HADOOP_CLASSPATH Required Hadoop jars when you use the Kyuubi Hive engine.
8488
#
8589

8690

@@ -89,6 +93,8 @@ You can configure the environment variables in `$KYUUBI_HOME/conf/kyuubi-env.sh`
8993
# export JAVA_HOME=/usr/jdk64/jdk1.8.0_152
9094
# export SPARK_HOME=/opt/spark
9195
# export FLINK_HOME=/opt/flink
96+
# export HIVE_HOME=/opt/hive
97+
# export HIVE_HADOOP_CLASSPATH=${HADOOP_HOME}/share/hadoop/common/lib/commons-collections-3.2.2.jar:${HADOOP_HOME}/share/hadoop/client/hadoop-client-runtime-3.1.0.jar:${HADOOP_HOME}/share/hadoop/client/hadoop-client-api-3.1.0.jar:${HADOOP_HOME}/share/hadoop/common/lib/htrace-core4-4.1.0-incubating.jar
9298
# export HADOOP_CONF_DIR=/usr/ndp/current/mapreduce_client/conf
9399
# export YARN_CONF_DIR=/usr/ndp/current/yarn/conf
94100
# export KYUUBI_JAVA_OPTS="-Xmx10g -XX:+UnlockDiagnosticVMOptions -XX:ParGCCardsPerStrideChunk=4096 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSInitiatingOccupancyOnly -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:+UseCondCardMark -XX:MaxDirectMemorySize=1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./logs -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -Xloggc:./logs/kyuubi-server-gc-%t.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=5M -XX:NewRatio=3 -XX:MetaspaceSize=512m"

kyuubi-server/src/main/scala/org/apache/kyuubi/engine/hive/HiveProcessBuilder.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class HiveProcessBuilder(
3939

4040
private val hiveHome: String = getEngineHome("hive")
4141

42+
private val HIVE_HADOOP_CLASSPATH: String = "HIVE_HADOOP_CLASSPATH"
43+
4244
override protected def module: String = "kyuubi-hive-sql-engine"
4345

4446
override protected def mainClass: String = "org.apache.kyuubi.engine.hive.HiveSQLEngine"
@@ -77,18 +79,21 @@ class HiveProcessBuilder(
7779
env.get("YARN_CONF_DIR").foreach(classpathEntries.add)
7880
// jars from hive distribution
7981
classpathEntries.add(s"$hiveHome${File.separator}lib${File.separator}*")
82+
val hadoopCp = env.get(HIVE_HADOOP_CLASSPATH)
83+
hadoopCp.foreach(classpathEntries.add)
8084
val extraCp = conf.get(ENGINE_HIVE_EXTRA_CLASSPATH)
8185
extraCp.foreach(classpathEntries.add)
82-
if (extraCp.isEmpty) {
83-
warn(s"The conf of kyuubi.engine.hive.extra.classpath is empty.")
86+
if (hadoopCp.isEmpty && extraCp.isEmpty) {
87+
warn(s"The conf of ${HIVE_HADOOP_CLASSPATH} or ${ENGINE_HIVE_EXTRA_CLASSPATH} is empty.")
88+
debug("Detected development environment")
8489
mainResource.foreach { path =>
8590
val devHadoopJars = Paths.get(path).getParent
8691
.resolve(s"scala-$SCALA_COMPILE_VERSION")
8792
.resolve("jars")
8893
if (!Files.exists(devHadoopJars)) {
89-
throw new KyuubiException(s"The path $devHadoopJars does not exists. Please set " +
90-
s"kyuubi.engine.hive.extra.classpath for configuring location of " +
91-
s"hadoop client jars, etc")
94+
throw new KyuubiException(s"The path $devHadoopJars does not exists. " +
95+
s"Please set ${HIVE_HADOOP_CLASSPATH} or ${ENGINE_HIVE_EXTRA_CLASSPATH} for " +
96+
s"configuring location of hadoop client jars, etc")
9297
}
9398
classpathEntries.add(s"$devHadoopJars${File.separator}*")
9499
}

0 commit comments

Comments
 (0)