Java Code Examples for jdk.jfr.Recording#setName()

The following examples show how to use jdk.jfr.Recording#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestRecordingInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording recording = new Recording(Configuration.getConfiguration("profile"));
    recording.setDestination(Paths.get(".", "my.jfr"));
    recording.setDumpOnExit(true);
    recording.setDuration(Duration.ofSeconds(60));
    recording.setMaxAge(Duration.ofHours(1));
    recording.setMaxSize(123456789);
    recording.setName("myName");
    recording.enable("java.exception_throw").with("threashold", "2 s");
    recording.setToDisk(true);

    recording.start();
    CommonHelper.verifyRecordingState(recording, RecordingState.RUNNING); // Wait until running

    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();
    RecordingInfo info = JmxHelper.verifyExists(recording.getId(), bean.getRecordings());

    System.out.println(JmxHelper.asString(recording));
    System.out.println(JmxHelper.asString(info));
    JmxHelper.verifyEquals(info, recording);

    recording.stop();
    recording.close();
}
 
Example 2
Source File: TestRecordingInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording recording = new Recording(Configuration.getConfiguration("profile"));
    recording.setDestination(Paths.get(".", "my.jfr"));
    recording.setDumpOnExit(true);
    recording.setDuration(Duration.ofSeconds(60));
    recording.setMaxAge(Duration.ofHours(1));
    recording.setMaxSize(123456789);
    recording.setName("myName");
    recording.enable("java.exception_throw").with("threashold", "2 s");
    recording.setToDisk(true);

    recording.start();
    CommonHelper.verifyRecordingState(recording, RecordingState.RUNNING); // Wait until running

    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();
    RecordingInfo info = JmxHelper.verifyExists(recording.getId(), bean.getRecordings());

    System.out.println(JmxHelper.asString(recording));
    System.out.println(JmxHelper.asString(info));
    JmxHelper.verifyEquals(info, recording);

    recording.stop();
    recording.close();
}
 
Example 3
Source File: TestRecordingInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    Recording recording = new Recording(Configuration.getConfiguration("profile"));
    recording.setDestination(Paths.get(".", "my.jfr"));
    recording.setDumpOnExit(true);
    recording.setDuration(Duration.ofSeconds(60));
    recording.setMaxAge(Duration.ofHours(1));
    recording.setMaxSize(123456789);
    recording.setName("myName");
    recording.enable("java.exception_throw").with("threashold", "2 s");
    recording.setToDisk(true);

    recording.start();
    CommonHelper.verifyRecordingState(recording, RecordingState.RUNNING); // Wait until running

    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();
    RecordingInfo info = JmxHelper.verifyExists(recording.getId(), bean.getRecordings());

    System.out.println(JmxHelper.asString(recording));
    System.out.println(JmxHelper.asString(info));
    JmxHelper.verifyEquals(info, recording);

    recording.stop();
    recording.close();
}
 
Example 4
Source File: TestRecordingBase.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void testSetGetName() throws Throwable {
    Recording r = new Recording();
    final String name = "TestName";
    r.setName(name);
    assertEquals(name, r.getName(), "Wrong set/get name");
    r.close();
}
 
Example 5
Source File: TestRecordingEnableDisable.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {

        Recording rA = new Recording();
        Recording rB = new Recording();

        rA.setName("rA");
        rB.setName("rB");

        final Path path = Paths.get(".", "my.jfr");
        rA.start();
        rB.start();

        for (int i = 0; i < 30; ++i) {
            SimpleEventHelper.createEvent(i);
            if (isMyEventEnabled(rA, rB)) {
                System.out.println("MyEvent enabled");
            }
            else {
                System.out.println("MyEvent disabled");
            }

            Files.write(path, "A".getBytes());
            if (isIoEnabled(rA, rB)) {
                System.out.println("IoEvent enabled");
            }
            else {
                System.out.println("IoEvent disabled");
            }
            Recording r = ((i % 2) == 0) ? rA : rB;
            updateSettings(r);
        }

        rA.stop();
        rB.stop();
        rA.close();
        rB.close();
    }
 
Example 6
Source File: TestRecordingBase.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void testSetGetName() throws Throwable {
    Recording r = new Recording();
    final String name = "TestName";
    r.setName(name);
    assertEquals(name, r.getName(), "Wrong set/get name");
    r.close();
}
 
