Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 d9d8c08fc -> 7e87f6255


PHOENIX-2311 Fix performance.py java.io.FileNotFoundException (Gabor Liptak)


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

Branch: refs/heads/4.x-HBase-0.98
Commit: 7e87f6255bb2ffa268afd0024a20ac130f88e10d
Parents: d9d8c08
Author: Mujtaba <mujt...@apache.org>
Authored: Tue Oct 13 10:26:43 2015 -0700
Committer: Mujtaba <mujt...@apache.org>
Committed: Tue Oct 13 10:26:43 2015 -0700

----------------------------------------------------------------------
 bin/performance.py                              | 10 ++++++----
 .../phoenix/util/GeneratePerformanceData.java   | 21 ++++++++++----------
 2 files changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7e87f625/bin/performance.py
----------------------------------------------------------------------
diff --git a/bin/performance.py b/bin/performance.py
index c3705f0..f28cd7e 100755
--- a/bin/performance.py
+++ b/bin/performance.py
@@ -22,6 +22,7 @@
 import os
 import subprocess
 import sys
+import tempfile
 import phoenix_utils
 
 def queryex(description, statement):
@@ -54,9 +55,9 @@ rowcount = sys.argv[2]
 table = "PERFORMANCE_" + sys.argv[2]
 
 # helper variable and functions
-ddl = "ddl.sql"
-data = "data.csv"
-qry = "query.sql"
+ddl = tempfile.mkstemp(prefix='ddl_', suffix='.sql')[1]
+data = tempfile.mkstemp(prefix='data_', suffix='.csv')[1]
+qry = tempfile.mkstemp(prefix='query_', suffix='.sql')[1]
 statements = ""
 
 phoenix_utils.setPath()
@@ -127,7 +128,8 @@ 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('%s -jar %s %s' % (java_cmd, phoenix_utils.testjar, 
rowcount), shell=True)
+exitcode = subprocess.call('java -jar %s %s %s' % (phoenix_utils.testjar, 
data, rowcount),
+                           shell=True)
 if exitcode != 0:
     sys.exit(exitcode)
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7e87f625/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java
index 7ef7887..c8a9f6e 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/util/GeneratePerformanceData.java
@@ -27,23 +27,22 @@ import java.util.Random;
 import java.util.TimeZone;
 
 public class GeneratePerformanceData {
-    private static final String FILENAME = "data.csv";
-
     public static void main(String[] args) throws FileNotFoundException, 
IOException {
         String[] host = {"NA","CS","EU"};
         String[] domain = {"Salesforce.com","Apple.com","Google.com"};
         String[] feature = {"Login","Report","Dashboard"};
         Calendar now = GregorianCalendar.getInstance();
-        FileOutputStream fostream = new FileOutputStream(FILENAME);
+        Random random = new Random();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        if (args.length != 2) {
+            System.out.println("Data file name and row count must be specified 
as arguments");
+            return;
+        }
+        String dataFile = args[0];
+        int rowCount = Integer.parseInt(args[1]);
+        FileOutputStream fostream = null;
         try {
-            Random random = new Random();
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
-            if (args.length < 1) {
-                System.out.println("Row count must be specified as argument");
-                return;
-            }
-            int rowCount = Integer.parseInt(args[0]);
+            fostream = new FileOutputStream(dataFile);
             for (int i=0; i<rowCount; i++) {
                 now.add(Calendar.SECOND, 1);
                 fostream.write((host[random.nextInt(host.length)] + "," + 

Reply via email to