Home / Class/ NonStickyEventExecutorGroupTest Class — netty Architecture

NonStickyEventExecutorGroupTest Class — netty Architecture

Architecture documentation for the NonStickyEventExecutorGroupTest class in NonStickyEventExecutorGroupTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d2c2f535_6e38_2696_75d2_7afac99b078a["NonStickyEventExecutorGroupTest"]
  efa53066_0667_edb0_1914_141afc870408["NonStickyEventExecutorGroupTest.java"]
  d2c2f535_6e38_2696_75d2_7afac99b078a -->|defined in| efa53066_0667_edb0_1914_141afc870408
  03efb36b_8355_12d6_ab7e_0cb5f589e96e["testInvalidGroup()"]
  d2c2f535_6e38_2696_75d2_7afac99b078a -->|method| 03efb36b_8355_12d6_ab7e_0cb5f589e96e
  d5893745_7691_5b98_f080_83ab28a2c49b["data()"]
  d2c2f535_6e38_2696_75d2_7afac99b078a -->|method| d5893745_7691_5b98_f080_83ab28a2c49b
  a5a7ef77_49a5_2174_475c_896e0d12611b["testOrdering()"]
  d2c2f535_6e38_2696_75d2_7afac99b078a -->|method| a5a7ef77_49a5_2174_475c_896e0d12611b
  1eacf891_c5e9_622e_43c4_60bd21c51c50["testRaceCondition()"]
  d2c2f535_6e38_2696_75d2_7afac99b078a -->|method| 1eacf891_c5e9_622e_43c4_60bd21c51c50
  14b687f0_1586_e71c_9bd1_aa3dff7998ea["testInEventLoopAfterReschedulingFailure()"]
  d2c2f535_6e38_2696_75d2_7afac99b078a -->|method| 14b687f0_1586_e71c_9bd1_aa3dff7998ea
  d369a955_11b2_c7ca_40f7_c70d0810e451["execute()"]
  d2c2f535_6e38_2696_75d2_7afac99b078a -->|method| d369a955_11b2_c7ca_40f7_c70d0810e451

Relationship Graph

Source Code

common/src/test/java/io/netty/util/concurrent/NonStickyEventExecutorGroupTest.java lines 41–329

public class NonStickyEventExecutorGroupTest {
    private static final String PARAMETERIZED_NAME = "{index}: maxTaskExecutePerRun = {0}";

    @Test
    public void testInvalidGroup() {
        final EventExecutorGroup group = new DefaultEventExecutorGroup(1);
        try {
            assertThrows(IllegalArgumentException.class, new Executable() {
                @Override
                public void execute() {
                    new NonStickyEventExecutorGroup(group);
                }
            });
        } finally {
            group.shutdownGracefully();
        }
    }

    public static Collection<Object[]> data() throws Exception {
        List<Object[]> params = new ArrayList<Object[]>();
        params.add(new Object[] {64});
        params.add(new Object[] {256});
        params.add(new Object[] {1024});
        params.add(new Object[] {Integer.MAX_VALUE});
        return params;
    }

    @ParameterizedTest(name = PARAMETERIZED_NAME)
    @MethodSource("data")
    @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
    public void testOrdering(int maxTaskExecutePerRun) throws Throwable {
        final int threads = NettyRuntime.availableProcessors() * 2;
        final EventExecutorGroup group = new UnorderedThreadPoolEventExecutor(threads);
        final NonStickyEventExecutorGroup nonStickyGroup = new NonStickyEventExecutorGroup(group, maxTaskExecutePerRun);
        try {
            final CountDownLatch startLatch = new CountDownLatch(1);
            final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
            List<Thread> threadList = new ArrayList<Thread>(threads);
            for (int i = 0 ; i < threads; i++) {
                Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            execute(nonStickyGroup, startLatch);
                        } catch (Throwable cause) {
                            error.compareAndSet(null, cause);
                        }
                    }
                });
                threadList.add(thread);
                thread.start();
            }
            startLatch.countDown();
            for (Thread t: threadList) {
                t.join();
            }
            Throwable cause = error.get();
            if (cause != null) {
                throw cause;
            }
        } finally {
            nonStickyGroup.shutdownGracefully();
        }
    }

    @ParameterizedTest(name = PARAMETERIZED_NAME)
    @MethodSource("data")
    public void testRaceCondition(int maxTaskExecutePerRun) throws InterruptedException {
        EventExecutorGroup group = new UnorderedThreadPoolEventExecutor(1);
        NonStickyEventExecutorGroup nonStickyGroup = new NonStickyEventExecutorGroup(group, maxTaskExecutePerRun);

        try {
            EventExecutor executor = nonStickyGroup.next();

            for (int j = 0; j < 5000; j++) {
                final CountDownLatch firstCompleted = new CountDownLatch(1);
                final CountDownLatch latch = new CountDownLatch(2);
                for (int i = 0; i < 2; i++) {
                    executor.execute(new Runnable() {
                        @Override
                        public void run() {

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free