Home / Class/ EpollEventLoopTest Class — netty Architecture

EpollEventLoopTest Class — netty Architecture

Architecture documentation for the EpollEventLoopTest class in EpollEventLoopTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  bfe6ddcc_7826_010d_3f8f_df4f5668832e["EpollEventLoopTest"]
  3cf3642d_8edb_c551_48ee_349f4490deb8["EpollEventLoopTest.java"]
  bfe6ddcc_7826_010d_3f8f_df4f5668832e -->|defined in| 3cf3642d_8edb_c551_48ee_349f4490deb8
  f894bd9a_6019_6f4b_da38_36cab265775b["supportsChannelIteration()"]
  bfe6ddcc_7826_010d_3f8f_df4f5668832e -->|method| f894bd9a_6019_6f4b_da38_36cab265775b
  e43713be_8510_948c_5b3d_0d673611341d["EventLoopGroup()"]
  bfe6ddcc_7826_010d_3f8f_df4f5668832e -->|method| e43713be_8510_948c_5b3d_0d673611341d
  7ff6e86d_7505_eaa4_d705_04359fea7f2c["ServerSocketChannel()"]
  bfe6ddcc_7826_010d_3f8f_df4f5668832e -->|method| 7ff6e86d_7505_eaa4_d705_04359fea7f2c
  11ca5918_87f1_4297_c2a1_f7815c66d395["serverChannelClass()"]
  bfe6ddcc_7826_010d_3f8f_df4f5668832e -->|method| 11ca5918_87f1_4297_c2a1_f7815c66d395
  870f693e_1e15_5fe3_b88d_ed928d403782["testScheduleBigDelayNotOverflow()"]
  bfe6ddcc_7826_010d_3f8f_df4f5668832e -->|method| 870f693e_1e15_5fe3_b88d_ed928d403782
  bf0952e3_87ed_60f2_96b4_800662896698["testEventFDETSemantics()"]
  bfe6ddcc_7826_010d_3f8f_df4f5668832e -->|method| bf0952e3_87ed_60f2_96b4_800662896698
  f16230fe_0636_eb5d_927c_baa1dea3fec4["testResultNoTimeoutCorrectlyEncoded()"]
  bfe6ddcc_7826_010d_3f8f_df4f5668832e -->|method| f16230fe_0636_eb5d_927c_baa1dea3fec4

Relationship Graph

Source Code

transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollEventLoopTest.java lines 41–194

public class EpollEventLoopTest extends AbstractSingleThreadEventLoopTest {

    @Override
    protected boolean supportsChannelIteration() {
        return true;
    }

    @Override
    protected EventLoopGroup newEventLoopGroup() {
        return new EpollEventLoopGroup();
    }

    @Override
    protected EventLoopGroup newAutoScalingEventLoopGroup() {
        return new EpollEventLoopGroup(SCALING_MAX_THREADS, (Executor) null, AUTO_SCALING_CHOOSER_FACTORY,
                                       DefaultSelectStrategyFactory.INSTANCE);
    }

    @Override
    protected ServerSocketChannel newChannel() {
        return new EpollServerSocketChannel();
    }

    @Override
    protected Class<? extends ServerChannel> serverChannelClass() {
        return EpollServerSocketChannel.class;
    }

    @Test
    public void testScheduleBigDelayNotOverflow() {
        final AtomicReference<Throwable> capture = new AtomicReference<Throwable>();

        final EventLoopGroup group = new EpollEventLoop(null,
                new ThreadPerTaskExecutor(new DefaultThreadFactory(getClass())), eventLoop -> new EpollIoHandler(
                        eventLoop, 0, DefaultSelectStrategyFactory.INSTANCE.newSelectStrategy()) {
            @Override
            void handleLoopException(Throwable t) {
                capture.set(t);
                super.handleLoopException(t);
            }
        });

        try {
            final EventLoop eventLoop = group.next();
            Future<?> future = eventLoop.schedule(new Runnable() {
                @Override
                public void run() {
                    // NOOP
                }
            }, Long.MAX_VALUE, TimeUnit.MILLISECONDS);

            assertFalse(future.awaitUninterruptibly(1000));
            assertTrue(future.cancel(true));
            assertNull(capture.get());
        } finally {
            group.shutdownGracefully();
        }
    }

    @Test
    public void testEventFDETSemantics() throws Throwable {
        final FileDescriptor epoll = Native.newEpollCreate();
        final FileDescriptor eventFd = Native.newEventFd();
        final FileDescriptor timerFd = Native.newTimerFd();
        final EpollEventArray array = new EpollEventArray(1024);
        try {
            Native.epollCtlAdd(epoll.intValue(), eventFd.intValue(), Native.EPOLLIN | Native.EPOLLET);
            final AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
            final AtomicInteger integer = new AtomicInteger();
            final Thread t = new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        for (int i = 0; i < 2; i++) {
                            int ready = Native.epollWait(epoll, array, timerFd, -1, -1);
                            assertEquals(1, ready);
                            assertEquals(eventFd.intValue(), array.fd(0));
                            integer.incrementAndGet();
                        }
                    } catch (IOException e) {
                        causeRef.set(e);

Frequently Asked Questions

What is the EpollEventLoopTest class?
EpollEventLoopTest is a class in the netty codebase, defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollEventLoopTest.java.
Where is EpollEventLoopTest defined?
EpollEventLoopTest is defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollEventLoopTest.java at line 41.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free