PHOENIX-2303 Fix for performance.py not using JAVA_HOME (bpanneton)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/0b7a3c46 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/0b7a3c46 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/0b7a3c46 Branch: refs/heads/calcite Commit: 0b7a3c460e1171b5e67934684bf8ee71f07927cb Parents: 15432d1 Author: Mujtaba <mujt...@apache.org> Authored: Mon Oct 5 10:57:35 2015 -0700 Committer: Nick Dimiduk <ndimi...@apache.org> Committed: Tue Jan 19 20:49:52 2016 -0800 ---------------------------------------------------------------------- bin/performance.py | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/0b7a3c46/bin/performance.py ---------------------------------------------------------------------- diff --git a/bin/performance.py b/bin/performance.py index 2f7fad1..fe39ddf 100755 --- a/bin/performance.py +++ b/bin/performance.py @@ -66,10 +66,40 @@ phoenix_utils.setPath() # HBase/Phoenix client side property override hbase_config_path = os.getenv('HBASE_CONF_DIR', phoenix_utils.current_dir) -execute = ('java -cp "%s%s%s" -Dlog4j.configuration=file:' + +java_home = os.getenv('JAVA_HOME') + +# load hbase-env.??? to extract JAVA_HOME, HBASE_PID_DIR, HBASE_LOG_DIR +hbase_env_path = None +hbase_env_cmd = None +if os.name == 'posix': + hbase_env_path = os.path.join(hbase_config_path, 'hbase-env.sh') + hbase_env_cmd = ['bash', '-c', 'source %s && env' % hbase_env_path] +elif os.name == 'nt': + hbase_env_path = os.path.join(hbase_config_path, 'hbase-env.cmd') + hbase_env_cmd = ['cmd.exe', '/c', 'call %s & set' % hbase_env_path] +if not hbase_env_path or not hbase_env_cmd: + print >> sys.stderr, "hbase-env file unknown on platform %s" % os.name + sys.exit(-1) + +hbase_env = {} +if os.path.isfile(hbase_env_path): + p = subprocess.Popen(hbase_env_cmd, stdout = subprocess.PIPE) + for x in p.stdout: + (k, _, v) = x.partition('=') + hbase_env[k.strip()] = v.strip() + +if hbase_env.has_key('JAVA_HOME'): + java_home = hbase_env['JAVA_HOME'] + +if java_home: + java_cmd = os.path.join(java_home, 'bin', 'java') +else: + java_cmd = 'java' + +execute = ('%s -cp "%s%s%s" -Dlog4j.configuration=file:' + os.path.join(phoenix_utils.current_dir, "log4j.properties") + ' org.apache.phoenix.util.PhoenixRuntime -t %s %s ') % \ - (hbase_config_path, os.pathsep, phoenix_utils.phoenix_client_jar, table, zookeeper) + (java_cmd, hbase_config_path, os.pathsep, phoenix_utils.phoenix_client_jar, table, zookeeper) # Create Table DDL createtable = "CREATE TABLE IF NOT EXISTS %s (HOST CHAR(2) NOT NULL,\ @@ -98,7 +128,7 @@ queryex("4 - Truncate + Group By", "SELECT TRUNC(DATE,'DAY') DAY FROM %s GROUP B queryex("5 - Filter + Count", "SELECT COUNT(1) FROM %s WHERE CORE<10;" % (table)) print "\nGenerating and upserting data..." -exitcode = subprocess.call('java -jar %s %s %s' % (phoenix_utils.testjar, data, rowcount), +exitcode = subprocess.call('%s -jar %s %s %s' % (java_cmd, phoenix_utils.testjar, data, rowcount), shell=True) if exitcode != 0: sys.exit(exitcode)