You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/04/28 01:17:49 UTC

[03/17] kylin git commit: KYLIN-2526 improve find-hive-dependency.sh

KYLIN-2526 improve find-hive-dependency.sh


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/d69cc278
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/d69cc278
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/d69cc278

Branch: refs/heads/master
Commit: d69cc2780d6849ff04d36e24882b932b22f6cc67
Parents: abb73ff
Author: Cheng Wang <ch...@kyligence.io>
Authored: Wed Apr 12 11:39:21 2017 +0800
Committer: liyang-gmt8 <li...@apache.org>
Committed: Wed Apr 12 11:51:31 2017 +0800

----------------------------------------------------------------------
 build/bin/find-hive-dependency.sh | 51 +++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/d69cc278/build/bin/find-hive-dependency.sh
----------------------------------------------------------------------
diff --git a/build/bin/find-hive-dependency.sh b/build/bin/find-hive-dependency.sh
index aa39da0..02a47ef 100644
--- a/build/bin/find-hive-dependency.sh
+++ b/build/bin/find-hive-dependency.sh
@@ -98,8 +98,57 @@ then
     quit "hcatalog lib not found"
 fi
 
+function checkFileExist()
+{
+    files=$1
+    misFiles=0
+    outputMissFiles=
+    for file in ${files//:/ }
+    do
+        let allFiles++
+        if [ ! -f "${file}" ]; then
+            outputMissFiles=${outputMissFiles}${file}", "
+            let misFiles++
+        fi
+    done
+    ratio=`echo "scale=3; ${misFiles}/${allFiles}" | bc`
+    [[ `echo "$ratio < 0.01" | bc ` -eq 1 ]] || quit "A couple of hive jars can't be found: ${outputMisFiles}!"
+}
+
+function validateDirectory()
+{
+    conf_path=$1
+    [[ -d "${conf_path}" ]] || quit "${conf_path} doesn't exist!"
+    unit=${conf_path: -1}
+    [[ "${unit}" == "/" ]] || conf_path=${conf_path}"/"
+
+    find="false"
+    filelist=`ls ${conf_path}`
+    for file in $filelist
+    do
+        if [ "${file}" == "hive-site.xml" ]
+        then
+            find="true"
+            break
+        fi
+    done
+    [[ "${find}" == "true" ]] || quit "ERROR, no hive-site.xml found under dir: ${conf_path}!"
+}
+
+if [ -z "$HIVE_LIB" ]
+then
+    verbose "HIVE_LIB is not set, try to retrieve hive lib from hive_exec_path"
+    hive_lib_dir="$(dirname $hive_exec_path)"
+else
+    hive_lib_dir="$HIVE_LIB"
+fi
+hive_lib=`find -L ${hive_lib_dir} -name '*.jar' ! -name '*calcite*' -printf '%p:' | sed 's/:$//'`
+
+validateDirectory ${hive_conf_path}
+checkFileExist ${hive_lib}
+checkFileExist ${hcatalog}
 
-hive_lib=`find -L "$(dirname $hive_exec_path)" -name '*.jar' ! -name '*calcite*' -printf '%p:' | sed 's/:$//'`
 hive_dependency=${hive_conf_path}:${hive_lib}:${hcatalog}
 verbose "hive dependency: $hive_dependency"
 export hive_dependency
+