Example 7
Source File: TestRecordingEnableDisable.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {

        Recording rA = new Recording();
        Recording rB = new Recording();

        rA.setName("rA");
        rB.setName("rB");

        final Path path = Paths.get(".", "my.jfr");
        rA.start();
        rB.start();

        for (int i = 0; i < 30; ++i) {
            SimpleEventHelper.createEvent(i);
            if (isMyEventEnabled(rA, rB)) {
                System.out.println("MyEvent enabled");
            }
            else {
                System.out.println("MyEvent disabled");
            }

            Files.write(path, "A".getBytes());
            if (isIoEnabled(rA, rB)) {
                System.out.println("IoEvent enabled");
            }
            else {
                System.out.println("IoEvent disabled");
            }
            Recording r = ((i % 2) == 0) ? rA : rB;
            updateSettings(r);
        }

        rA.stop();
        rB.stop();
        rA.close();
        rB.close();
    }
 
Example 8
Source File: TestRecordingBase.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void testSetGetName() throws Throwable {
    Recording r = new Recording();
    final String name = "TestName";
    r.setName(name);
    assertEquals(name, r.getName(), "Wrong set/get name");
    r.close();
}
 
Example 9
Source File: TestRecordingEnableDisable.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {

        Recording rA = new Recording();
        Recording rB = new Recording();

        rA.setName("rA");
        rB.setName("rB");

        final Path path = Paths.get(".", "my.jfr");
        rA.start();
        rB.start();

        for (int i = 0; i < 30; ++i) {
            SimpleEventHelper.createEvent(i);
            if (isMyEventEnabled(rA, rB)) {
                System.out.println("MyEvent enabled");
            }
            else {
                System.out.println("MyEvent disabled");
            }

            Files.write(path, "A".getBytes());
            if (isIoEnabled(rA, rB)) {
                System.out.println("IoEvent enabled");
            }
            else {
                System.out.println("IoEvent disabled");
            }
            Recording r = ((i % 2) == 0) ? rA : rB;
            updateSettings(r);
        }

        rA.stop();
        rB.stop();
        rA.close();
        rB.close();
    }
 
Example 10
Source File: TestActiveRecordingEvent.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void testWithPath(Path path) throws Throwable {
    Recording recording = new Recording();
    recording.enable(ACTIVE_RECORDING_EVENT_NAME);

    recording.setDuration(REC_DURATION);
    recording.setMaxSize(MAX_SIZE);
    recording.setMaxAge(MAX_AGE);
    recording.setName(REC_NAME);
    if (path != null) {
        recording.setToDisk(true);
        recording.setDestination(path);
    }

    long tsBeforeStart = Instant.now().toEpochMilli();
    recording.start();
    recording.stop();
    long tsAfterStop = Instant.now().toEpochMilli();

    List<RecordedEvent> events = Events.fromRecording(recording);

    Events.hasEvents(events);
    RecordedEvent ev = events.get(0);

    // Duration must be kept in milliseconds
    assertEquals(REC_DURATION.toMillis(), ev.getValue("recordingDuration"));

    assertEquals(MAX_SIZE, ev.getValue("maxSize"));

    // maxAge must be kept in milliseconds
    assertEquals(MAX_AGE.toMillis(), ev.getValue("maxAge"));

    EventType evType = ev.getEventType();
    ValueDescriptor durationField = evType.getField("recordingDuration");
    assertEquals(durationField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS);

    if (path == null) {
        assertNull(ev.getValue("destination"));
    } else {
        assertEquals(path.toAbsolutePath().toString(), ev.getValue("destination").toString());
    }

    ValueDescriptor recordingStartField = evType.getField("recordingStart");
    assertEquals(recordingStartField.getAnnotation(Timestamp.class).value(), Timestamp.MILLISECONDS_SINCE_EPOCH);

    long tsRecordingStart = ev.getValue("recordingStart");
    assertTrue(tsBeforeStart <= tsRecordingStart);
    assertTrue(tsAfterStop >= tsRecordingStart);

    assertEquals(recording.getId(), ev.getValue("id"));

    ValueDescriptor maxAgeField = evType.getField("maxAge");
    assertEquals(maxAgeField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS);
}
 
