Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 789c96c46 -> 606983425


PHOENIX-2345 - Pherf - ResultManager does not flush


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

Branch: refs/heads/4.x-HBase-1.0
Commit: 6069834254d6ba4c88a2e1786ae9ed9c22a5397f
Parents: 789c96c
Author: cmarcel <cody.mar...@gmail.com>
Authored: Thu Oct 22 12:46:31 2015 -0700
Committer: cmarcel <cmar...@salesforce.com>
Committed: Thu Oct 22 15:28:54 2015 -0700

----------------------------------------------------------------------
 .../phoenix/pherf/result/ResultManager.java     | 20 ++++++++++++++++++++
 .../pherf/workload/MultiThreadedRunner.java     |  4 ++++
 .../phoenix/pherf/workload/QueryExecutor.java   |  1 +
 .../org/apache/phoenix/pherf/ResultTest.java    |  1 +
 4 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/60698342/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultManager.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultManager.java
 
b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultManager.java
index f994621..4d4ca4a 100644
--- 
a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultManager.java
+++ 
b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/ResultManager.java
@@ -24,11 +24,15 @@ import 
org.apache.phoenix.pherf.result.impl.CSVFileResultHandler;
 import org.apache.phoenix.pherf.result.impl.ImageResultHandler;
 import org.apache.phoenix.pherf.result.impl.XMLResultHandler;
 import org.apache.phoenix.util.InstanceResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.ArrayList;
 import java.util.List;
 
 public class ResultManager {
+    private static final Logger logger = 
LoggerFactory.getLogger(ResultManager.class);
+
     private final List<ResultHandler> resultHandlers;
     private final ResultUtil util;
     private static final List<ResultHandler> defaultHandlers;
@@ -134,6 +138,22 @@ public class ResultManager {
         }
     }
 
+    /**
+     * Allows for flushing all the {@link 
org.apache.phoenix.pherf.result.ResultHandler}
+     * @throws Exception
+     */
+    public synchronized void flush(){
+        for (ResultHandler handler : resultHandlers) {
+            try {
+                handler.flush();
+            } catch (Exception e) {
+                e.printStackTrace();
+                logger.warn("Could not flush handler: "
+                        + handler.getResultFileName() + " : " + 
e.getMessage());
+            }
+        }
+    }
+
     public List<ResultHandler> getResultHandlers() {
         return resultHandlers;
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/60698342/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/MultiThreadedRunner.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/MultiThreadedRunner.java
 
b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/MultiThreadedRunner.java
index de6cdaf..24c68dc 100644
--- 
a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/MultiThreadedRunner.java
+++ 
b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/MultiThreadedRunner.java
@@ -89,6 +89,10 @@ class MultiThreadedRunner implements Runnable {
                 e.printStackTrace();
             }
         }
+
+        // Make sure all result have been dumped before exiting
+        resultManager.flush();
+
         logger.info("\n\nThread exiting." + threadName + "\n\n");
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/60698342/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/QueryExecutor.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/QueryExecutor.java
 
b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/QueryExecutor.java
index 347e203..7f861f1 100644
--- 
a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/QueryExecutor.java
+++ 
b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/workload/QueryExecutor.java
@@ -169,6 +169,7 @@ public class QueryExecutor implements Workload {
                         resultManager.write(dataModelResult);
                     }
                     resultManager.write(dataModelResults);
+                    resultManager.flush();
                 } catch (Exception e) {
                     logger.warn("", e);
                 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/60698342/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java
----------------------------------------------------------------------
diff --git 
a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java 
b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java
index e543137..2afdd21 100644
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/ResultTest.java
@@ -124,6 +124,7 @@ public class ResultTest extends ResultBaseTest {
         modelResults.add(dataModelResult);
         modelResults.add(dataModelResult);
         resultManager.write(modelResults);
+        resultManager.flush();
 
         // read result from file
         List<Result> resultList = xmlResultHandler.read();

Reply via email to