Home / Class/ AbstractOioByteChannel Class — netty Architecture

AbstractOioByteChannel Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  df30be00_eee6_bc00_48f3_cbf4f80b9065["AbstractOioByteChannel"]
  42e31513_fc4f_d6df_7b58_05cb4b9aeca0["AbstractOioByteChannel.java"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|defined in| 42e31513_fc4f_d6df_7b58_05cb4b9aeca0
  9ac8e97b_eb4a_e10e_39ec_1b7297a0160d["AbstractOioByteChannel()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 9ac8e97b_eb4a_e10e_39ec_1b7297a0160d
  bf9fbd96_2c54_0291_2e65_55a8057aad86["ChannelMetadata()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| bf9fbd96_2c54_0291_2e65_55a8057aad86
  9f1b0882_de8a_d386_f00a_3c8170b1e5f6["isInputShutdown()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 9f1b0882_de8a_d386_f00a_3c8170b1e5f6
  310f3fab_15a7_0809_fbca_a7f597c47dac["ChannelFuture()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 310f3fab_15a7_0809_fbca_a7f597c47dac
  e2921b96_0d95_d59d_1b95_b8061971e04f["closeOnRead()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| e2921b96_0d95_d59d_1b95_b8061971e04f
  6731b7b6_ba29_84b6_72f2_5246e108dfb1["handleReadException()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 6731b7b6_ba29_84b6_72f2_5246e108dfb1
  24847cd2_e242_82c4_873e_ef44313f60e1["doRead()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 24847cd2_e242_82c4_873e_ef44313f60e1
  59312554_c4bd_9271_bd1e_6ef0f218a046["doWrite()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 59312554_c4bd_9271_bd1e_6ef0f218a046
  2f570c0c_a166_9cb6_bebb_05fdaa95031b["Object()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 2f570c0c_a166_9cb6_bebb_05fdaa95031b
  c4cb8ae3_e77f_078e_ff82_bbcf09e40ae1["available()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| c4cb8ae3_e77f_078e_ff82_bbcf09e40ae1
  3bfe11d6_f89b_cc98_cc9d_828f40a064a5["doReadBytes()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 3bfe11d6_f89b_cc98_cc9d_828f40a064a5
  f9bde2eb_dd38_8728_f7d0_1eef9cc00d41["doWriteBytes()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| f9bde2eb_dd38_8728_f7d0_1eef9cc00d41
  49f14135_8a21_cada_5d5d_39e15785aaf9["doWriteFileRegion()"]
  df30be00_eee6_bc00_48f3_cbf4f80b9065 -->|method| 49f14135_8a21_cada_5d5d_39e15785aaf9

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/oio/AbstractOioByteChannel.java lines 41–274

public abstract class AbstractOioByteChannel extends AbstractOioChannel {

    private static final ChannelMetadata METADATA = new ChannelMetadata(false);
    private static final String EXPECTED_TYPES =
            " (expected: " + StringUtil.simpleClassName(ByteBuf.class) + ", " +
            StringUtil.simpleClassName(FileRegion.class) + ')';

    /**
     * @see AbstractOioByteChannel#AbstractOioByteChannel(Channel)
     */
    protected AbstractOioByteChannel(Channel parent) {
        super(parent);
    }

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

    /**
     * Determine if the input side of this channel is shutdown.
     * @return {@code true} if the input side of this channel is shutdown.
     */
    protected abstract boolean isInputShutdown();

    /**
     * Shutdown the input side of this channel.
     * @return A channel future that will complete when the shutdown is complete.
     */
    protected abstract ChannelFuture shutdownInput();

    private void closeOnRead(ChannelPipeline pipeline) {
        if (isOpen()) {
            if (Boolean.TRUE.equals(config().getOption(ChannelOption.ALLOW_HALF_CLOSURE))) {
                shutdownInput();
                pipeline.fireUserEventTriggered(ChannelInputShutdownEvent.INSTANCE);
            } else {
                unsafe().close(unsafe().voidPromise());
            }
            pipeline.fireUserEventTriggered(ChannelInputShutdownReadComplete.INSTANCE);
        }
    }

    private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close,
            RecvByteBufAllocator.Handle allocHandle) {
        if (byteBuf != null) {
            if (byteBuf.isReadable()) {
                readPending = false;
                pipeline.fireChannelRead(byteBuf);
            } else {
                byteBuf.release();
            }
        }
        allocHandle.readComplete();
        pipeline.fireChannelReadComplete();
        pipeline.fireExceptionCaught(cause);

        // If oom will close the read event, release connection.
        // See https://github.com/netty/netty/issues/10434
        if (close ||
                cause instanceof OutOfMemoryError ||
                cause instanceof LeakPresenceDetector.AllocationProhibitedException ||
                cause instanceof IOException) {
            closeOnRead(pipeline);
        }
    }

    @Override
    protected void doRead() {
        final ChannelConfig config = config();
        if (isInputShutdown() || !readPending) {
            // We have to check readPending here because the Runnable to read could have been scheduled and later
            // during the same read loop readPending was set to false.
            return;
        }
        // In OIO we should set readPending to false even if the read was not successful so we can schedule
        // another read on the event loop if no reads are done.
        readPending = false;

        final ChannelPipeline pipeline = pipeline();
        final ByteBufAllocator allocator = config.getAllocator();

Frequently Asked Questions

What is the AbstractOioByteChannel class?
AbstractOioByteChannel is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/oio/AbstractOioByteChannel.java.
Where is AbstractOioByteChannel defined?
AbstractOioByteChannel is defined in transport/src/main/java/io/netty/channel/oio/AbstractOioByteChannel.java at line 41.

Analyze Your Own Codebase

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

Try Supermodel Free