ReentrantChannelTest Class — netty Architecture
Architecture documentation for the ReentrantChannelTest class in ReentrantChannelTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 13a11eea_27b7_44b5_a4d5_69eb21dd0e09["ReentrantChannelTest"] 02d7cd68_2601_7c8b_c874_ac553d2129b9["ReentrantChannelTest.java"] 13a11eea_27b7_44b5_a4d5_69eb21dd0e09 -->|defined in| 02d7cd68_2601_7c8b_c874_ac553d2129b9 de74e55a_e2a8_7d5a_138f_b5c265bff952["testWritabilityChanged()"] 13a11eea_27b7_44b5_a4d5_69eb21dd0e09 -->|method| de74e55a_e2a8_7d5a_138f_b5c265bff952 ef11a39e_d0ab_0511_0453_427051cac84f["testFlushInWritabilityChanged()"] 13a11eea_27b7_44b5_a4d5_69eb21dd0e09 -->|method| ef11a39e_d0ab_0511_0453_427051cac84f b53ee246_8f81_f0bd_b037_e9d5a67324ad["testWriteFlushPingPong()"] 13a11eea_27b7_44b5_a4d5_69eb21dd0e09 -->|method| b53ee246_8f81_f0bd_b037_e9d5a67324ad f88fc585_cf0a_1ba8_606e_8f4d4be7b258["testCloseInFlush()"] 13a11eea_27b7_44b5_a4d5_69eb21dd0e09 -->|method| f88fc585_cf0a_1ba8_606e_8f4d4be7b258 19fbe94a_ce47_fc05_828c_8c5b59dd4105["testFlushFailure()"] 13a11eea_27b7_44b5_a4d5_69eb21dd0e09 -->|method| 19fbe94a_ce47_fc05_828c_8c5b59dd4105 da3878d1_9916_f6ab_77a8_b57486aa58a3["nestReentrancy()"] 13a11eea_27b7_44b5_a4d5_69eb21dd0e09 -->|method| da3878d1_9916_f6ab_77a8_b57486aa58a3
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/ReentrantChannelTest.java lines 41–399
public class ReentrantChannelTest extends BaseChannelTest {
@Test
public void testWritabilityChanged() throws Exception {
LocalAddress addr = new LocalAddress("testWritabilityChanged");
ServerBootstrap sb = getLocalServerBootstrap();
sb.bind(addr).sync().channel();
Bootstrap cb = getLocalClientBootstrap();
setInterest(Event.WRITE, Event.FLUSH, Event.WRITABILITY);
Channel clientChannel = cb.connect(addr).sync().channel();
clientChannel.config().setWriteBufferLowWaterMark(512);
clientChannel.config().setWriteBufferHighWaterMark(1024);
// What is supposed to happen from this point:
//
// 1. Because this write attempt has been made from a non-I/O thread,
// ChannelOutboundBuffer.pendingWriteBytes will be increased before
// write() event is really evaluated.
// -> channelWritabilityChanged() will be triggered,
// because the Channel became unwritable.
//
// 2. The write() event is handled by the pipeline in an I/O thread.
// -> write() will be triggered.
//
// 3. Once the write() event is handled, ChannelOutboundBuffer.pendingWriteBytes
// will be decreased.
// -> channelWritabilityChanged() will be triggered,
// because the Channel became writable again.
//
// 4. The message is added to the ChannelOutboundBuffer and thus
// pendingWriteBytes will be increased again.
// -> channelWritabilityChanged() will be triggered.
//
// 5. The flush() event causes the write request in theChannelOutboundBuffer
// to be removed.
// -> flush() and channelWritabilityChanged() will be triggered.
//
// Note that the channelWritabilityChanged() in the step 4 can occur between
// the flush() and the channelWritabilityChanged() in the step 5, because
// the flush() is invoked from a non-I/O thread while the other are from
// an I/O thread.
ChannelFuture future = clientChannel.write(createTestBuf(2000));
clientChannel.flush();
future.sync();
clientChannel.close().sync();
assertLog(
// Case 1:
"WRITABILITY: writable=false\n" +
"WRITE\n" +
"WRITABILITY: writable=false\n" +
"WRITABILITY: writable=false\n" +
"FLUSH\n" +
"WRITABILITY: writable=true\n",
// Case 2:
"WRITABILITY: writable=false\n" +
"WRITE\n" +
"WRITABILITY: writable=false\n" +
"FLUSH\n" +
"WRITABILITY: writable=true\n" +
"WRITABILITY: writable=true\n");
}
/**
* Similar to {@link #testWritabilityChanged()} with slight variation.
*/
@Test
public void testFlushInWritabilityChanged() throws Exception {
LocalAddress addr = new LocalAddress("testFlushInWritabilityChanged");
ServerBootstrap sb = getLocalServerBootstrap();
sb.bind(addr).sync().channel();
Source
Frequently Asked Questions
What is the ReentrantChannelTest class?
ReentrantChannelTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/ReentrantChannelTest.java.
Where is ReentrantChannelTest defined?
ReentrantChannelTest is defined in transport/src/test/java/io/netty/channel/ReentrantChannelTest.java at line 41.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free