HashedWheelTimerTest Class — netty Architecture
Architecture documentation for the HashedWheelTimerTest class in HashedWheelTimerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 00b49e45_9607_bed0_2d5f_fd3bdc9b959f["HashedWheelTimerTest"] 8b1fd0cb_ec4c_8e3f_9ff5_6e8b62b71d6d["HashedWheelTimerTest.java"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|defined in| 8b1fd0cb_ec4c_8e3f_9ff5_6e8b62b71d6d 08d3d16d_15b9_a53c_2ca0_c1ec2018dad3["testScheduleTimeoutShouldNotRunBeforeDelay()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 08d3d16d_15b9_a53c_2ca0_c1ec2018dad3 630af61b_3921_71fc_0f7d_32338de39c60["testScheduleTimeoutShouldRunAfterDelay()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 630af61b_3921_71fc_0f7d_32338de39c60 4afc3817_5801_81bf_8cb4_ce5d8a87bd0c["testStopTimer()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 4afc3817_5801_81bf_8cb4_ce5d8a87bd0c 890ee8a4_685e_5d59_b0b2_0694b06fb41a["testTimerShouldThrowExceptionAfterShutdownForNewTimeouts()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 890ee8a4_685e_5d59_b0b2_0694b06fb41a 4fb9102e_2e65_98d1_2694_2b29203c606c["testTimerOverflowWheelLength()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 4fb9102e_2e65_98d1_2694_2b29203c606c 7becbeb5_da6a_7c11_06f2_e14ef82a1dd4["testExecutionOnTime()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 7becbeb5_da6a_7c11_06f2_e14ef82a1dd4 05850959_622a_2869_eb39_466a9901789c["testExecutionOnTaskExecutor()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 05850959_622a_2869_eb39_466a9901789c 0a00f6d8_faf0_eee8_562e_ede8b2cca08a["testRejectedExecutionExceptionWhenTooManyTimeoutsAreAddedBackToBack()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 0a00f6d8_faf0_eee8_562e_ede8b2cca08a ca2cf6ca_a17f_c8c7_5b29_c9d6b330e3f9["testNewTimeoutShouldStopThrowingRejectedExecutionExceptionWhenExistingTimeoutIsCancelled()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| ca2cf6ca_a17f_c8c7_5b29_c9d6b330e3f9 2b22fb00_dc3b_d53d_61b2_f282c2215e84["testNewTimeoutShouldStopThrowingRejectedExecutionExceptionWhenExistingTimeoutIsExecuted()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 2b22fb00_dc3b_d53d_61b2_f282c2215e84 08c0f897_4977_5c0b_cfb5_2cc368351487["reportPendingTimeouts()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 08c0f897_4977_5c0b_cfb5_2cc368351487 88d3dd85_6ac5_0ea4_5ad7_fdfdf4217edb["testOverflow()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| 88d3dd85_6ac5_0ea4_5ad7_fdfdf4217edb f0b9c669_7bcf_edbc_f596_573fb64e92ab["testStopTimerCancelsPendingTasks()"] 00b49e45_9607_bed0_2d5f_fd3bdc9b959f -->|method| f0b9c669_7bcf_edbc_f596_573fb64e92ab
Relationship Graph
Source Code
common/src/test/java/io/netty/util/HashedWheelTimerTest.java lines 35–368
public class HashedWheelTimerTest {
@Test
public void testScheduleTimeoutShouldNotRunBeforeDelay() throws InterruptedException {
final Timer timer = new HashedWheelTimer();
final CountDownLatch barrier = new CountDownLatch(1);
final Timeout timeout = timer.newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
fail("This should not have run");
barrier.countDown();
}
}, 10, TimeUnit.SECONDS);
assertFalse(barrier.await(3, TimeUnit.SECONDS));
assertFalse(timeout.isExpired(), "timer should not expire");
timer.stop();
}
@Test
public void testScheduleTimeoutShouldRunAfterDelay() throws InterruptedException {
final Timer timer = new HashedWheelTimer();
final CountDownLatch barrier = new CountDownLatch(1);
final Timeout timeout = timer.newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
barrier.countDown();
}
}, 2, TimeUnit.SECONDS);
assertTrue(barrier.await(3, TimeUnit.SECONDS));
assertTrue(timeout.isExpired(), "timer should expire");
timer.stop();
}
@Test
@org.junit.jupiter.api.Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
public void testStopTimer() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(3);
final Timer timerProcessed = new HashedWheelTimer();
for (int i = 0; i < 3; i ++) {
timerProcessed.newTimeout(new TimerTask() {
@Override
public void run(final Timeout timeout) throws Exception {
latch.countDown();
}
}, 1, TimeUnit.MILLISECONDS);
}
latch.await();
assertEquals(0, timerProcessed.stop().size(), "Number of unprocessed timeouts should be 0");
final Timer timerUnprocessed = new HashedWheelTimer();
for (int i = 0; i < 5; i ++) {
timerUnprocessed.newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
}
}, 5, TimeUnit.SECONDS);
}
Thread.sleep(1000L); // sleep for a second
assertFalse(timerUnprocessed.stop().isEmpty(), "Number of unprocessed timeouts should be greater than 0");
}
@Test
@org.junit.jupiter.api.Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
public void testTimerShouldThrowExceptionAfterShutdownForNewTimeouts() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(3);
final Timer timer = new HashedWheelTimer();
for (int i = 0; i < 3; i ++) {
timer.newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
latch.countDown();
}
}, 1, TimeUnit.MILLISECONDS);
}
latch.await();
timer.stop();
try {
timer.newTimeout(createNoOpTimerTask(), 1, TimeUnit.MILLISECONDS);
Source
Frequently Asked Questions
What is the HashedWheelTimerTest class?
HashedWheelTimerTest is a class in the netty codebase, defined in common/src/test/java/io/netty/util/HashedWheelTimerTest.java.
Where is HashedWheelTimerTest defined?
HashedWheelTimerTest is defined in common/src/test/java/io/netty/util/HashedWheelTimerTest.java at line 35.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free