HBASE-9564 Intermittent TestSimpleRpcScheduler#testHandlerIsolation failure
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1524415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
886a96aed8
commit
db0a4b2d07
|
@ -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 {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue