QuicConnectionStatsTest Class — netty Architecture
Architecture documentation for the QuicConnectionStatsTest class in QuicConnectionStatsTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 0860b84f_d0cb_aba0_8368_9cc08dfb6cdc["QuicConnectionStatsTest"] b220f67a_319b_54a2_ebd7_0d9bfe1d120e["QuicConnectionStatsTest.java"] 0860b84f_d0cb_aba0_8368_9cc08dfb6cdc -->|defined in| b220f67a_319b_54a2_ebd7_0d9bfe1d120e b156fca5_0a46_0a8f_7ef9_f638a61f7e25["testStatsAreCollected()"] 0860b84f_d0cb_aba0_8368_9cc08dfb6cdc -->|method| b156fca5_0a46_0a8f_7ef9_f638a61f7e25 0c3f61b1_f916_78b8_26f0_b8f4ecb31910["assertStats()"] 0860b84f_d0cb_aba0_8368_9cc08dfb6cdc -->|method| 0c3f61b1_f916_78b8_26f0_b8f4ecb31910
Relationship Graph
Source Code
codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionStatsTest.java lines 36–141
public class QuicConnectionStatsTest extends AbstractQuicTest {
@ParameterizedTest
@MethodSource("newSslTaskExecutors")
public void testStatsAreCollected(Executor executor) throws Throwable {
Channel server = null;
Channel channel = null;
AtomicInteger counter = new AtomicInteger();
Promise<QuicConnectionStats> serverActiveStats = ImmediateEventExecutor.INSTANCE.newPromise();
Promise<QuicConnectionStats> serverInactiveStats = ImmediateEventExecutor.INSTANCE.newPromise();
QuicChannelValidationHandler serverHandler = new QuicChannelValidationHandler() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
super.channelActive(ctx);
collectStats(ctx, serverActiveStats);
}
@Override
public void channelInactive(ChannelHandlerContext ctx) {
collectStats(ctx, serverInactiveStats);
ctx.fireChannelInactive();
}
private void collectStats(ChannelHandlerContext ctx, Promise<QuicConnectionStats> promise) {
QuicheQuicChannel channel = (QuicheQuicChannel) ctx.channel();
channel.collectStats(promise);
}
};
QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();
try {
server = QuicTestUtils.newServer(executor, serverHandler, new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
counter.incrementAndGet();
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
// Let's just echo back the message.
ctx.writeAndFlush(msg);
}
@Override
public boolean isSharable() {
return true;
}
});
channel = QuicTestUtils.newClient(executor);
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(server.localAddress())
.connect().get();
assertNotNull(quicChannel.collectStats().sync().getNow());
quicChannel.createStream(QuicStreamType.BIDIRECTIONAL, new ChannelInboundHandlerAdapter() {
private final int bufferSize = 8;
private int received;
@Override
public void channelActive(ChannelHandlerContext ctx) {
ctx.writeAndFlush(Unpooled.buffer().writeZero(bufferSize));
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
ByteBuf buffer = (ByteBuf) msg;
received += buffer.readableBytes();
buffer.release();
if (received == bufferSize) {
ctx.close().addListener((ChannelFuture future) -> {
// Close the underlying QuicChannel as well.
future.channel().parent().close();
});
}
}
}).sync();
// Wait until closure
Source
Frequently Asked Questions
What is the QuicConnectionStatsTest class?
QuicConnectionStatsTest is a class in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionStatsTest.java.
Where is QuicConnectionStatsTest defined?
QuicConnectionStatsTest is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicConnectionStatsTest.java at line 36.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free