hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [14/23] hbase git commit: HBASE-14758 Add UT case for unchecked error/exception thrown in AsyncProcess#sendMultiAction (Yu Li)
Date Thu, 05 Nov 2015 17:37:07 GMT
HBASE-14758 Add UT case for unchecked error/exception thrown in AsyncProcess#sendMultiAction
(Yu Li)


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

Branch: refs/heads/hbase-12439
Commit: cfc5348b5eb60daad812e362c90c74341f10d3e6
Parents: ceddec9
Author: tedyu <yuzhihong@gmail.com>
Authored: Wed Nov 4 07:20:59 2015 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Wed Nov 4 07:20:59 2015 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/client/TestAsyncProcess.java   | 40 ++++++++++++++++++++
 1 file changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/cfc5348b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncProcess.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncProcess.java
b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncProcess.java
index 28cff10..067f2ad 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncProcess.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestAsyncProcess.java
@@ -29,7 +29,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadFactory;
@@ -1049,4 +1052,41 @@ public class TestAsyncProcess {
 
     return p;
   }
+
+  static class MyThreadPoolExecutor extends ThreadPoolExecutor {
+    public MyThreadPoolExecutor(int coreThreads, int maxThreads, long keepAliveTime,
+        TimeUnit timeunit, BlockingQueue<Runnable> blockingqueue) {
+      super(coreThreads, maxThreads, keepAliveTime, timeunit, blockingqueue);
+    }
+
+    @Override
+    public Future submit(Runnable runnable) {
+      throw new OutOfMemoryError("OutOfMemory error thrown by means");
+    }
+  }
+
+  static class AsyncProcessForThrowableCheck extends AsyncProcess {
+    public AsyncProcessForThrowableCheck(ClusterConnection hc, Configuration conf,
+        ExecutorService pool) {
+      super(hc, conf, pool, new RpcRetryingCallerFactory(conf), false, new RpcControllerFactory(
+          conf));
+    }
+  }
+
+  @Test
+  public void testUncheckedException() throws Exception {
+    // Test the case pool.submit throws unchecked exception
+    ClusterConnection hc = createHConnection();
+    MyThreadPoolExecutor myPool =
+        new MyThreadPoolExecutor(1, 20, 60, TimeUnit.SECONDS,
+            new LinkedBlockingQueue<Runnable>(200));
+    AsyncProcess ap = new AsyncProcessForThrowableCheck(hc, conf, myPool);
+
+    List<Put> puts = new ArrayList<Put>();
+    puts.add(createPut(1, true));
+
+    ap.submit(DUMMY_TABLE, puts, false, null, false);
+    Assert.assertTrue(puts.isEmpty());
+  }
+
 }


Mime
View raw message