setup() — netty Function Reference
Architecture documentation for the setup() function in EpollSocketChannelBenchmark.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 82ffb78c_cbbc_11f5_0d1f_af090f75205e["setup()"] 1b64bade_715a_bad2_74e3_ba8a9d114f53["EpollSocketChannelBenchmark"] 82ffb78c_cbbc_11f5_0d1f_af090f75205e -->|defined in| 1b64bade_715a_bad2_74e3_ba8a9d114f53 style 82ffb78c_cbbc_11f5_0d1f_af090f75205e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
microbench/src/main/java/io/netty/microbench/channel/epoll/EpollSocketChannelBenchmark.java lines 52–132
@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());
}
});
}
})
.group(group)
.connect(serverChan.localAddress())
.sync()
.channel();
abyte = chan.alloc().directBuffer(1);
abyte.writeByte('a');
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does setup() do?
setup() is a function in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/channel/epoll/EpollSocketChannelBenchmark.java.
Where is setup() defined?
setup() is defined in microbench/src/main/java/io/netty/microbench/channel/epoll/EpollSocketChannelBenchmark.java at line 52.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free