Home / Function/ testScaleUp() — netty Function Reference

testScaleUp() — netty Function Reference

Architecture documentation for the testScaleUp() function in AutoScalingEventExecutorChooserFactoryTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  31e8cd5d_3da2_e457_e392_791da6763b49["testScaleUp()"]
  b457a618_1afa_e8a9_dd34_152c53154c93["AutoScalingEventExecutorChooserFactoryTest"]
  31e8cd5d_3da2_e457_e392_791da6763b49 -->|defined in| b457a618_1afa_e8a9_dd34_152c53154c93
  451cbcf6_6cbf_b404_e07f_191549368cc2["TestEventExecutorGroup()"]
  31e8cd5d_3da2_e457_e392_791da6763b49 -->|calls| 451cbcf6_6cbf_b404_e07f_191549368cc2
  70a22675_9cb3_276f_a519_80257cc8a1a0["startAllExecutors()"]
  31e8cd5d_3da2_e457_e392_791da6763b49 -->|calls| 70a22675_9cb3_276f_a519_80257cc8a1a0
  c81b705e_9115_5b4b_23a6_5102d314a007["setHighLoad()"]
  31e8cd5d_3da2_e457_e392_791da6763b49 -->|calls| c81b705e_9115_5b4b_23a6_5102d314a007
  style 31e8cd5d_3da2_e457_e392_791da6763b49 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java lines 124–169

    @Test
    @Timeout(30)
    void testScaleUp() throws InterruptedException {
        TestEventExecutorGroup group = new TestEventExecutorGroup(1, 3, 50, TimeUnit.MILLISECONDS);
        try {
            startAllExecutors(group);
            Thread.sleep(200);
            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);

            // The monitor will see high utilization on the active thread. After 2 cycles (100 ms),
            // it will decide to 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 2 after stressing one executor.");

            for (EventExecutor exec : group) {
                if (!exec.isSuspended()) {
                    ((TestEventExecutor) exec).setHighLoad(true);
                }
            }

            while (group.activeExecutorCount() < 3 && System.nanoTime() < deadline) {
                Thread.sleep(50);
            }
            assertEquals(3, group.activeExecutorCount(),
                         "Should scale up to 3 after stressing two executors.");
        } finally {
            group.shutdownGracefully().syncUninterruptibly();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testScaleUp() do?
testScaleUp() is a function in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java.
Where is testScaleUp() defined?
testScaleUp() is defined in common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java at line 124.
What does testScaleUp() call?
testScaleUp() 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