Home / Function/ write() — netty Function Reference

write() — netty Function Reference

Architecture documentation for the write() function in DefaultHttp2ConnectionEncoder.java from the netty codebase.

Function java Buffer Allocators calls 3 called by 2

Entity Profile

Dependency Diagram

graph TD
  00bd83d0_dcec_5387_7a17_1c0f317ff485["write()"]
  3f967aaa_cd4e_4486_0912_7a9f57cfa847["FlowControlledData"]
  00bd83d0_dcec_5387_7a17_1c0f317ff485 -->|defined in| 3f967aaa_cd4e_4486_0912_7a9f57cfa847
  d9006e3b_57b1_d5dd_3732_26d895ab9344["write()"]
  d9006e3b_57b1_d5dd_3732_26d895ab9344 -->|calls| 00bd83d0_dcec_5387_7a17_1c0f317ff485
  477efeff_1ae4_5595_d4ec_eae3cb151ba9["error()"]
  477efeff_1ae4_5595_d4ec_eae3cb151ba9 -->|calls| 00bd83d0_dcec_5387_7a17_1c0f317ff485
  d9006e3b_57b1_d5dd_3732_26d895ab9344["write()"]
  00bd83d0_dcec_5387_7a17_1c0f317ff485 -->|calls| d9006e3b_57b1_d5dd_3732_26d895ab9344
  477efeff_1ae4_5595_d4ec_eae3cb151ba9["error()"]
  00bd83d0_dcec_5387_7a17_1c0f317ff485 -->|calls| 477efeff_1ae4_5595_d4ec_eae3cb151ba9
  056b4816_0b1f_9d07_6136_4efe950e0c59["size()"]
  00bd83d0_dcec_5387_7a17_1c0f317ff485 -->|calls| 056b4816_0b1f_9d07_6136_4efe950e0c59
  style 00bd83d0_dcec_5387_7a17_1c0f317ff485 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java lines 468–509

        @Override
        public void write(ChannelHandlerContext ctx, int allowedBytes) {
            int queuedData = queue.readableBytes();
            if (!endOfStream) {
                if (queuedData == 0) {
                    if (queue.isEmpty()) {
                        // When the queue is empty it means we did clear it because of an error(...) call
                        // (as otherwise we will have at least 1 entry in there), which will happen either when called
                        // explicit or when the write itself fails. In this case just set dataSize and padding to 0
                        // which will signal back that the whole frame was consumed.
                        //
                        // See https://github.com/netty/netty/issues/8707.
                        padding = dataSize = 0;
                    } else {
                        // There's no need to write any data frames because there are only empty data frames in the
                        // queue and it is not end of stream yet. Just complete their promises by getting the buffer
                        // corresponding to 0 bytes and writing it to the channel (to preserve notification order).
                        ChannelPromise writePromise = ctx.newPromise().addListener(this);
                        ctx.write(queue.remove(0, writePromise), writePromise);
                    }
                    return;
                }

                if (allowedBytes == 0) {
                    return;
                }
            }

            // Determine how much data to write.
            int writableData = min(queuedData, allowedBytes);
            ChannelPromise writePromise = ctx.newPromise().addListener(this);
            ByteBuf toWrite = queue.remove(writableData, writePromise);
            dataSize = queue.readableBytes();

            // Determine how much padding to write.
            int writablePadding = min(allowedBytes - writableData, padding);
            padding -= writablePadding;

            // Write the frame(s).
            frameWriter().writeData(ctx, stream.id(), toWrite, writablePadding,
                    endOfStream && size() == 0, writePromise);
        }

Domain

Subdomains

Called By

Frequently Asked Questions

What does write() do?
write() is a function in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java.
Where is write() defined?
write() is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2ConnectionEncoder.java at line 468.
What does write() call?
write() calls 3 function(s): error, size, write.
What calls write()?
write() is called by 2 function(s): error, write.

Analyze Your Own Codebase

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

Try Supermodel Free