hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1524415 - /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java
Date Wed, 18 Sep 2013 13:53:50 GMT
Author: tedyu
Date: Wed Sep 18 13:53:50 2013
New Revision: 1524415

URL: http://svn.apache.org/r1524415
Log:
HBASE-9564 Intermittent TestSimpleRpcScheduler#testHandlerIsolation failure


Modified:
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java?rev=1524415&r1=1524414&r2=1524415&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestSimpleRpcScheduler.java
Wed Sep 18 13:53:50 2013
@@ -38,6 +38,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CountDownLatch;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Matchers.anyObject;
@@ -91,12 +92,16 @@ public class TestSimpleRpcScheduler {
         replicationTask, HConstants.REPLICATION_QOS);
     PriorityFunction qosFunction = mock(PriorityFunction.class);
     final Map<CallRunner, Thread> handlerThreads = Maps.newHashMap();
+    final CountDownLatch countDownLatch = new CountDownLatch(tasks.size());
     Answer<Void> answerToRun = new Answer<Void>() {
       @Override
       public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
-        handlerThreads.put(
-            (CallRunner) invocationOnMock.getMock(),
-            Thread.currentThread());
+        synchronized (handlerThreads) {
+          handlerThreads.put(
+              (CallRunner) invocationOnMock.getMock(),
+              Thread.currentThread());
+        }
+        countDownLatch.countDown();
         return null;
       }
     };
@@ -119,6 +124,7 @@ public class TestSimpleRpcScheduler {
     scheduler.stop();
 
     // Tests that these requests are handled by three distinct threads.
+    countDownLatch.await();
     assertEquals(3, ImmutableSet.copyOf(handlerThreads.values()).size());
   }
 



Mime
View raw message