Home / Class/ DefaultState Class — netty Architecture

DefaultState Class — netty Architecture

Architecture documentation for the DefaultState class in DefaultHttp2LocalFlowController.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  45d84eff_651d_e7b2_c74b_baa69a4b9a46["DefaultState"]
  40872612_d507_c116_2a45_f6a7304d70c3["DefaultHttp2LocalFlowController.java"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|defined in| 40872612_d507_c116_2a45_f6a7304d70c3
  87cc7b6b_084a_2d73_f3e8_72c10f5e9df8["DefaultState()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 87cc7b6b_084a_2d73_f3e8_72c10f5e9df8
  8c10e539_c458_c1c5_0e65_4634ab77891c["window()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 8c10e539_c458_c1c5_0e65_4634ab77891c
  77cdebf4_06e3_6aee_d889_ec6ae1010514["windowSize()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 77cdebf4_06e3_6aee_d889_ec6ae1010514
  0a901b1e_fe09_7d37_2b31_e9c669168f65["initialWindowSize()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 0a901b1e_fe09_7d37_2b31_e9c669168f65
  039e5f5a_d327_a52e_1d1d_c2a37cfcb39b["endOfStream()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 039e5f5a_d327_a52e_1d1d_c2a37cfcb39b
  b19934c9_762a_a6ef_846d_78846cc038d8["windowUpdateRatio()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| b19934c9_762a_a6ef_846d_78846cc038d8
  99d2bb23_5d25_b9c3_9198_e95ecb1dcb00["incrementInitialStreamWindow()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 99d2bb23_5d25_b9c3_9198_e95ecb1dcb00
  6c8131a5_8522_16f2_0337_17791bd40117["incrementFlowControlWindows()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 6c8131a5_8522_16f2_0337_17791bd40117
  9523c9a0_347c_e559_6167_578b8b4e1289["receiveFlowControlledFrame()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 9523c9a0_347c_e559_6167_578b8b4e1289
  61d990c0_a422_284b_0163_1929df9f14e5["returnProcessedBytes()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 61d990c0_a422_284b_0163_1929df9f14e5
  a8ec61e3_3bd1_b8ce_6ec2_534b49608d0a["consumeBytes()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| a8ec61e3_3bd1_b8ce_6ec2_534b49608d0a
  dee433fc_8cf9_8aa8_72d9_8fd1710c26cc["unconsumedBytes()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| dee433fc_8cf9_8aa8_72d9_8fd1710c26cc
  03837159_529f_3d31_e83d_d29893d9aba0["writeWindowUpdateIfNeeded()"]
  45d84eff_651d_e7b2_c74b_baa69a4b9a46 -->|method| 03837159_529f_3d31_e83d_d29893d9aba0

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2LocalFlowController.java lines 322–485

    private class DefaultState implements FlowState {
        private final Http2Stream stream;

        /**
         * The actual flow control window that is decremented as soon as {@code DATA} arrives.
         */
        private int window;

        /**
         * A view of {@link #window} that is used to determine when to send {@code WINDOW_UPDATE}
         * frames. Decrementing this window for received {@code DATA} frames is delayed until the
         * application has indicated that the data has been fully processed. This prevents sending
         * a {@code WINDOW_UPDATE} until the number of processed bytes drops below the threshold.
         */
        private int processedWindow;

        /**
         * This is what is used to determine how many bytes need to be returned relative to {@link #processedWindow}.
         * Each stream has their own initial window size.
         */
        private int initialStreamWindowSize;

        /**
         * This is used to determine when {@link #processedWindow} is sufficiently far away from
         * {@link #initialStreamWindowSize} such that a {@code WINDOW_UPDATE} should be sent.
         * Each stream has their own window update ratio.
         */
        private float streamWindowUpdateRatio;

        private int lowerBound;
        private boolean endOfStream;

        DefaultState(Http2Stream stream, int initialWindowSize) {
            this.stream = stream;
            window(initialWindowSize);
            streamWindowUpdateRatio = windowUpdateRatio;
        }

        @Override
        public void window(int initialWindowSize) {
            assert ctx == null || ctx.executor().inEventLoop();
            window = processedWindow = initialStreamWindowSize = initialWindowSize;
        }

        @Override
        public int windowSize() {
            return window;
        }

        @Override
        public int initialWindowSize() {
            return initialStreamWindowSize;
        }

        @Override
        public void endOfStream(boolean endOfStream) {
            this.endOfStream = endOfStream;
        }

        @Override
        public float windowUpdateRatio() {
            return streamWindowUpdateRatio;
        }

        @Override
        public void windowUpdateRatio(float ratio) {
            assert ctx == null || ctx.executor().inEventLoop();
            streamWindowUpdateRatio = ratio;
        }

        @Override
        public void incrementInitialStreamWindow(int delta) {
            // Clip the delta so that the resulting initialStreamWindowSize falls within the allowed range.
            int newValue = (int) min(MAX_INITIAL_WINDOW_SIZE,
                    max(MIN_INITIAL_WINDOW_SIZE, initialStreamWindowSize + (long) delta));
            delta = newValue - initialStreamWindowSize;

            initialStreamWindowSize += delta;
        }

        @Override

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free