Java Code Examples for jdk.management.jfr.FlightRecorderMXBean#cloneRecording()

The following examples show how to use jdk.management.jfr.FlightRecorderMXBean#cloneRecording() . 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: TestCloneRepeat.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long orgId = bean.newRecording();
    bean.startRecording(orgId);

    List<Integer> ids = new ArrayList<>();
    for (int i=0; i<5; i++) {
        long cloneId = bean.cloneRecording(orgId, false);
        SimpleEventHelper.createEvent(i);
        bean.stopRecording(cloneId);
        Path path = Paths.get(".", i + "-org.jfr");
        bean.copyTo(cloneId, path.toString());
        bean.closeRecording(cloneId);
        ids.add(i);
        verifyEvents(path, ids);
    }

    bean.closeRecording(orgId);
}
 
Example 2
Source File: TestCloneRepeat.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long orgId = bean.newRecording();
    bean.startRecording(orgId);

    List<Integer> ids = new ArrayList<>();
    for (int i=0; i<5; i++) {
        long cloneId = bean.cloneRecording(orgId, false);
        SimpleEventHelper.createEvent(i);
        bean.stopRecording(cloneId);
        Path path = Paths.get(".", i + "-org.jfr");
        bean.copyTo(cloneId, path.toString());
        bean.closeRecording(cloneId);
        ids.add(i);
        verifyEvents(path, ids);
    }

    bean.closeRecording(orgId);
}
 
Example 3
Source File: TestCloneRepeat.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long orgId = bean.newRecording();
    bean.startRecording(orgId);

    List<Integer> ids = new ArrayList<>();
    for (int i=0; i<5; i++) {
        long cloneId = bean.cloneRecording(orgId, false);
        SimpleEventHelper.createEvent(i);
        bean.stopRecording(cloneId);
        Path path = Paths.get(".", i + "-org.jfr");
        bean.copyTo(cloneId, path.toString());
        bean.closeRecording(cloneId);
        ids.add(i);
        verifyEvents(path, ids);
    }

    bean.closeRecording(orgId);
}
 
Example 4
Source File: TestClone.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long orgId = bean.newRecording();
    bean.startRecording(orgId);
    SimpleEventHelper.createEvent(1); // Should be in both org and clone

    long cloneId = bean.cloneRecording(orgId, false);
    Asserts.assertNotEquals(orgId, cloneId, "clone id should not be same as org id");

    List<RecordingInfo> recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.RUNNING, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.RUNNING, recordings);

    bean.stopRecording(orgId);
    recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.STOPPED, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.RUNNING, recordings);

    SimpleEventHelper.createEvent(2);  // Should only be in clone

    bean.stopRecording(cloneId);
    recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.STOPPED, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.STOPPED, recordings);

    Path orgPath = Paths.get(".", "org.jfr");
    Path clonePath = Paths.get(".", "clone.jfr");
    bean.copyTo(orgId, orgPath.toString());
    bean.copyTo(cloneId, clonePath.toString());

    verifyEvents(orgPath, 1);
    verifyEvents(clonePath, 1, 2);

    bean.closeRecording(orgId);
    bean.closeRecording(cloneId);
}
 
Example 5
Source File: TestClone.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long orgId = bean.newRecording();
    bean.startRecording(orgId);
    SimpleEventHelper.createEvent(1); // Should be in both org and clone

    long cloneId = bean.cloneRecording(orgId, false);
    Asserts.assertNotEquals(orgId, cloneId, "clone id should not be same as org id");

    List<RecordingInfo> recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.RUNNING, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.RUNNING, recordings);

    bean.stopRecording(orgId);
    recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.STOPPED, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.RUNNING, recordings);

    SimpleEventHelper.createEvent(2);  // Should only be in clone

    bean.stopRecording(cloneId);
    recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.STOPPED, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.STOPPED, recordings);

    Path orgPath = Paths.get(".", "org.jfr");
    Path clonePath = Paths.get(".", "clone.jfr");
    bean.copyTo(orgId, orgPath.toString());
    bean.copyTo(cloneId, clonePath.toString());

    verifyEvents(orgPath, 1);
    verifyEvents(clonePath, 1, 2);

    bean.closeRecording(orgId);
    bean.closeRecording(cloneId);
}
 
Example 6
Source File: TestClone.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();

    long orgId = bean.newRecording();
    bean.startRecording(orgId);
    SimpleEventHelper.createEvent(1); // Should be in both org and clone

    long cloneId = bean.cloneRecording(orgId, false);
    Asserts.assertNotEquals(orgId, cloneId, "clone id should not be same as org id");

    List<RecordingInfo> recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.RUNNING, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.RUNNING, recordings);

    bean.stopRecording(orgId);
    recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.STOPPED, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.RUNNING, recordings);

    SimpleEventHelper.createEvent(2);  // Should only be in clone

    bean.stopRecording(cloneId);
    recordings = bean.getRecordings();
    JmxHelper.verifyState(orgId, RecordingState.STOPPED, recordings);
    JmxHelper.verifyState(cloneId, RecordingState.STOPPED, recordings);

    Path orgPath = Paths.get(".", "org.jfr");
    Path clonePath = Paths.get(".", "clone.jfr");
    bean.copyTo(orgId, orgPath.toString());
    bean.copyTo(cloneId, clonePath.toString());

    verifyEvents(orgPath, 1);
    verifyEvents(clonePath, 1, 2);

    bean.closeRecording(orgId);
    bean.closeRecording(cloneId);
}