From fa91d17f6887c25d51d522b4bf43d4ab3c608f98 Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Tue, 3 Jul 2018 15:56:11 -0500 Subject: [PATCH] HIVE-20077 : hcat command should follow same pattern as hive cli for getting HBase jars --- hcatalog/bin/hcat | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/hcatalog/bin/hcat b/hcatalog/bin/hcat index 7889263671..2211407d1a 100644 --- a/hcatalog/bin/hcat +++ b/hcatalog/bin/hcat @@ -145,18 +145,37 @@ fi # Put external jars, hcat jar, and config file in the classpath HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:${HCAT_CLASSPATH}:${HCAT_JAR}:${HIVE_CONF_DIR} -# Look for HBase in a BigTop-compatible way. Avoid thrift version -# conflict with modern versions of HBase. +# 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:-"${HBASE_HOME}/conf"} -if [ -d ${HBASE_HOME} ] ; then - for jar in $(find $HBASE_HOME -name '*.jar' -not -name '*thrift*'); do - HBASE_CLASSPATH=$HBASE_CLASSPATH:${jar} - done - export HADOOP_CLASSPATH="${HADOOP_CLASSPATH}:${HBASE_CLASSPATH}" -fi -if [ -d $HBASE_CONF_DIR ] ; then - HADOOP_CLASSPATH="${HADOOP_CLASSPATH}:${HBASE_CONF_DIR}" +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)"} + +# 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>&2 | 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 export HADOOP_CLASSPATH=$HADOOP_CLASSPATH -- 2.16.1