Http2MaxRstFrameLimitEncoder Class — netty Architecture
Architecture documentation for the Http2MaxRstFrameLimitEncoder class in Http2MaxRstFrameLimitEncoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 70483983_583b_a156_29a1_a1f5db1cbe8a["Http2MaxRstFrameLimitEncoder"] 33e3648f_2b6f_2f41_9cbf_a20fdb28acae["Http2MaxRstFrameLimitEncoder.java"] 70483983_583b_a156_29a1_a1f5db1cbe8a -->|defined in| 33e3648f_2b6f_2f41_9cbf_a20fdb28acae 71d98c5a_ec46_9807_5470_6c861ee3a5b9["Http2MaxRstFrameLimitEncoder()"] 70483983_583b_a156_29a1_a1f5db1cbe8a -->|method| 71d98c5a_ec46_9807_5470_6c861ee3a5b9 13e76a88_a5cc_55c0_9aaf_c5b83bf423c8["lifecycleManager()"] 70483983_583b_a156_29a1_a1f5db1cbe8a -->|method| 13e76a88_a5cc_55c0_9aaf_c5b83bf423c8 5377e62a_6e94_1f44_1916_4aa3e2c8d5a3["ChannelFuture()"] 70483983_583b_a156_29a1_a1f5db1cbe8a -->|method| 5377e62a_6e94_1f44_1916_4aa3e2c8d5a3 980965b6_3c7a_be97_9097_595d39a50d76["countRstFrameErrorCode()"] 70483983_583b_a156_29a1_a1f5db1cbe8a -->|method| 980965b6_3c7a_be97_9097_595d39a50d76
Relationship Graph
Source Code
codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MaxRstFrameLimitEncoder.java lines 31–94
final class Http2MaxRstFrameLimitEncoder extends DecoratingHttp2ConnectionEncoder {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(Http2MaxRstFrameLimitEncoder.class);
private final long nanosPerWindow;
private final int maxRstFramesPerWindow;
private final Ticker ticker;
private long lastRstFrameNano;
private int sendRstInWindow;
private Http2LifecycleManager lifecycleManager;
Http2MaxRstFrameLimitEncoder(Http2ConnectionEncoder delegate, int maxRstFramesPerWindow, int secondsPerWindow) {
this(delegate, maxRstFramesPerWindow, secondsPerWindow, Ticker.systemTicker());
}
Http2MaxRstFrameLimitEncoder(Http2ConnectionEncoder delegate, int maxRstFramesPerWindow, int secondsPerWindow,
Ticker ticker) {
super(delegate);
this.maxRstFramesPerWindow = maxRstFramesPerWindow;
this.nanosPerWindow = TimeUnit.SECONDS.toNanos(secondsPerWindow);
this.ticker = ticker;
lastRstFrameNano = ticker.nanoTime();
}
@Override
public void lifecycleManager(Http2LifecycleManager lifecycleManager) {
this.lifecycleManager = lifecycleManager;
super.lifecycleManager(lifecycleManager);
}
@Override
public ChannelFuture writeRstStream(ChannelHandlerContext ctx, int streamId, long errorCode,
ChannelPromise promise) {
ChannelFuture future = super.writeRstStream(ctx, streamId, errorCode, promise);
if (countRstFrameErrorCode(errorCode)) {
long currentNano = ticker.nanoTime();
if (currentNano - lastRstFrameNano >= nanosPerWindow) {
lastRstFrameNano = currentNano;
sendRstInWindow = 1;
} else {
sendRstInWindow++;
if (sendRstInWindow > maxRstFramesPerWindow) {
Http2Exception exception = Http2Exception.connectionError(Http2Error.ENHANCE_YOUR_CALM,
"Maximum number %d of RST frames frames reached within %d seconds", maxRstFramesPerWindow,
TimeUnit.NANOSECONDS.toSeconds(nanosPerWindow));
logger.debug("{} Maximum number {} of RST frames reached within {} seconds, " +
"closing connection with {} error", ctx.channel(), maxRstFramesPerWindow,
TimeUnit.NANOSECONDS.toSeconds(nanosPerWindow), exception.error(),
exception);
// First notify the Http2LifecycleManager and then close the connection.
lifecycleManager.onError(ctx, true, exception);
ctx.close();
}
}
}
return future;
}
private boolean countRstFrameErrorCode(long errorCode) {
// Don't count CANCEL and NO_ERROR as these might be ok.
return errorCode != Http2Error.CANCEL.code() && errorCode != Http2Error.NO_ERROR.code();
}
}
Source
Frequently Asked Questions
What is the Http2MaxRstFrameLimitEncoder class?
Http2MaxRstFrameLimitEncoder is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MaxRstFrameLimitEncoder.java.
Where is Http2MaxRstFrameLimitEncoder defined?
Http2MaxRstFrameLimitEncoder is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/Http2MaxRstFrameLimitEncoder.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free