Home / Class/ AbstractEpollServerChannel Class — netty Architecture

AbstractEpollServerChannel Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  1e17774d_85e5_c37d_827e_0e1debcbb478["AbstractEpollServerChannel"]
  7b3f3725_abfa_064b_80f8_409f318cca4c["AbstractEpollServerChannel.java"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|defined in| 7b3f3725_abfa_064b_80f8_409f318cca4c
  b396962c_b7a6_4f4d_13f6_00df1ca8a962["AbstractEpollServerChannel()"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|method| b396962c_b7a6_4f4d_13f6_00df1ca8a962
  12782ca4_d4d6_3130_39f0_93c831646803["ChannelMetadata()"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|method| 12782ca4_d4d6_3130_39f0_93c831646803
  b9c75bdd_cdec_a414_984d_1e9c378647f3["InetSocketAddress()"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|method| b9c75bdd_cdec_a414_984d_1e9c378647f3
  999b6278_02f9_e9e7_c357_769247ac757a["AbstractEpollUnsafe()"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|method| 999b6278_02f9_e9e7_c357_769247ac757a
  36fcbc2c_8169_f436_c32d_a8c624df6ab8["doWrite()"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|method| 36fcbc2c_8169_f436_c32d_a8c624df6ab8
  624882f8_ced4_110f_b642_e25c94bfd82a["Object()"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|method| 624882f8_ced4_110f_b642_e25c94bfd82a
  2a1d11e7_8d7c_e30a_e0bc_375ec4229a73["Channel()"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|method| 2a1d11e7_8d7c_e30a_e0bc_375ec4229a73
  baf0dc8f_ed9d_82a7_f584_f15874971c2d["doConnect()"]
  1e17774d_85e5_c37d_827e_0e1debcbb478 -->|method| baf0dc8f_ed9d_82a7_f584_f15874971c2d

Relationship Graph

Source Code

transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollServerChannel.java lines 29–134

public abstract class AbstractEpollServerChannel extends AbstractEpollChannel implements ServerChannel {
    private static final ChannelMetadata METADATA = new ChannelMetadata(false, 16);

    protected AbstractEpollServerChannel(int fd) {
        this(new LinuxSocket(fd), false);
    }

    protected AbstractEpollServerChannel(LinuxSocket fd) {
        this(fd, isSoErrorZero(fd));
    }

    protected AbstractEpollServerChannel(LinuxSocket fd, boolean active) {
        super(null, fd, active, EpollIoOps.valueOf(0));
    }

    @Override
    public ChannelMetadata metadata() {
        return METADATA;
    }

    @Override
    protected InetSocketAddress remoteAddress0() {
        return null;
    }

    @Override
    protected AbstractEpollUnsafe newUnsafe() {
        return new EpollServerSocketUnsafe();
    }

    @Override
    protected void doWrite(ChannelOutboundBuffer in) throws Exception {
        throw new UnsupportedOperationException();
    }

    @Override
    protected Object filterOutboundMessage(Object msg) throws Exception {
        throw new UnsupportedOperationException();
    }

    protected abstract Channel newChildChannel(int fd, byte[] remote, int offset, int len) throws Exception;

    final class EpollServerSocketUnsafe extends AbstractEpollUnsafe {
        // Will hold the remote address after accept(...) was successful.
        // We need 24 bytes for the address as maximum + 1 byte for storing the length.
        private final byte[] acceptedAddress = new byte[25];

        @Override
        public void connect(SocketAddress socketAddress, SocketAddress socketAddress2, ChannelPromise channelPromise) {
            // Connect not supported by ServerChannel implementations
            channelPromise.setFailure(new UnsupportedOperationException());
        }

        @Override
        void epollInReady() {
            assert eventLoop().inEventLoop();
            final ChannelConfig config = config();
            if (shouldBreakEpollInReady(config)) {
                clearEpollIn0();
                return;
            }
            final EpollRecvByteAllocatorHandle allocHandle = recvBufAllocHandle();
            final ChannelPipeline pipeline = pipeline();
            allocHandle.reset(config);
            allocHandle.attemptedBytesRead(1);

            Throwable exception = null;
            try {
                try {
                    do {
                        // lastBytesRead represents the fd. We use lastBytesRead because it must be set so that the
                        // EpollRecvByteAllocatorHandle knows if it should try to read again or not when autoRead is
                        // enabled.
                        allocHandle.lastBytesRead(socket.accept(acceptedAddress));
                        if (allocHandle.lastBytesRead() == -1) {
                            // this means everything was handled for now
                            break;
                        }
                        allocHandle.incMessagesRead(1);

                        readPending = false;

Frequently Asked Questions

What is the AbstractEpollServerChannel class?
AbstractEpollServerChannel is a class in the netty codebase, defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollServerChannel.java.
Where is AbstractEpollServerChannel defined?
AbstractEpollServerChannel is defined in transport-classes-epoll/src/main/java/io/netty/channel/epoll/AbstractEpollServerChannel.java at line 29.

Analyze Your Own Codebase

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

Try Supermodel Free