testUnhealthyChannelIsNotOffered() — netty Function Reference
Architecture documentation for the testUnhealthyChannelIsNotOffered() function in SimpleChannelPoolTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 8fbf2461_6bdc_8ae7_1e7a_27e89b76b26e["testUnhealthyChannelIsNotOffered()"] dfb428cc_ecc3_d271_5689_7e428381a986["SimpleChannelPoolTest"] 8fbf2461_6bdc_8ae7_1e7a_27e89b76b26e -->|defined in| dfb428cc_ecc3_d271_5689_7e428381a986 style 8fbf2461_6bdc_8ae7_1e7a_27e89b76b26e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java lines 162–201
@Test
public void testUnhealthyChannelIsNotOffered() throws Exception {
EventLoopGroup group = new MultiThreadIoEventLoopGroup(LocalIoHandler.newFactory());
LocalAddress addr = new LocalAddress(getLocalAddrId());
Bootstrap cb = new Bootstrap();
cb.remoteAddress(addr);
cb.group(group)
.channel(LocalChannel.class);
ServerBootstrap sb = new ServerBootstrap();
sb.group(group)
.channel(LocalServerChannel.class)
.childHandler(new ChannelInitializer<LocalChannel>() {
@Override
public void initChannel(LocalChannel ch) throws Exception {
ch.pipeline().addLast(new ChannelInboundHandlerAdapter());
}
});
// Start server
Channel sc = sb.bind(addr).syncUninterruptibly().channel();
ChannelPoolHandler handler = new CountingChannelPoolHandler();
ChannelPool pool = new SimpleChannelPool(cb, handler);
Channel channel1 = pool.acquire().syncUninterruptibly().getNow();
pool.release(channel1).syncUninterruptibly();
Channel channel2 = pool.acquire().syncUninterruptibly().getNow();
//first check that when returned healthy then it actually offered back to the pool.
assertSame(channel1, channel2);
channel1.close().syncUninterruptibly();
pool.release(channel1).syncUninterruptibly();
Channel channel3 = pool.acquire().syncUninterruptibly().getNow();
//channel1 was not healthy anymore so it should not get acquired anymore.
assertNotSame(channel1, channel3);
sc.close().syncUninterruptibly();
channel3.close().syncUninterruptibly();
pool.close();
group.shutdownGracefully();
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testUnhealthyChannelIsNotOffered() do?
testUnhealthyChannelIsNotOffered() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java.
Where is testUnhealthyChannelIsNotOffered() defined?
testUnhealthyChannelIsNotOffered() is defined in transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java at line 162.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free