EpollSocketChannelBenchmark Class — netty Architecture
Architecture documentation for the EpollSocketChannelBenchmark class in EpollSocketChannelBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1b64bade_715a_bad2_74e3_ba8a9d114f53["EpollSocketChannelBenchmark"] 440507ef_8970_a87a_48c3_d94d4a6b3bd9["EpollSocketChannelBenchmark.java"] 1b64bade_715a_bad2_74e3_ba8a9d114f53 -->|defined in| 440507ef_8970_a87a_48c3_d94d4a6b3bd9 82ffb78c_cbbc_11f5_0d1f_af090f75205e["setup()"] 1b64bade_715a_bad2_74e3_ba8a9d114f53 -->|method| 82ffb78c_cbbc_11f5_0d1f_af090f75205e 6ada7fe6_a601_9cd0_cdd3_072f65b2edcf["tearDown()"] 1b64bade_715a_bad2_74e3_ba8a9d114f53 -->|method| 6ada7fe6_a601_9cd0_cdd3_072f65b2edcf aadfae58_d6ec_71af_cbaf_3310acbbe50c["Object()"] 1b64bade_715a_bad2_74e3_ba8a9d114f53 -->|method| aadfae58_d6ec_71af_cbaf_3310acbbe50c
Relationship Graph
Source Code
microbench/src/main/java/io/netty/microbench/channel/epoll/EpollSocketChannelBenchmark.java lines 40–158
public class EpollSocketChannelBenchmark extends AbstractMicrobenchmark {
private static final Runnable runnable = new Runnable() {
@Override
public void run() { }
};
private EventLoopGroup group;
private Channel serverChan;
private Channel chan;
private ByteBuf abyte;
private Future<?> future;
@Setup
public void setup() throws Exception {
group = new MultiThreadIoEventLoopGroup(1, EpollIoHandler.newFactory());
// add an arbitrary timeout to make the timer reschedule
future = group.schedule(new Runnable() {
@Override
public void run() {
throw new AssertionError();
}
}, 5, TimeUnit.MINUTES);
serverChan = new ServerBootstrap()
.channel(EpollServerSocketChannel.class)
.group(group)
.childHandler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addLast(new ChannelDuplexHandler() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof ByteBuf) {
ctx.writeAndFlush(msg, ctx.voidPromise());
} else {
throw new AssertionError();
}
}
});
}
})
.bind(0)
.sync()
.channel();
chan = new Bootstrap()
.channel(EpollSocketChannel.class)
.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addLast(new ChannelDuplexHandler() {
private ChannelPromise lastWritePromise;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof ByteBuf) {
ByteBuf buf = (ByteBuf) msg;
try {
if (buf.readableBytes() == 1) {
lastWritePromise.trySuccess();
lastWritePromise = null;
} else {
throw new AssertionError();
}
} finally {
buf.release();
}
} else {
throw new AssertionError();
}
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
throws Exception {
if (lastWritePromise != null) {
throw new IllegalStateException();
}
lastWritePromise = promise;
super.write(ctx, msg, ctx.voidPromise());
Defined In
Source
Frequently Asked Questions
What is the EpollSocketChannelBenchmark class?
EpollSocketChannelBenchmark is a class in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/channel/epoll/EpollSocketChannelBenchmark.java.
Where is EpollSocketChannelBenchmark defined?
EpollSocketChannelBenchmark is defined in microbench/src/main/java/io/netty/microbench/channel/epoll/EpollSocketChannelBenchmark.java at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free