Home / Class/ FlightRecorderTest Class — netty Architecture

FlightRecorderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  5524177b_fab5_a7f3_543b_444503b791cb["FlightRecorderTest"]
  70fc0681_5557_d123_2a04_8ea9364c459e["FlightRecorderTest.java"]
  5524177b_fab5_a7f3_543b_444503b791cb -->|defined in| 70fc0681_5557_d123_2a04_8ea9364c459e
  ca90535e_27c3_66db_0956_0e326cb5129b["testJfrEnabled()"]
  5524177b_fab5_a7f3_543b_444503b791cb -->|method| ca90535e_27c3_66db_0956_0e326cb5129b
  2e642c04_8fa9_492c_c551_57e921ab300f["testAdaptiveAllocatorEvent()"]
  5524177b_fab5_a7f3_543b_444503b791cb -->|method| 2e642c04_8fa9_492c_c551_57e921ab300f

Relationship Graph

Source Code

testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/FlightRecorderTest.java lines 36–72

public class FlightRecorderTest {

    @Test
    public void testJfrEnabled() {
        assertTrue(PlatformDependent.isJfrEnabled());
    }

    @EnabledForJreRange(min = JRE.JAVA_17) // RecordingStream
    @Timeout(10)
    @Test
    public void testAdaptiveAllocatorEvent()  throws Exception {

        ClassLoader cl = ClassLoader.getSystemClassLoader();
        Class<?> recordingStreamClass = cl.loadClass("jdk.jfr.consumer.RecordingStream");
        Constructor<?> ctor = recordingStreamClass.getConstructor();
        Method enableMethod = recordingStreamClass.getMethod("enable", String.class);
        Method onEventMethod = recordingStreamClass.getMethod("onEvent", String.class, Consumer.class);
        Method startAsyncMethod = recordingStreamClass.getMethod("startAsync");
        Object recordingStream = ctor.newInstance();

        try (AutoCloseable c = (AutoCloseable) recordingStream) {
            CompletableFuture<RecordedEvent> allocateFuture = new CompletableFuture<>();
            Consumer<RecordedEvent> complete = allocateFuture::complete;
            enableMethod.invoke(recordingStream, "io.netty.AllocateChunk");
            onEventMethod.invoke(recordingStream, "io.netty.AllocateChunk", complete);
            startAsyncMethod.invoke(recordingStream);

            AdaptiveByteBufAllocator alloc = new AdaptiveByteBufAllocator(true, false);
            alloc.directBuffer(128).release();

            RecordedEvent allocate = allocateFuture.get();
            assertTrue(allocate.getBoolean("pooled"));
            assertFalse(allocate.getBoolean("threadLocal"));
            assertTrue(allocate.getBoolean("direct"));
        }
    }
}

Frequently Asked Questions

What is the FlightRecorderTest class?
FlightRecorderTest is a class in the netty codebase, defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/FlightRecorderTest.java.
Where is FlightRecorderTest defined?
FlightRecorderTest is defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/FlightRecorderTest.java at line 36.

Analyze Your Own Codebase

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

Try Supermodel Free