Home / Class/ AbstractNioChannel Class — netty Architecture

AbstractNioChannel Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721["AbstractNioChannel"]
  9ebed286_fd2b_0f44_ed7f_f94498c8773b["AbstractNioChannel.java"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|defined in| 9ebed286_fd2b_0f44_ed7f_f94498c8773b
  57707215_c50c_85c0_551b_f8c8f6388770["AbstractNioChannel()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 57707215_c50c_85c0_551b_f8c8f6388770
  ba123f72_ce38_82b2_4c0e_e8db9c3db02a["addAndSubmit()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| ba123f72_ce38_82b2_4c0e_e8db9c3db02a
  31c32611_5d7e_c587_8628_79f1c8ac0508["removeAndSubmit()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 31c32611_5d7e_c587_8628_79f1c8ac0508
  a85a5240_55bd_f0e8_3a73_aff79c985009["isOpen()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| a85a5240_55bd_f0e8_3a73_aff79c985009
  5c5ede6a_94d2_10f8_cba3_c38d91428a80["NioUnsafe()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 5c5ede6a_94d2_10f8_cba3_c38d91428a80
  52638f57_6035_b240_5af7_943dfa350a96["SelectableChannel()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 52638f57_6035_b240_5af7_943dfa350a96
  626fd659_8cc7_1180_23cc_17f6481bf087["SelectionKey()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 626fd659_8cc7_1180_23cc_17f6481bf087
  b8d5ce3a_fab0_ecb6_5620_00310e1092b6["IoRegistration()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| b8d5ce3a_fab0_ecb6_5620_00310e1092b6
  85c018fa_7837_337c_d047_67e0edc0ac5b["isReadPending()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 85c018fa_7837_337c_d047_67e0edc0ac5b
  8248a3f9_fb9b_eaf1_dd1f_981e4f2f5830["setReadPending()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 8248a3f9_fb9b_eaf1_dd1f_981e4f2f5830
  3b046972_48de_5343_2f1a_a98db9545619["clearReadPending()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 3b046972_48de_5343_2f1a_a98db9545619
  1fc16029_be4f_b1f4_db0e_e80de9cde9b9["setReadPending0()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 1fc16029_be4f_b1f4_db0e_e80de9cde9b9
  58010162_b32e_8dc9_9f6b_35b7135a804b["clearReadPending0()"]
  ee3727e1_0d64_fa3f_39b7_5b5d3cee6721 -->|method| 58010162_b32e_8dc9_9f6b_35b7135a804b

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java lines 53–588

public abstract class AbstractNioChannel extends AbstractChannel {

    private static final InternalLogger logger =
            InternalLoggerFactory.getInstance(AbstractNioChannel.class);

    private final SelectableChannel ch;
    protected final int readInterestOp;
    protected final NioIoOps readOps;
    volatile IoRegistration registration;
    boolean readPending;
    private final Runnable clearReadPendingRunnable = new Runnable() {
        @Override
        public void run() {
            clearReadPending0();
        }
    };

    /**
     * The future of the current connection attempt.  If not null, subsequent
     * connection attempts will fail.
     */
    private ChannelPromise connectPromise;
    private Future<?> connectTimeoutFuture;
    private SocketAddress requestedRemoteAddress;

    /**
     * Create a new instance
     *
     * @param parent            the parent {@link Channel} by which this instance was created. May be {@code null}
     * @param ch                the underlying {@link SelectableChannel} on which it operates
     * @param readOps           the ops to set to receive data from the {@link SelectableChannel}
     */
    protected AbstractNioChannel(Channel parent, SelectableChannel ch, int readOps) {
        this(parent, ch, NioIoOps.valueOf(readOps));
    }

    protected AbstractNioChannel(Channel parent, SelectableChannel ch, NioIoOps readOps) {
        super(parent);
        this.ch = ch;
        this.readInterestOp = ObjectUtil.checkNotNull(readOps, "readOps").value;
        this.readOps = readOps;
        try {
            ch.configureBlocking(false);
        } catch (IOException e) {
            try {
                ch.close();
            } catch (IOException e2) {
                logger.warn(
                            "Failed to close a partially initialized socket.", e2);
            }

            throw new ChannelException("Failed to enter non-blocking mode.", e);
        }
    }

    protected void addAndSubmit(NioIoOps addOps) {
        int interestOps = selectionKey().interestOps();
        if (!addOps.isIncludedIn(interestOps)) {
            try {
                registration().submit(NioIoOps.valueOf(interestOps).with(addOps));
            } catch (Exception e) {
                throw new ChannelException(e);
            }
        }
    }

    protected void removeAndSubmit(NioIoOps removeOps) {
        int interestOps = selectionKey().interestOps();
        if (removeOps.isIncludedIn(interestOps)) {
            try {
                registration().submit(NioIoOps.valueOf(interestOps).without(removeOps));
            } catch (Exception e) {
                throw new ChannelException(e);
            }
        }
    }

    @Override
    public boolean isOpen() {
        return ch.isOpen();
    }

Frequently Asked Questions

What is the AbstractNioChannel class?
AbstractNioChannel is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java.
Where is AbstractNioChannel defined?
AbstractNioChannel is defined in transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java at line 53.

Analyze Your Own Codebase

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

Try Supermodel Free