testScaleUpDoesNotExceedMaxThreads() — netty Function Reference
Architecture documentation for the testScaleUpDoesNotExceedMaxThreads() function in AutoScalingEventExecutorChooserFactoryTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 37ecfbd1_4171_5557_1ae6_d06132219da3["testScaleUpDoesNotExceedMaxThreads()"] b457a618_1afa_e8a9_dd34_152c53154c93["AutoScalingEventExecutorChooserFactoryTest"] 37ecfbd1_4171_5557_1ae6_d06132219da3 -->|defined in| b457a618_1afa_e8a9_dd34_152c53154c93 451cbcf6_6cbf_b404_e07f_191549368cc2["TestEventExecutorGroup()"] 37ecfbd1_4171_5557_1ae6_d06132219da3 -->|calls| 451cbcf6_6cbf_b404_e07f_191549368cc2 70a22675_9cb3_276f_a519_80257cc8a1a0["startAllExecutors()"] 37ecfbd1_4171_5557_1ae6_d06132219da3 -->|calls| 70a22675_9cb3_276f_a519_80257cc8a1a0 c81b705e_9115_5b4b_23a6_5102d314a007["setHighLoad()"] 37ecfbd1_4171_5557_1ae6_d06132219da3 -->|calls| c81b705e_9115_5b4b_23a6_5102d314a007 style 37ecfbd1_4171_5557_1ae6_d06132219da3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java lines 197–243
@Test
@Timeout(30)
void testScaleUpDoesNotExceedMaxThreads() throws Exception {
TestEventExecutorGroup group = new TestEventExecutorGroup(1, 2, 50, TimeUnit.MILLISECONDS);
try {
startAllExecutors(group);
Thread.sleep(200); // Allow time for initial scale-down to minThreads
assertEquals(1, group.activeExecutorCount());
TestEventExecutor activeExecutor = null;
for (EventExecutor exec : group) {
if (!exec.isSuspended()) {
activeExecutor = (TestEventExecutor) exec;
break;
}
}
if (activeExecutor == null) {
fail("Could not find an active executor to stress.");
}
activeExecutor.setHighLoad(true);
// Wait for the UtilizationMonitor to react and scale up.
long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5);
while (group.activeExecutorCount() < 2 && System.nanoTime() < deadline) {
Thread.sleep(50);
}
assertEquals(2, group.activeExecutorCount(), "Should scale up to maxThreads");
// Now that we have scaled up, put all active executors under a high load
// to prevent the new one from being scaled back down immediately.
for (EventExecutor exec : group) {
if (!exec.isSuspended()) {
((TestEventExecutor) exec).setHighLoad(true);
}
}
// Further calls to next() should not increase the count, and the group should
// remain at its max size because both threads are now busy.
group.next();
Thread.sleep(200); // Give the monitor time to check again.
assertEquals(2, group.activeExecutorCount(),
"Should not scale back down while load is high");
} finally {
group.shutdownGracefully().syncUninterruptibly();
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does testScaleUpDoesNotExceedMaxThreads() do?
testScaleUpDoesNotExceedMaxThreads() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java.
Where is testScaleUpDoesNotExceedMaxThreads() defined?
testScaleUpDoesNotExceedMaxThreads() is defined in common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java at line 197.
What does testScaleUpDoesNotExceedMaxThreads() call?
testScaleUpDoesNotExceedMaxThreads() calls 3 function(s): TestEventExecutorGroup, setHighLoad, startAllExecutors.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free