SimpleChannelPoolTest Class — netty Architecture
Architecture documentation for the SimpleChannelPoolTest class in SimpleChannelPoolTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD dfb428cc_ecc3_d271_5689_7e428381a986["SimpleChannelPoolTest"] 73c783dd_d54e_0209_27c1_761064593525["SimpleChannelPoolTest.java"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|defined in| 73c783dd_d54e_0209_27c1_761064593525 7ee3490a_1492_c910_ee2c_a21beccb5068["testAcquire()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 7ee3490a_1492_c910_ee2c_a21beccb5068 987af820_7f06_6372_53f6_60207baf0284["testBoundedChannelPoolSegment()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 987af820_7f06_6372_53f6_60207baf0284 8fbf2461_6bdc_8ae7_1e7a_27e89b76b26e["testUnhealthyChannelIsNotOffered()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 8fbf2461_6bdc_8ae7_1e7a_27e89b76b26e 6bbbc43d_2d1c_2589_ce6c_f313e2fd83e0["testUnhealthyChannelIsOfferedWhenNoHealthCheckRequested()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 6bbbc43d_2d1c_2589_ce6c_f313e2fd83e0 11c2b736_3691_4346_003e_2374801f94e3["testBootstrap()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 11c2b736_3691_4346_003e_2374801f94e3 d866d4ba_b43a_befc_6965_597e3b0869f9["testHandler()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| d866d4ba_b43a_befc_6965_597e3b0869f9 3942cb04_6563_9352_b9f2_7d502a9eb2f9["testHealthChecker()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 3942cb04_6563_9352_b9f2_7d502a9eb2f9 3b8c27bb_da91_a998_f22d_967f94baad1a["testReleaseHealthCheck()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 3b8c27bb_da91_a998_f22d_967f94baad1a 73d3bc7c_1d20_5ad5_27e1_f8cb91620dee["testCloseAsync()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 73d3bc7c_1d20_5ad5_27e1_f8cb91620dee 93230eaa_c699_cb6d_4ae2_c0ac1c3a194b["testChannelAcquiredException()"] dfb428cc_ecc3_d271_5689_7e428381a986 -->|method| 93230eaa_c699_cb6d_4ae2_c0ac1c3a194b
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java lines 46–400
public class SimpleChannelPoolTest {
@Test
public void testAcquire() 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).sync().channel();
CountingChannelPoolHandler handler = new CountingChannelPoolHandler();
final ChannelPool pool = new SimpleChannelPool(cb, handler);
Channel channel = pool.acquire().sync().getNow();
pool.release(channel).syncUninterruptibly();
final Channel channel2 = pool.acquire().sync().getNow();
assertSame(channel, channel2);
assertEquals(1, handler.channelCount());
pool.release(channel2).syncUninterruptibly();
// Should fail on multiple release calls.
assertThrows(IllegalArgumentException.class, new Executable() {
@Override
public void execute() throws Throwable {
pool.release(channel2).syncUninterruptibly();
}
});
assertFalse(channel.isActive());
assertEquals(2, handler.acquiredCount());
assertEquals(2, handler.releasedCount());
sc.close().sync();
pool.close();
group.shutdownGracefully();
}
@Test
public void testBoundedChannelPoolSegment() 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).sync().channel();
CountingChannelPoolHandler handler = new CountingChannelPoolHandler();
final ChannelPool pool = new SimpleChannelPool(cb, handler, ChannelHealthChecker.ACTIVE) {
private final Queue<Channel> queue = new LinkedBlockingQueue<Channel>(1);
@Override
protected Channel pollChannel() {
return queue.poll();
Source
Frequently Asked Questions
What is the SimpleChannelPoolTest class?
SimpleChannelPoolTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java.
Where is SimpleChannelPoolTest defined?
SimpleChannelPoolTest is defined in transport/src/test/java/io/netty/channel/pool/SimpleChannelPoolTest.java at line 46.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free