Home / Class/ State Class — netty Architecture

State Class — netty Architecture

Architecture documentation for the State class in WeightedFairQueueByteDistributor.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  7bb99c84_0884_e59e_f284_a7da408d2406["State"]
  71cf42ec_8b96_e844_a28e_f91e8e96ff66["WeightedFairQueueByteDistributor.java"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|defined in| 71cf42ec_8b96_e844_a28e_f91e8e96ff66
  c917735b_d24b_2117_4bb3_2cfe991fa070["State()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| c917735b_d24b_2117_4bb3_2cfe991fa070
  e7564f5e_a83e_9a00_89a6_e897079b3574["isDescendantOf()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| e7564f5e_a83e_9a00_89a6_e897079b3574
  fb17eda3_f88a_c99f_e79c_e7e5ccb06a40["takeChild()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| fb17eda3_f88a_c99f_e79c_e7e5ccb06a40
  a7426564_13ec_4caa_ec35_83d94c9ad9d0["removeChild()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| a7426564_13ec_4caa_ec35_83d94c9ad9d0
  1fffb7e5_18e2_6d2d_5034_f6b396e3925d["getTotalWeight()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 1fffb7e5_18e2_6d2d_5034_f6b396e3925d
  14668215_be12_0440_a4cb_6e6686da3f8a["removeAllChildrenExcept()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 14668215_be12_0440_a4cb_6e6686da3f8a
  0bfeea84_edf2_a350_f986_e4dde4dc5152["setParent()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 0bfeea84_edf2_a350_f986_e4dde4dc5152
  4d1be32d_ee4e_92e3_9f28_345b81895f7c["initChildrenIfEmpty()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 4d1be32d_ee4e_92e3_9f28_345b81895f7c
  8d0c762f_3641_1298_766d_c1efcbdd7b69["initChildren()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 8d0c762f_3641_1298_766d_c1efcbdd7b69
  92f89bf4_2b10_7968_2875_1890f0eed386["write()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 92f89bf4_2b10_7968_2875_1890f0eed386
  4ff2400b_5ed4_4092_bc1a_dfee981e6cf7["activeCountChangeForTree()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 4ff2400b_5ed4_4092_bc1a_dfee981e6cf7
  3042fea5_9611_a8ff_248e_a67b1cffbc63["updateStreamableBytes()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 3042fea5_9611_a8ff_248e_a67b1cffbc63
  44e16369_7668_ebe2_f028_9d6680dd00c4["updatePseudoTime()"]
  7bb99c84_0884_e59e_f284_a7da408d2406 -->|method| 44e16369_7668_ebe2_f028_9d6680dd00c4

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java lines 432–781

    private final class State implements PriorityQueueNode {
        private static final byte STATE_IS_ACTIVE = 0x1;
        private static final byte STATE_IS_DISTRIBUTING = 0x2;
        private static final byte STATE_STREAM_ACTIVATED = 0x4;

        /**
         * Maybe {@code null} if the stream if the stream is not active.
         */
        Http2Stream stream;
        State parent;
        IntObjectMap<State> children = IntCollections.emptyMap();
        private final PriorityQueue<State> pseudoTimeQueue;
        final int streamId;
        int streamableBytes;
        int dependencyTreeDepth;
        /**
         * Count of nodes rooted at this sub tree with {@link #isActive()} equal to {@code true}.
         */
        int activeCountForTree;
        private int pseudoTimeQueueIndex = INDEX_NOT_IN_QUEUE;
        private int stateOnlyQueueIndex = INDEX_NOT_IN_QUEUE;
        /**
         * An estimate of when this node should be given the opportunity to write data.
         */
        long pseudoTimeToWrite;
        /**
         * A pseudo time maintained for immediate children to base their {@link #pseudoTimeToWrite} off of.
         */
        long pseudoTime;
        long totalQueuedWeights;
        private byte flags;
        short weight = DEFAULT_PRIORITY_WEIGHT;

        State(int streamId) {
            this(streamId, null, 0);
        }

        State(Http2Stream stream) {
            this(stream, 0);
        }

        State(Http2Stream stream, int initialSize) {
            this(stream.id(), stream, initialSize);
        }

        State(int streamId, Http2Stream stream, int initialSize) {
            this.stream = stream;
            this.streamId = streamId;
            pseudoTimeQueue = new DefaultPriorityQueue<State>(StatePseudoTimeComparator.INSTANCE, initialSize);
        }

        boolean isDescendantOf(State state) {
            State next = parent;
            while (next != null) {
                if (next == state) {
                    return true;
                }
                next = next.parent;
            }
            return false;
        }

        void takeChild(State child, boolean exclusive, List<ParentChangedEvent> events) {
            takeChild(null, child, exclusive, events);
        }

        /**
         * Adds a child to this priority. If exclusive is set, any children of this node are moved to being dependent on
         * the child.
         */
        void takeChild(Iterator<IntObjectMap.PrimitiveEntry<State>> childItr, State child, boolean exclusive,
                       List<ParentChangedEvent> events) {
            State oldParent = child.parent;

            if (oldParent != this) {
                events.add(new ParentChangedEvent(child, oldParent));
                child.setParent(this);
                // If the childItr is not null we are iterating over the oldParent.children collection and should
                // use the iterator to remove from the collection to avoid concurrent modification. Otherwise it is
                // assumed we are not iterating over this collection and it is safe to call remove directly.
                if (childItr != null) {

Frequently Asked Questions

What is the State class?
State is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java.
Where is State defined?
State is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/WeightedFairQueueByteDistributor.java at line 432.

Analyze Your Own Codebase

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

Try Supermodel Free