phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mujt...@apache.org
Subject phoenix git commit: PHOENIX-2303 Fix for performance.py not using JAVA_HOME (bpanneton)
Date Mon, 05 Oct 2015 17:59:18 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.5-HBase-1.1 e215eeb5e -> cbe78b5ba


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/cbe78b5b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/cbe78b5b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/cbe78b5b

Branch: refs/heads/4.5-HBase-1.1
Commit: cbe78b5ba51194fbe02cf541bf4f69e35d190ede
Parents: e215eeb
Author: Mujtaba <mujtaba@apache.org>
Authored: Mon Oct 5 10:59:15 2015 -0700
Committer: Mujtaba <mujtaba@apache.org>
Committed: Mon Oct 5 10:59:15 2015 -0700

----------------------------------------------------------------------
 bin/performance.py | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/cbe78b5b/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)
 


Mime
View raw message