Home / Class/ ByteCounter Class — netty Architecture

ByteCounter Class — netty Architecture

Architecture documentation for the ByteCounter class in NoPriorityByteDistributionBenchmark.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  2c52aad5_37a2_e1fd_00b4_5e4b4fb43de8["ByteCounter"]
  279fab0c_16a0_85c7_c9ea_cb95941ef43a["NoPriorityByteDistributionBenchmark.java"]
  2c52aad5_37a2_e1fd_00b4_5e4b4fb43de8 -->|defined in| 279fab0c_16a0_85c7_c9ea_cb95941ef43a
  af9824ac_7220_18ff_1137_1c1d2a831cfe["ByteCounter()"]
  2c52aad5_37a2_e1fd_00b4_5e4b4fb43de8 -->|method| af9824ac_7220_18ff_1137_1c1d2a831cfe
  3aee1b47_699e_09ba_a3b7_6a0a261ee75b["updateStreamableBytes()"]
  2c52aad5_37a2_e1fd_00b4_5e4b4fb43de8 -->|method| 3aee1b47_699e_09ba_a3b7_6a0a261ee75b
  59891554_2be9_fcbf_8f89_1f3baf4ec9b1["updateDependencyTree()"]
  2c52aad5_37a2_e1fd_00b4_5e4b4fb43de8 -->|method| 59891554_2be9_fcbf_8f89_1f3baf4ec9b1
  2dcab111_2797_a7d0_08a9_9c9b7907a154["distribute()"]
  2c52aad5_37a2_e1fd_00b4_5e4b4fb43de8 -->|method| 2dcab111_2797_a7d0_08a9_9c9b7907a154

Relationship Graph

Source Code

microbench/src/main/java/io/netty/microbench/http2/NoPriorityByteDistributionBenchmark.java lines 245–295

    private final class ByteCounter implements StreamByteDistributor {
        private final StreamByteDistributor delegate;

        private ByteCounter(StreamByteDistributor delegate) {
            this.delegate = delegate;
        }

        @Override
        public void updateStreamableBytes(StreamState state) {
            delegate.updateStreamableBytes(state);
        }

        @Override
        public void updateDependencyTree(int childStreamId, int parentStreamId, short weight, boolean exclusive) {
            delegate.updateDependencyTree(childStreamId, parentStreamId, weight, exclusive);
        }

        @Override
        public boolean distribute(int maxBytes, Writer writer) throws Http2Exception {
            return delegate.distribute(maxBytes, new CountingWriter(writer));
        }

        private final class CountingWriter implements Writer {
            private final Writer delegate;

            private CountingWriter(Writer delegate) {
                this.delegate = delegate;
            }

            @Override
            public void write(Http2Stream stream, int numBytes) {
                if (numBytes > 0) {
                    // Add the data to the refresher so that it can be given back to the
                    // stream at the end of the iteration.
                    DataRefresher refresher = dataRefresher(stream);
                    refresher.add(numBytes);

                    ++counters.numWrites;
                    counters.totalBytes += numBytes;
                    if (numBytes < counters.minWriteSize) {
                        counters.minWriteSize = numBytes;
                    }
                    if (numBytes > counters.maxWriteSize) {
                        counters.maxWriteSize = numBytes;
                    }
                }

                delegate.write(stream, numBytes);
            }
        }
    }

Frequently Asked Questions

What is the ByteCounter class?
ByteCounter is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/http2/NoPriorityByteDistributionBenchmark.java.
Where is ByteCounter defined?
ByteCounter is defined in microbench/src/main/java/io/netty/microbench/http2/NoPriorityByteDistributionBenchmark.java at line 245.

Analyze Your Own Codebase

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

Try Supermodel Free