use of org.apache.hbase.thirdparty.io.netty.channel.DefaultEventLoop in project hbase by apache.
the class TestIPCUtil method testExecute.
@Test
public void testExecute() throws IOException {
EventLoop eventLoop = new DefaultEventLoop();
MutableInt executed = new MutableInt(0);
MutableInt numStackTraceElements = new MutableInt(0);
CompletableFuture<Void> future = new CompletableFuture<>();
try {
IPCUtil.execute(eventLoop, new Runnable() {
@Override
public void run() {
int numElements = new Exception().getStackTrace().length;
int depth = executed.getAndIncrement();
if (depth <= IPCUtil.MAX_DEPTH) {
if (numElements <= numStackTraceElements.intValue()) {
future.completeExceptionally(new AssertionError("should call run directly but stack trace decreased from " + numStackTraceElements.intValue() + " to " + numElements));
return;
}
numStackTraceElements.setValue(numElements);
IPCUtil.execute(eventLoop, this);
} else {
if (numElements >= numStackTraceElements.intValue()) {
future.completeExceptionally(new AssertionError("should call eventLoop.execute to prevent stack overflow but" + " stack trace increased from " + numStackTraceElements.intValue() + " to " + numElements));
} else {
future.complete(null);
}
}
}
});
FutureUtils.get(future);
} finally {
eventLoop.shutdownGracefully();
}
}
Aggregations