Home / Class/ Http2MaxRstFrameListener Class — netty Architecture

Http2MaxRstFrameListener Class — netty Architecture

Architecture documentation for the Http2MaxRstFrameListener class in Http2MaxRstFrameListener.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f6cc9826_c4b6_0da1_8bf8_712b2f00e3a1["Http2MaxRstFrameListener"]
  25a35630_fbbf_6838_fe06_199a50146db1["Http2MaxRstFrameListener.java"]
  f6cc9826_c4b6_0da1_8bf8_712b2f00e3a1 -->|defined in| 25a35630_fbbf_6838_fe06_199a50146db1
  add77f49_44a1_9106_7659_cc4dd7a667ec["Http2MaxRstFrameListener()"]
  f6cc9826_c4b6_0da1_8bf8_712b2f00e3a1 -->|method| add77f49_44a1_9106_7659_cc4dd7a667ec
  63209e61_b71d_9b11_0c5c_2b29862bcad3["onRstStreamRead()"]
  f6cc9826_c4b6_0da1_8bf8_712b2f00e3a1 -->|method| 63209e61_b71d_9b11_0c5c_2b29862bcad3

Relationship Graph

Source Code

codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MaxRstFrameListener.java lines 25–60

final class Http2MaxRstFrameListener extends Http2FrameListenerDecorator {
    private static final InternalLogger logger = InternalLoggerFactory.getInstance(Http2MaxRstFrameListener.class);
    private static final Http2Exception RST_FRAME_RATE_EXCEEDED = Http2Exception.newStatic(Http2Error.ENHANCE_YOUR_CALM,
            "Maximum number of RST frames reached",
            Http2Exception.ShutdownHint.HARD_SHUTDOWN, Http2MaxRstFrameListener.class, "onRstStreamRead(..)");

    private final long nanosPerWindow;
    private final int maxRstFramesPerWindow;
    private long lastRstFrameNano = System.nanoTime();
    private int receivedRstInWindow;

    Http2MaxRstFrameListener(Http2FrameListener listener, int maxRstFramesPerWindow, int secondsPerWindow) {
        super(listener);
        this.maxRstFramesPerWindow = maxRstFramesPerWindow;
        this.nanosPerWindow = TimeUnit.SECONDS.toNanos(secondsPerWindow);
    }

    @Override
    public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) throws Http2Exception {
        long currentNano = System.nanoTime();
        if (currentNano - lastRstFrameNano >= nanosPerWindow) {
            lastRstFrameNano = currentNano;
            receivedRstInWindow = 1;
        } else {
            receivedRstInWindow++;
            if (receivedRstInWindow > maxRstFramesPerWindow) {
                logger.debug("{} Maximum number {} of RST frames reached within {} seconds, " +
                                "closing connection with {} error", ctx.channel(), maxRstFramesPerWindow,
                        TimeUnit.NANOSECONDS.toSeconds(nanosPerWindow), RST_FRAME_RATE_EXCEEDED.error(),
                        RST_FRAME_RATE_EXCEEDED);
                throw RST_FRAME_RATE_EXCEEDED;
            }
        }
        super.onRstStreamRead(ctx, streamId, errorCode);
    }
}

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free