Home / Class/ TestEventExecutor Class — netty Architecture

TestEventExecutor Class — netty Architecture

Architecture documentation for the TestEventExecutor class in AutoScalingEventExecutorChooserFactoryTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  621041f0_4644_9edd_5867_6d66d195dcf5["TestEventExecutor"]
  64bbeca7_14ae_a6e0_13bc_10ee775d5e7c["AutoScalingEventExecutorChooserFactoryTest.java"]
  621041f0_4644_9edd_5867_6d66d195dcf5 -->|defined in| 64bbeca7_14ae_a6e0_13bc_10ee775d5e7c
  4101a178_4afb_c280_7e07_263dc0a69ff6["TestEventExecutor()"]
  621041f0_4644_9edd_5867_6d66d195dcf5 -->|method| 4101a178_4afb_c280_7e07_263dc0a69ff6
  c81b705e_9115_5b4b_23a6_5102d314a007["setHighLoad()"]
  621041f0_4644_9edd_5867_6d66d195dcf5 -->|method| c81b705e_9115_5b4b_23a6_5102d314a007
  7381030b_fad1_d2e6_14a3_4852bdaf698c["run()"]
  621041f0_4644_9edd_5867_6d66d195dcf5 -->|method| 7381030b_fad1_d2e6_14a3_4852bdaf698c

Relationship Graph

Source Code

common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java lines 42–88

    private static final class TestEventExecutor extends SingleThreadEventExecutor {
        private final AtomicBoolean highLoad = new AtomicBoolean(false);

        TestEventExecutor(EventExecutorGroup parent, Executor executor) {
            super(parent, executor, true, true, DEFAULT_MAX_PENDING_EXECUTOR_TASKS,
                  RejectedExecutionHandlers.reject());
        }

        void setHighLoad(boolean highLoad) {
            this.highLoad.set(highLoad);
        }

        @Override
        protected void run() {
            do {
                if (highLoad.get()) {
                    runAllTasks(TimeUnit.MILLISECONDS.toNanos(20));
                    long busyWorkStart = ticker().nanoTime();
                    busyTask(35, TimeUnit.MILLISECONDS);
                    long busyWorkEnd = ticker().nanoTime();
                    reportActiveIoTime(busyWorkEnd - busyWorkStart);
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        Thread.currentThread().interrupt();
                        break;
                    }
                } else {
                    boolean ranTask = runAllTasks();
                    if (ranTask) {
                        updateLastExecutionTime();
                        // If we ran tasks, immediately loop back to check highLoad state
                        continue;
                    }

                    // No immediate tasks available, sleep to avoid busy waiting
                    // This allows the thread to be responsive to state changes while staying idle
                    try {
                        Thread.sleep(50);
                    } catch (InterruptedException e) {
                        Thread.currentThread().interrupt();
                        break;
                    }
                }
            } while (!confirmShutdown() && !canSuspend());
        }
    }

Frequently Asked Questions

What is the TestEventExecutor class?
TestEventExecutor is a class in the netty codebase, defined in common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java.
Where is TestEventExecutor defined?
TestEventExecutor is defined in common/src/test/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactoryTest.java at line 42.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free