EpollTest Class — netty Architecture
Architecture documentation for the EpollTest class in EpollTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d19acad4_cac4_5960_b5c8_a3e77d808f28["EpollTest"] 932e4eb6_bae6_024b_67bb_c7b9f0c4ec08["EpollTest.java"] d19acad4_cac4_5960_b5c8_a3e77d808f28 -->|defined in| 932e4eb6_bae6_024b_67bb_c7b9f0c4ec08 7da23658_7765_7320_3574_c41f053e4bb2["testIsAvailable()"] d19acad4_cac4_5960_b5c8_a3e77d808f28 -->|method| 7da23658_7765_7320_3574_c41f053e4bb2 0115e6dc_73c5_5904_5844_498b25ab8495["testEpollWaitTimeoutAccuracy()"] d19acad4_cac4_5960_b5c8_a3e77d808f28 -->|method| 0115e6dc_73c5_5904_5844_498b25ab8495 2ba665b3_bded_4ce6_3891_186c95e006e8["testEpollWaitWithTimeOutMinusOne()"] d19acad4_cac4_5960_b5c8_a3e77d808f28 -->|method| 2ba665b3_bded_4ce6_3891_186c95e006e8
Relationship Graph
Source Code
transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollTest.java lines 30–99
public class EpollTest {
@Test
public void testIsAvailable() {
assertTrue(Epoll.isAvailable());
}
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEpollWaitTimeoutAccuracy() throws Exception {
final int timeoutMs = 200;
final FileDescriptor epoll = Native.newEpollCreate();
final EpollEventArray eventArray = new EpollEventArray(8);
try {
long startNs = System.nanoTime();
// No fds registered, so this will just wait for the timeout.
int ready = Native.epollWait(epoll, eventArray, timeoutMs);
long elapsedMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);
assertEquals(0, ready);
// Should have waited at least close to the timeout
assertThat(elapsedMs).isGreaterThanOrEqualTo(timeoutMs - 20);
// Should not have waited vastly longer than the timeout
assertThat(elapsedMs).isLessThan(timeoutMs + 200);
} finally {
eventArray.free();
epoll.close();
}
}
// Testcase for https://github.com/netty/netty/issues/8444
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testEpollWaitWithTimeOutMinusOne() throws Exception {
final EpollEventArray eventArray = new EpollEventArray(8);
try {
final FileDescriptor epoll = Native.newEpollCreate();
final FileDescriptor timerFd = Native.newTimerFd();
final FileDescriptor eventfd = Native.newEventFd();
Native.epollCtlAdd(epoll.intValue(), timerFd.intValue(), Native.EPOLLIN);
Native.epollCtlAdd(epoll.intValue(), eventfd.intValue(), Native.EPOLLIN);
final AtomicReference<Throwable> ref = new AtomicReference<Throwable>();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
assertEquals(1, Native.epollWait(epoll, eventArray, false));
// This should have been woken up because of eventfd_write.
assertEquals(eventfd.intValue(), eventArray.fd(0));
} catch (Throwable cause) {
ref.set(cause);
}
}
});
t.start();
t.join(1000);
assertTrue(t.isAlive());
Native.eventFdWrite(eventfd.intValue(), 1);
t.join();
assertNull(ref.get());
epoll.close();
timerFd.close();
eventfd.close();
} finally {
eventArray.free();
}
}
}
Source
Frequently Asked Questions
What is the EpollTest class?
EpollTest is a class in the netty codebase, defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollTest.java.
Where is EpollTest defined?
EpollTest is defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollTest.java at line 30.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free