Home / Class/ FakeFlowControlled Class — netty Architecture

FakeFlowControlled Class — netty Architecture

Architecture documentation for the FakeFlowControlled class in DefaultHttp2RemoteFlowControllerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd["FakeFlowControlled"]
  151982d5_edbe_2785_5895_4670aa555104["DefaultHttp2RemoteFlowControllerTest.java"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|defined in| 151982d5_edbe_2785_5895_4670aa555104
  136071dd_c92e_5482_7cb2_c1ba0769c1ab["FakeFlowControlled()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| 136071dd_c92e_5482_7cb2_c1ba0769c1ab
  2138bd63_dd75_adae_bf55_ec27bb49f749["size()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| 2138bd63_dd75_adae_bf55_ec27bb49f749
  9baf4bc7_c696_1a99_a197_637e1878ae95["originalSize()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| 9baf4bc7_c696_1a99_a197_637e1878ae95
  46be14d4_2ad4_2dfe_fa3e_2212c0d8e50e["error()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| 46be14d4_2ad4_2dfe_fa3e_2212c0d8e50e
  5af4576c_23ff_8e3b_df41_9d71757029eb["writeComplete()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| 5af4576c_23ff_8e3b_df41_9d71757029eb
  abf1bc09_403f_110e_0b96_d73f451a8f8b["write()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| abf1bc09_403f_110e_0b96_d73f451a8f8b
  00fd93b0_e80e_3de0_eaa4_9b896f69e83c["merge()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| 00fd93b0_e80e_3de0_eaa4_9b896f69e83c
  cef12f3c_7ba5_f21c_d8bc_55d129c6c1b0["written()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| cef12f3c_7ba5_f21c_d8bc_55d129c6c1b0
  4d627b61_f0ea_0927_043f_7bfb246d71d1["assertNotWritten()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| 4d627b61_f0ea_0927_043f_7bfb246d71d1
  d7bb96bf_47aa_9ae7_f5a1_7aaad102fb27["assertPartiallyWritten()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| d7bb96bf_47aa_9ae7_f5a1_7aaad102fb27
  da0712d5_2b96_e340_6c7a_17114adb9efc["assertFullyWritten()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| da0712d5_2b96_e340_6c7a_17114adb9efc
  3cd0e74f_b811_ae1d_06a2_395e3e3422ef["assertMerged()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| 3cd0e74f_b811_ae1d_06a2_395e3e3422ef
  d35164e2_8346_f5f5_f90a_f92c38f3329a["assertError()"]
  f33d41f9_6d94_fcc8_6c0d_546200c5b4cd -->|method| d35164e2_8346_f5f5_f90a_f92c38f3329a

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowControllerTest.java lines 1039–1145

    private static final class FakeFlowControlled implements Http2RemoteFlowController.FlowControlled {
        private int currentPadding;
        private int currentPayloadSize;
        private int originalPayloadSize;
        private int originalPadding;
        private boolean writeCalled;
        private final boolean mergeable;
        private boolean merged;

        private Throwable t;

        private FakeFlowControlled(int size) {
            this(size, false);
        }

        private FakeFlowControlled(int size, boolean mergeable) {
            this(size, 0, mergeable);
        }

        private FakeFlowControlled(int payloadSize, int padding, boolean mergeable) {
            currentPayloadSize = originalPayloadSize = payloadSize;
            currentPadding = originalPadding = padding;
            this.mergeable = mergeable;
        }

        @Override
        public int size() {
            return currentPayloadSize + currentPadding;
        }

        private int originalSize() {
            return originalPayloadSize + originalPadding;
        }

        @Override
        public void error(ChannelHandlerContext ctx, Throwable t) {
            this.t = t;
        }

        @Override
        public void writeComplete() {
        }

        @Override
        public void write(ChannelHandlerContext ctx, int allowedBytes) {
            if (allowedBytes <= 0 && size() != 0) {
                // Write has been called but no data can be written
                return;
            }
            writeCalled = true;
            int written = Math.min(size(), allowedBytes);
            if (written > currentPayloadSize) {
                written -= currentPayloadSize;
                currentPayloadSize = 0;
                currentPadding -= written;
            } else {
                currentPayloadSize -= written;
            }
        }

        @Override
        public boolean merge(ChannelHandlerContext ctx, Http2RemoteFlowController.FlowControlled next) {
            if (mergeable && next instanceof FakeFlowControlled) {
                FakeFlowControlled ffcNext = (FakeFlowControlled) next;
                originalPayloadSize += ffcNext.originalPayloadSize;
                currentPayloadSize += ffcNext.originalPayloadSize;
                currentPadding = originalPadding = Math.max(originalPadding, ffcNext.originalPadding);
                ffcNext.merged = true;
                return true;
            }
            return false;
        }

        public int written() {
            return originalSize() - size();
        }

        public void assertNotWritten() {
            assertFalse(writeCalled);
        }

Frequently Asked Questions

What is the FakeFlowControlled class?
FakeFlowControlled is a class in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowControllerTest.java.
Where is FakeFlowControlled defined?
FakeFlowControlled is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2RemoteFlowControllerTest.java at line 1039.

Analyze Your Own Codebase

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

Try Supermodel Free