Example 11
Source File: TestActiveRecordingEvent.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void testWithPath(Path path) throws Throwable {
    Recording recording = new Recording();
    recording.enable(ACTIVE_RECORDING_EVENT_NAME);

    recording.setDuration(REC_DURATION);
    recording.setMaxSize(MAX_SIZE);
    recording.setMaxAge(MAX_AGE);
    recording.setName(REC_NAME);
    if (path != null) {
        recording.setToDisk(true);
        recording.setDestination(path);
    }

    long tsBeforeStart = Instant.now().toEpochMilli();
    recording.start();
    recording.stop();
    long tsAfterStop = Instant.now().toEpochMilli();

    List<RecordedEvent> events = Events.fromRecording(recording);

    Events.hasEvents(events);
    RecordedEvent ev = events.get(0);

    // Duration must be kept in milliseconds
    assertEquals(REC_DURATION.toMillis(), ev.getValue("recordingDuration"));

    assertEquals(MAX_SIZE, ev.getValue("maxSize"));

    // maxAge must be kept in milliseconds
    assertEquals(MAX_AGE.toMillis(), ev.getValue("maxAge"));

    EventType evType = ev.getEventType();
    ValueDescriptor durationField = evType.getField("recordingDuration");
    assertEquals(durationField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS);

    if (path == null) {
        assertNull(ev.getValue("destination"));
    } else {
        assertEquals(path.toAbsolutePath().toString(), ev.getValue("destination").toString());
    }

    ValueDescriptor recordingStartField = evType.getField("recordingStart");
    assertEquals(recordingStartField.getAnnotation(Timestamp.class).value(), Timestamp.MILLISECONDS_SINCE_EPOCH);

    long tsRecordingStart = ev.getValue("recordingStart");
    assertTrue(tsBeforeStart <= tsRecordingStart);
    assertTrue(tsAfterStop >= tsRecordingStart);

    assertEquals(recording.getId(), ev.getValue("id"));

    ValueDescriptor maxAgeField = evType.getField("maxAge");
    assertEquals(maxAgeField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS);
}
 
Example 12
Source File: TestActiveRecordingEvent.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void testWithPath(Path path) throws Throwable {
    Recording recording = new Recording();
    recording.enable(ACTIVE_RECORDING_EVENT_NAME);

    recording.setDuration(REC_DURATION);
    recording.setMaxSize(MAX_SIZE);
    recording.setMaxAge(MAX_AGE);
    recording.setName(REC_NAME);
    if (path != null) {
        recording.setToDisk(true);
        recording.setDestination(path);
    }

    long tsBeforeStart = Instant.now().toEpochMilli();
    recording.start();
    recording.stop();
    long tsAfterStop = Instant.now().toEpochMilli();

    List<RecordedEvent> events = Events.fromRecording(recording);

    Events.hasEvents(events);
    RecordedEvent ev = events.get(0);

    // Duration must be kept in milliseconds
    assertEquals(REC_DURATION.toMillis(), ev.getValue("recordingDuration"));

    assertEquals(MAX_SIZE, ev.getValue("maxSize"));

    // maxAge must be kept in milliseconds
    assertEquals(MAX_AGE.toMillis(), ev.getValue("maxAge"));

    EventType evType = ev.getEventType();
    ValueDescriptor durationField = evType.getField("recordingDuration");
    assertEquals(durationField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS);

    if (path == null) {
        assertNull(ev.getValue("destination"));
    } else {
        assertEquals(path.toAbsolutePath().toString(), ev.getValue("destination").toString());
    }

    ValueDescriptor recordingStartField = evType.getField("recordingStart");
    assertEquals(recordingStartField.getAnnotation(Timestamp.class).value(), Timestamp.MILLISECONDS_SINCE_EPOCH);

    long tsRecordingStart = ev.getValue("recordingStart");
    assertTrue(tsBeforeStart <= tsRecordingStart);
    assertTrue(tsAfterStop >= tsRecordingStart);

    assertEquals(recording.getId(), ev.getValue("id"));

    ValueDescriptor maxAgeField = evType.getField("maxAge");
    assertEquals(maxAgeField.getAnnotation(Timespan.class).value(), Timespan.MILLISECONDS);
}