PHOENIX-2369 Some UDF tests failed due to not finding Hadoop classpath (aliciashu)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/cfde793e Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/cfde793e Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/cfde793e Branch: refs/heads/txn Commit: cfde793e2c593fd5d936de54d51dcfdb1098c5b9 Parents: e9d4498 Author: Mujtaba <[email protected]> Authored: Mon Nov 16 10:29:21 2015 -0800 Committer: Mujtaba <[email protected]> Committed: Mon Nov 16 10:29:21 2015 -0800 ---------------------------------------------------------------------- bin/phoenix_utils.py | 22 ++++++++++++++++++++++ bin/psql.py | 2 +- bin/sqlline-thin.py | 2 +- bin/sqlline.py | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/cfde793e/bin/phoenix_utils.py ---------------------------------------------------------------------- diff --git a/bin/phoenix_utils.py b/bin/phoenix_utils.py index 13dd360..cb48194 100755 --- a/bin/phoenix_utils.py +++ b/bin/phoenix_utils.py @@ -21,6 +21,7 @@ import os import fnmatch +import subprocess def find(pattern, classPaths): paths = classPaths.split(os.pathsep) @@ -52,6 +53,17 @@ def findFileInPathWithoutRecursion(pattern, path): return "" +def which(file): + for path in os.environ["PATH"].split(os.pathsep): + if os.path.exists(os.path.join(path, file)): + return os.path.join(path, file) + return None + +def findClasspath(file): + aPath = which(file) + command = "%s%s" %(aPath, ' classpath') + return subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read() + def setPath(): PHOENIX_CLIENT_JAR_PATTERN = "phoenix-*-client.jar" PHOENIX_THIN_CLIENT_JAR_PATTERN = "phoenix-*-thin-client.jar" @@ -94,6 +106,15 @@ def setPath(): global phoenix_test_jar_path phoenix_test_jar_path = os.path.join(current_dir, "..", "phoenix-core", "target","*") + global hadoop_conf + hadoop_conf = os.getenv('HADOOP_CONF_DIR', '') + + global hadoop_classpath + if (os.name != 'nt'): + hadoop_classpath = findClasspath('hadoop') + else: + hadoop_classpath = os.getenv('HADOOP_CLASSPATH', '') + global hadoop_common_jar_path hadoop_common_jar_path = os.path.join(current_dir, "..", "phoenix-assembly", "target","*") @@ -166,3 +187,4 @@ if __name__ == "__main__": print "testjar:", testjar print "phoenix_queryserver_jar:", phoenix_queryserver_jar print "phoenix_thin_client_jar:", phoenix_thin_client_jar + print "hadoop_classpath:", hadoop_classpath http://git-wip-us.apache.org/repos/asf/phoenix/blob/cfde793e/bin/psql.py ---------------------------------------------------------------------- diff --git a/bin/psql.py b/bin/psql.py index 230180d..d4269d1 100755 --- a/bin/psql.py +++ b/bin/psql.py @@ -63,7 +63,7 @@ else: java = 'java' java_cmd = java +' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + phoenix_utils.phoenix_client_jar + \ - '" -Dlog4j.configuration=file:' + \ + os.pathsep + phoenix_utils.hadoop_conf + os.pathsep + phoenix_utils.hadoop_classpath + '" -Dlog4j.configuration=file:' + \ os.path.join(phoenix_utils.current_dir, "log4j.properties") + \ " org.apache.phoenix.util.PhoenixRuntime " + args http://git-wip-us.apache.org/repos/asf/phoenix/blob/cfde793e/bin/sqlline-thin.py ---------------------------------------------------------------------- diff --git a/bin/sqlline-thin.py b/bin/sqlline-thin.py index a2d313f..9877def 100755 --- a/bin/sqlline-thin.py +++ b/bin/sqlline-thin.py @@ -112,7 +112,7 @@ else: java = 'java' java_cmd = java + ' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + phoenix_utils.phoenix_thin_client_jar + \ - '" -Dlog4j.configuration=file:' + \ + os.pathsep + phoenix_utils.hadoop_conf + os.pathsep + phoenix_utils.hadoop_classpath + '" -Dlog4j.configuration=file:' + \ os.path.join(phoenix_utils.current_dir, "log4j.properties") + \ " sqlline.SqlLine -d org.apache.phoenix.queryserver.client.Driver " + \ " -u jdbc:phoenix:thin:url=" + url + \ http://git-wip-us.apache.org/repos/asf/phoenix/blob/cfde793e/bin/sqlline.py ---------------------------------------------------------------------- diff --git a/bin/sqlline.py b/bin/sqlline.py index bff2e80..d3901ce 100755 --- a/bin/sqlline.py +++ b/bin/sqlline.py @@ -88,7 +88,7 @@ if os.name == 'nt': colorSetting = "false" java_cmd = java + ' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + phoenix_utils.phoenix_client_jar + os.pathsep + phoenix_utils.hadoop_common_jar + os.pathsep + phoenix_utils.hadoop_hdfs_jar + \ - '" -Dlog4j.configuration=file:' + \ + os.pathsep + phoenix_utils.hadoop_conf + os.pathsep + phoenix_utils.hadoop_classpath + '" -Dlog4j.configuration=file:' + \ os.path.join(phoenix_utils.current_dir, "log4j.properties") + \ " sqlline.SqlLine -d org.apache.phoenix.jdbc.PhoenixDriver \ -u jdbc:phoenix:" + phoenix_utils.shell_quote([sys.argv[1]]) + \
