From f367952b8d9a7b379d51facf78ed2739008e669b Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Mon, 18 Nov 2013 12:27:59 -0800 Subject: [PATCH] HIVE-2055 include hbase dependencies in launch script Look for HBase and dependencies. If available, include them in the launch classpath. --- bin/hive | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/bin/hive b/bin/hive index d26d867..40e2c75 100755 --- a/bin/hive +++ b/bin/hive @@ -196,6 +196,39 @@ if [ "$hadoop_major_ver" -lt "1" -a "$hadoop_minor_ver$hadoop_patch_ver" -lt "2 exit 6 fi +# HBase detection. Need bin/hbase and a conf dir for building classpath entries. +# Start with BigTop defaults for HBASE_HOME and HBASE_CONF_DIR. +HBASE_HOME=${HBASE_HOME:-"/usr/lib/hbase"} +HBASE_CONF_DIR=${HBASE_CONF_DIR:-"/etc/hbase/conf"} +if [[ ! -d $HBASE_CONF_DIR ]] ; then + # not explicitly set, nor in BigTop location. Try looking in HBASE_HOME. + HBASE_CONF_DIR="$HBASE_HOME/conf" +fi + +# perhaps we've located the HBase config. if so, include it on classpath. +if [[ -d $HBASE_CONF_DIR ]] ; then + export HADOOP_CLASSPATH="${HADOOP_CLASSPATH}:${HBASE_CONF_DIR}" +fi + +# look for the hbase script. First check HBASE_HOME and then ask PATH. +if [[ -e $HBASE_HOME/bin/hbase ]] ; then + HBASE_BIN="$HBASE_HOME/bin/hbase" +fi +HBASE_BIN=${HBASE_BIN:-"$(which hbase 2>/dev/null)"} + +# perhaps we've located HBase. If so, include its details on the classpath +if [[ -n $HBASE_BIN ]] ; then + # exclude ZK, PB, and Guava (See HIVE-2055) + # depends on HBASE-8438 (hbase-0.94.14+, hbase-0.96.1+) for `hbase mapredcp` command + for x in $($HBASE_BIN mapredcp 2>/dev/null | tr ':' '\n') ; do + if [[ $x == *zookeeper* || $x == *protobuf-java* || $x == *guava* ]] ; then + continue + fi + # TODO: should these should be added to AUX_PARAM as well? + export HADOOP_CLASSPATH="${HADOOP_CLASSPATH}:${x}" + done +fi + if [ "${AUX_PARAM}" != "" ]; then HIVE_OPTS="$HIVE_OPTS -hiveconf hive.aux.jars.path=${AUX_PARAM}" AUX_JARS_CMD_LINE="-libjars ${AUX_PARAM}" -- 1.8.4.2