incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [3/3] git commit: Fix for the minicluster unit test.
Date Wed, 27 Feb 2013 13:49:57 GMT
Updated Branches:
  refs/heads/0.2-dev c81e606e6 -> 3bec1f2f8


Fix for the minicluster unit test.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/3bec1f2f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/3bec1f2f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/3bec1f2f

Branch: refs/heads/0.2-dev
Commit: 3bec1f2f8c0be562f0b4f2bf7db73b3fc9c0a05c
Parents: 36bf75b
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Wed Feb 27 08:49:06 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Wed Feb 27 08:49:06 2013 -0500

----------------------------------------------------------------------
 .../java/org/apache/blur/server/BlurServer.java    |    5 ++-
 .../apache/blur/server/QueryStatusContainer.java   |    8 +++-
 .../org/apache/blur/thrift/ITBlurClusterTest.java  |   31 +++++++++++++-
 3 files changed, 38 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3bec1f2f/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java b/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java
index d14e25f..8697ae3 100644
--- a/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java
+++ b/src/blur-core/src/main/java/org/apache/blur/server/BlurServer.java
@@ -553,7 +553,10 @@ public class BlurServer extends TableAdmin implements Iface {
       try {
         Map<String, QueryStatus> result = new HashMap<String, QueryStatus>();
         QueryStatusContainer queryStatusContainer = sessionInfo.getQueryStatusContainer();
-        result.put(server, queryStatusContainer.getQueryStatus(id));
+        QueryStatus queryStatus = queryStatusContainer.getQueryStatus(id);
+        if (queryStatus != null) {
+          result.put(server, queryStatus);  
+        }
         return result;
       } catch (Exception e) {
         LOG.error("Unknown error while trying to get query status with id [{0}] for session
[{1}].", e, id, sessionInfo);

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3bec1f2f/src/blur-core/src/main/java/org/apache/blur/server/QueryStatusContainer.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/main/java/org/apache/blur/server/QueryStatusContainer.java
b/src/blur-core/src/main/java/org/apache/blur/server/QueryStatusContainer.java
index 7be9001..858d707 100644
--- a/src/blur-core/src/main/java/org/apache/blur/server/QueryStatusContainer.java
+++ b/src/blur-core/src/main/java/org/apache/blur/server/QueryStatusContainer.java
@@ -23,6 +23,8 @@ import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.Future;
 
+import org.apache.blur.log.Log;
+import org.apache.blur.log.LogFactory;
 import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.QueryArgs;
 import org.apache.blur.thrift.generated.QueryState;
@@ -30,6 +32,8 @@ import org.apache.blur.thrift.generated.QueryStatus;
 import org.apache.blur.thrift.generated.TopFieldDocs;
 
 public class QueryStatusContainer {
+  
+  private static final Log LOG = LogFactory.getLog(QueryStatusContainer.class);
 
   static class QueryStatusInternal {
     final QueryStatus queryStatus = new QueryStatus();
@@ -46,7 +50,7 @@ public class QueryStatusContainer {
   public QueryStatus getQueryStatus(String id) throws BlurException {
     QueryStatusInternal queryStatusInternal = idLookup.get(id);
     if (queryStatusInternal == null) {
-      throw new BlurException("Query id [" + id + "] not found in the current session.",
null);
+      return null;
     }
     return queryStatusInternal.queryStatus;
   }
@@ -66,7 +70,7 @@ public class QueryStatusContainer {
     }
     QueryStatusInternal queryStatusInternal = idLookup.get(id);
     if (queryStatusInternal != null) {
-      throw new BlurException("Query id [" + id + "] already registered for the current session.",
null);
+      LOG.info("Query id [{0}] already registered for the current session.",id);
     }
     queryStatusInternal = new QueryStatusInternal();
     queryStatusInternal.queryArgs = queryArgs;

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/3bec1f2f/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java
----------------------------------------------------------------------
diff --git a/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java b/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java
index 88a7f5c..24174e3 100644
--- a/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java
+++ b/src/blur-core/src/test/java/org/apache/blur/thrift/ITBlurClusterTest.java
@@ -21,6 +21,9 @@ import static org.junit.Assert.assertEquals;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -107,11 +110,13 @@ public class ITBlurClusterTest {
 
   @Test
   public void testAddDocuments() throws BlurException, TException, InterruptedException,
IOException {
-    Iface client = getClient();
+    Iface client = callTimer(getClient());
     TableDescriptor tableDescriptor = new TableDescriptor();
     tableDescriptor.setName("test-add-table");
     tableDescriptor.setShardCount(SHARD_COUNT);
     tableDescriptor.setStoragePath(MiniCluster.getFileSystemUri().toString() + "/blur/test-add-table");
+    tableDescriptor.putToProperties("blur.shard.time.between.refreshs", "100");
+
     client.createTable(tableDescriptor);
 
     List<Generation> generations = new ArrayList<Generation>();
@@ -152,13 +157,31 @@ public class ITBlurClusterTest {
     assertEquals(SHARD_COUNT * 100, totalHits);
   }
 
+  private Iface callTimer(final Iface client) {
+    return (Iface) Proxy.newProxyInstance(Iface.class.getClassLoader(), new Class[] { Iface.class
}, new InvocationHandler() {
+
+      @Override
+      public Object invoke(Object o, Method method, Object[] args) throws Throwable {
+        long start = System.nanoTime();
+        try {
+          return method.invoke(client, args);
+        } finally {
+          long end = System.nanoTime();
+          System.err.println("Method call [" + method.getName() + "] took [" + (end - start)
/ 1000000.0 + "] ms to complete.");
+        }
+      }
+    });
+  }
+
   @Test
   public void testUpdateDocuments() throws BlurException, TException, InterruptedException,
IOException {
-    Iface client = getClient();
+    Iface client = callTimer(getClient());
     TableDescriptor tableDescriptor = new TableDescriptor();
     tableDescriptor.setName("test-update-table");
     tableDescriptor.setShardCount(SHARD_COUNT);
     tableDescriptor.setStoragePath(MiniCluster.getFileSystemUri().toString() + "/blur/test-update-table");
+    tableDescriptor.putToProperties("blur.shard.time.between.refreshs", "100");
+
     client.createTable(tableDescriptor);
     List<Generation> generations = new ArrayList<Generation>();
     for (int s = 0; s < SHARD_COUNT; s++) {
@@ -199,11 +222,13 @@ public class ITBlurClusterTest {
 
   @Test
   public void testAddDocumentsPerformance() throws BlurException, TException, InterruptedException,
IOException {
-    Iface client = getClient();
+    Iface client = callTimer(getClient());
     TableDescriptor tableDescriptor = new TableDescriptor();
     tableDescriptor.setName("test-add-table-perf");
     tableDescriptor.setShardCount(SHARD_COUNT);
     tableDescriptor.setStoragePath(MiniCluster.getFileSystemUri().toString() + "/blur/test-add-table-perf");
+    tableDescriptor.putToProperties("blur.shard.time.between.refreshs", "10000");
+
     client.createTable(tableDescriptor);
 
     List<Generation> generations = new ArrayList<Generation>();


Mime
View raw message