Repository: phoenix Updated Branches: refs/heads/4.5-HBase-1.0 52e44884d -> 6103269b2
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/6103269b Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6103269b Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6103269b Branch: refs/heads/4.5-HBase-1.0 Commit: 6103269b23c6c7a062745d57cca785185fd113a9 Parents: 52e4488 Author: Mujtaba <mujt...@apache.org> Authored: Mon Oct 5 10:59:04 2015 -0700 Committer: Mujtaba <mujt...@apache.org> Committed: Mon Oct 5 10:59:04 2015 -0700 ---------------------------------------------------------------------- bin/performance.py | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/6103269b/bin/performance.py ---------------------------------------------------------------------- diff --git a/bin/performance.py b/bin/performance.py index b9df433..c3705f0 100755 --- a/bin/performance.py +++ b/bin/performance.py @@ -65,10 +65,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,\ @@ -97,7 +127,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' % (phoenix_utils.testjar, rowcount), shell=True) +exitcode = subprocess.call('%s -jar %s %s' % (java_cmd, phoenix_utils.testjar, rowcount), shell=True) if exitcode != 0: sys.exit(exitcode)