Java Code Examples for jdk.jfr.consumer.RecordingFile#hasMoreEvents()

The following examples show how to use jdk.jfr.consumer.RecordingFile#hasMoreEvents() . 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: JSONWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void printEvents(RecordingFile es) throws IOException {
    printDataStructureName("events");
    printArrayBegin();
    boolean first = true;
    while (es.hasMoreEvents()) {
        RecordedEvent e = es.readEvent();
        printNewDataStructure(first, true, null);
        printEvent(e);
        flush();
        first = false;
    }
    printArrayEnd();
}
 
Example 2
Source File: TestReadTwice.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 r = new Recording();
    r.enable(MyEvent.class).withoutStackTrace();
    r.start();

    // Commit a single event to the recording
    MyEvent event = new MyEvent();
    event.commit();

    r.stop();

    // Dump the recording to a file
    Path path = Files.createTempFile("recording", ".jfr");
    System.out.println("Dumping to " + path);
    r.dump(path);
    r.close();

    // Read all events from the file in one go
    List<RecordedEvent> events = RecordingFile.readAllEvents(path);

    // Read again the same events one by one
    RecordingFile rfile = new RecordingFile(path);
    List<RecordedEvent> events2 = new LinkedList<>();
    while (rfile.hasMoreEvents()) {
        events2.add(rfile.readEvent());
    }

    // Compare sizes
    Asserts.assertEquals(events.size(), events2.size());
    rfile.close();
}
 
Example 3
Source File: TestEventFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void verifyEvent(RecordingFile rf) throws IOException {
    if (!rf.hasMoreEvents()) {
        throw new AssertionError("Expected one dynamic event");
    }
    verifyValues(rf.readEvent());
    if (rf.hasMoreEvents()) {
        throw new AssertionError("Expected one dynamic event");
    }
}
 
Example 4
Source File: TestReadTwice.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 r = new Recording();
    r.enable(MyEvent.class).withoutStackTrace();
    r.start();

    // Commit a single event to the recording
    MyEvent event = new MyEvent();
    event.commit();

    r.stop();

    // Dump the recording to a file
    Path path = Utils.createTempFile("read-twice", ".jfr");
    System.out.println("Dumping to " + path);
    r.dump(path);
    r.close();

    // Read all events from the file in one go
    List<RecordedEvent> events = RecordingFile.readAllEvents(path);

    // Read again the same events one by one
    RecordingFile rfile = new RecordingFile(path);
    List<RecordedEvent> events2 = new LinkedList<>();
    while (rfile.hasMoreEvents()) {
        events2.add(rfile.readEvent());
    }

    // Compare sizes
    Asserts.assertEquals(events.size(), events2.size());
    rfile.close();
}
 
Example 5
Source File: TestEventFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void verifyEvent(RecordingFile rf) throws IOException {
    if (!rf.hasMoreEvents()) {
        throw new AssertionError("Expected one dynamic event");
    }
    verifyValues(rf.readEvent());
    if (rf.hasMoreEvents()) {
        throw new AssertionError("Expected one dynamic event");
    }
}
 
Example 6
Source File: TestReadTwice.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 r = new Recording();
    r.enable(MyEvent.class).withoutStackTrace();
    r.start();

    // Commit a single event to the recording
    MyEvent event = new MyEvent();
    event.commit();

    r.stop();

    // Dump the recording to a file
    Path path = Utils.createTempFile("read-twice", ".jfr");
    System.out.println("Dumping to " + path);
    r.dump(path);
    r.close();

    // Read all events from the file in one go
    List<RecordedEvent> events = RecordingFile.readAllEvents(path);

    // Read again the same events one by one
    RecordingFile rfile = new RecordingFile(path);
    List<RecordedEvent> events2 = new LinkedList<>();
    while (rfile.hasMoreEvents()) {
        events2.add(rfile.readEvent());
    }

    // Compare sizes
    Asserts.assertEquals(events.size(), events2.size());
    rfile.close();
}
 
Example 7
Source File: TestEventFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void verifyEvent(RecordingFile rf) throws IOException {
    if (!rf.hasMoreEvents()) {
        throw new AssertionError("Expected one dynamic event");
    }
    verifyValues(rf.readEvent());
    if (rf.hasMoreEvents()) {
        throw new AssertionError("Expected one dynamic event");
    }
}