AbstractSingleThreadEventLoopTest Class — netty Architecture
Architecture documentation for the AbstractSingleThreadEventLoopTest class in AbstractSingleThreadEventLoopTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD eb487d77_b896_e5c3_20f1_2b7144dc7cf5["AbstractSingleThreadEventLoopTest"] 642db6b1_0111_80ad_75bd_94e07bc2724f["AbstractSingleThreadEventLoopTest.java"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|defined in| 642db6b1_0111_80ad_75bd_94e07bc2724f 52462c2e_4250_f1ae_61ef_3b822985a83b["testChannelsRegistered()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| 52462c2e_4250_f1ae_61ef_3b822985a83b d3288ff6_2cfa_b5ba_fcb4_f110c904eaec["checkNumRegisteredChannels()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| d3288ff6_2cfa_b5ba_fcb4_f110c904eaec 8e4c2417_e591_227d_d30d_62c23430fd6d["registeredChannels()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| 8e4c2417_e591_227d_d30d_62c23430fd6d 8aaf6d39_4799_7d00_5dfa_97001ead14a6["shutdownBeforeStart()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| 8aaf6d39_4799_7d00_5dfa_97001ead14a6 61ee028d_53b0_fd24_87a5_97b527bda5e8["shutdownGracefullyZeroQuietBeforeStart()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| 61ee028d_53b0_fd24_87a5_97b527bda5e8 cc6824c7_f166_8489_ce94_e326389a63c6["testShutdownGracefullyNoQuietPeriod()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| cc6824c7_f166_8489_ce94_e326389a63c6 735696fb_8a26_60c8_7f44_72d58a2f1b42["shutdownGracefullyBeforeStart()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| 735696fb_8a26_60c8_7f44_72d58a2f1b42 2d5aa692_75dd_63d1_8349_df49dffdb982["gracefulShutdownAfterStart()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| 2d5aa692_75dd_63d1_8349_df49dffdb982 85bd87ad_e38f_a747_1986_6bbe9126a367["testChannelsIteratorEmpty()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| 85bd87ad_e38f_a747_1986_6bbe9126a367 b755284f_722b_7273_735c_350c2bc74ed2["testChannelsIterator()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| b755284f_722b_7273_735c_350c2bc74ed2 c048b53a_33d7_8392_8dee_df47ef4ded8d["testChannelsIteratorRemoveThrows()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| c048b53a_33d7_8392_8dee_df47ef4ded8d 2012ac34_71c4_b515_84ff_cc5d05dbe7de["schedulingAndCancellingTasks()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| 2012ac34_71c4_b515_84ff_cc5d05dbe7de fa9c03dd_2805_1c69_4551_e646750ea727["testAutoScalingEventLoopGroupCanScaleDownAndBeUsed()"] eb487d77_b896_e5c3_20f1_2b7144dc7cf5 -->|method| fa9c03dd_2805_1c69_4551_e646750ea727
Relationship Graph
Source Code
testsuite/src/main/java/io/netty/testsuite/transport/AbstractSingleThreadEventLoopTest.java lines 59–453
public abstract class AbstractSingleThreadEventLoopTest {
protected static final int SCALING_MIN_THREADS = 1;
protected static final int SCALING_MAX_THREADS = 2;
protected static final long SCALING_WINDOW_SECONDS = 100;
protected static final TimeUnit SCALING_WINDOW_UNIT = MILLISECONDS;
protected static final double SCALEDOWN_THRESHOLD = 0.2;
protected static final double SCALEUP_THRESHOLD = 0.9;
protected static final int SCALING_PATIENCE_CYCLES = 1;
protected static final EventExecutorChooserFactory AUTO_SCALING_CHOOSER_FACTORY =
new AutoScalingEventExecutorChooserFactory(SCALING_MIN_THREADS, SCALING_MAX_THREADS, SCALING_WINDOW_SECONDS,
SCALING_WINDOW_UNIT, SCALEDOWN_THRESHOLD, SCALEUP_THRESHOLD,
SCALING_MAX_THREADS, SCALING_MAX_THREADS, SCALING_PATIENCE_CYCLES
);
@Test
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testChannelsRegistered() throws Exception {
EventLoopGroup group = newEventLoopGroup();
final SingleThreadEventLoop loop = (SingleThreadEventLoop) group.next();
try {
final Channel ch1 = newChannel();
final Channel ch2 = newChannel();
int rc = registeredChannels(loop);
boolean channelCountSupported = rc != -1;
if (channelCountSupported) {
assertEquals(0, registeredChannels(loop));
}
assertTrue(loop.register(ch1).syncUninterruptibly().isSuccess());
assertTrue(loop.register(ch2).syncUninterruptibly().isSuccess());
if (channelCountSupported) {
checkNumRegisteredChannels(loop, 2);
}
assertTrue(ch1.deregister().syncUninterruptibly().isSuccess());
if (channelCountSupported) {
checkNumRegisteredChannels(loop, 1);
}
} finally {
group.shutdownGracefully();
}
}
private static void checkNumRegisteredChannels(SingleThreadEventLoop loop, int numChannels) throws Exception {
// We need to loop as some EventLoop implementations may need some time to update the counter correctly.
while (registeredChannels(loop) != numChannels) {
Thread.sleep(50);
}
}
// Only reliable if run from event loop
private static int registeredChannels(final SingleThreadEventLoop loop) throws Exception {
return loop.submit(new Callable<Integer>() {
@Override
public Integer call() {
return loop.registeredChannels();
}
}).get(1, TimeUnit.SECONDS);
}
@Test
@SuppressWarnings("deprecation")
public void shutdownBeforeStart() throws Exception {
EventLoopGroup group = newEventLoopGroup();
assertFalse(group.awaitTermination(2, TimeUnit.MILLISECONDS));
group.shutdown();
assertTrue(group.awaitTermination(200, TimeUnit.MILLISECONDS));
}
@Test
public void shutdownGracefullyZeroQuietBeforeStart() throws Exception {
EventLoopGroup group = newEventLoopGroup();
assertTrue(group.shutdownGracefully(0L, 2L, TimeUnit.SECONDS).await(200L));
}
// Copied from AbstractEventLoopTest
@Test
Defined In
Source
Frequently Asked Questions
What is the AbstractSingleThreadEventLoopTest class?
AbstractSingleThreadEventLoopTest is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/AbstractSingleThreadEventLoopTest.java.
Where is AbstractSingleThreadEventLoopTest defined?
AbstractSingleThreadEventLoopTest is defined in testsuite/src/main/java/io/netty/testsuite/transport/AbstractSingleThreadEventLoopTest.java at line 59.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free