Home / Class/ AbstractKQueueServerChannel Class — netty Architecture

AbstractKQueueServerChannel Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  43bfa25a_f85c_184e_19d7_e229cdfb64d2["AbstractKQueueServerChannel"]
  c902fb76_9525_82ef_9b46_2a484e03cb48["AbstractKQueueServerChannel.java"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|defined in| c902fb76_9525_82ef_9b46_2a484e03cb48
  019c0f56_46e1_e455_487a_ce32f41f5240["AbstractKQueueServerChannel()"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|method| 019c0f56_46e1_e455_487a_ce32f41f5240
  d210312a_2add_e9e5_1906_a59dcb25b0cf["ChannelMetadata()"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|method| d210312a_2add_e9e5_1906_a59dcb25b0cf
  367ee6cd_38d2_d53b_61b7_73121ccee824["InetSocketAddress()"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|method| 367ee6cd_38d2_d53b_61b7_73121ccee824
  bd221837_217c_811d_31e8_068f2d9c9e0c["AbstractKQueueUnsafe()"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|method| bd221837_217c_811d_31e8_068f2d9c9e0c
  d6e8c33f_6803_535d_69e9_55d22697ddc1["doWrite()"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|method| d6e8c33f_6803_535d_69e9_55d22697ddc1
  e9ae6e02_e2e8_1da2_d923_571d3ba75d36["Object()"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|method| e9ae6e02_e2e8_1da2_d923_571d3ba75d36
  bd1acef2_c3c5_a768_0235_2602943e5371["Channel()"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|method| bd1acef2_c3c5_a768_0235_2602943e5371
  fe6f265f_0607_5c6f_5904_93dabc485e1a["doConnect()"]
  43bfa25a_f85c_184e_19d7_e229cdfb64d2 -->|method| fe6f265f_0607_5c6f_5904_93dabc485e1a

Relationship Graph

Source Code

transport-classes-kqueue/src/main/java/io/netty/channel/kqueue/AbstractKQueueServerChannel.java lines 28–121

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

    AbstractKQueueServerChannel(BsdSocket fd) {
        this(fd, isSoErrorZero(fd));
    }

    AbstractKQueueServerChannel(BsdSocket fd, boolean active) {
        super(null, fd, active);
    }

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

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

    @Override
    protected AbstractKQueueUnsafe newUnsafe() {
        return new KQueueServerSocketUnsafe();
    }

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

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

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

    @Override
    protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception {
        throw new UnsupportedOperationException();
    }

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

        @Override
        void readReady(KQueueRecvByteAllocatorHandle allocHandle) {
            assert eventLoop().inEventLoop();
            final ChannelConfig config = config();
            if (shouldBreakReadReady(config)) {
                clearReadFilter0();
                return;
            }
            final ChannelPipeline pipeline = pipeline();
            allocHandle.reset(config);
            allocHandle.attemptedBytesRead(1);

            Throwable exception = null;
            try {
                try {
                    do {
                        int acceptFd = socket.accept(acceptedAddress);
                        if (acceptFd == -1) {
                            // this means everything was handled for now
                            allocHandle.lastBytesRead(-1);
                            break;
                        }
                        allocHandle.lastBytesRead(1);
                        allocHandle.incMessagesRead(1);

                        readPending = false;
                        pipeline.fireChannelRead(newChildChannel(acceptFd, acceptedAddress, 1,
                                                                 acceptedAddress[0]));
                    } while (allocHandle.continueReading());
                } catch (Throwable t) {
                    exception = t;
                }
                allocHandle.readComplete();

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free