Repository: hive Updated Branches: refs/heads/master 403c1ea9c -> 02a038e23
HIVE-20077: hcat command should follow same pattern as hive cli for getting HBase jars (Sean Busbey, reviewed by Aihua Xu, Sahil Takiar) Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/02a038e2 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/02a038e2 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/02a038e2 Branch: refs/heads/master Commit: 02a038e230e38685d8050a09b1f578f259d578c8 Parents: 403c1ea Author: Sean Busbey <bus...@apache.org> Authored: Fri Jul 6 11:09:57 2018 -0500 Committer: Sahil Takiar <stak...@cloudera.com> Committed: Fri Jul 6 11:09:57 2018 -0500 ---------------------------------------------------------------------- hcatalog/bin/hcat | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/02a038e2/hcatalog/bin/hcat ---------------------------------------------------------------------- diff --git a/hcatalog/bin/hcat b/hcatalog/bin/hcat index 7889263..2211407 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