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

The following examples show how to use jdk.jfr.Recording#getId() . 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: RecordingInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
RecordingInfo(Recording recording) {
    id = recording.getId();
    name = recording.getName();
    state = recording.getState().toString();
    dumpOnExit = recording.getDumpOnExit();
    size = recording.getSize();
    disk = recording.isToDisk();

    Duration d = recording.getMaxAge();
    if (d == null) {
        maxAge = 0;
    } else {
        maxAge = d.getSeconds();
    }
    maxSize = recording.getMaxSize();
    Instant s = recording.getStartTime();
    startTime = s == null ? 0L : s.toEpochMilli();
    Instant st = recording.getStopTime();
    stopTime = st == null ? 0L : st.toEpochMilli();
    Path p = recording.getDestination();
    destination = p == null ? null : p.toString();
    Duration duration = recording.getDuration();
    durationInSeconds = duration == null ? 0 : duration.getSeconds();
    settings = recording.getSettings();
}
 
Example 2
Source File: RecordingInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
RecordingInfo(Recording recording) {
    id = recording.getId();
    name = recording.getName();
    state = recording.getState().toString();
    dumpOnExit = recording.getDumpOnExit();
    size = recording.getSize();
    disk = recording.isToDisk();

    Duration d = recording.getMaxAge();
    if (d == null) {
        maxAge = 0;
    } else {
        maxAge = d.getSeconds();
    }
    maxSize = recording.getMaxSize();
    Instant s = recording.getStartTime();
    startTime = s == null ? 0L : s.toEpochMilli();
    Instant st = recording.getStopTime();
    stopTime = st == null ? 0L : st.toEpochMilli();
    Path p = recording.getDestination();
    destination = p == null ? null : p.toString();
    Duration duration = recording.getDuration();
    durationInSeconds = duration == null ? 0 : duration.getSeconds();
    settings = recording.getSettings();
}
 
Example 3
Source File: FlightRecorderMXBeanImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Notification createNotication(Recording recording) {
    try {
        Long id = recording.getId();
        Object oldValue = changes.get(recording.getId());
        Object newValue = getAttribute(ATTRIBUTE_RECORDINGS);
        if (recording.getState() != RecordingState.CLOSED) {
            changes.put(id, newValue);
        } else {
            changes.remove(id);
        }
        return new AttributeChangeNotification(getObjectName(), sequenceNumber.incrementAndGet(), System.currentTimeMillis(), "Recording " + recording.getName() + " is "
                + recording.getState(), ATTRIBUTE_RECORDINGS, newValue.getClass().getName(), oldValue, newValue);
    } catch (AttributeNotFoundException | MBeanException | ReflectionException e) {
        throw new RuntimeException("Could not create notifcation for FlightRecorderMXBean. " + e.getMessage(), e);
    }
}
 
Example 4
Source File: FlightRecorderMXBeanImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Notification createNotication(Recording recording) {
    try {
        Long id = recording.getId();
        Object oldValue = changes.get(recording.getId());
        Object newValue = getAttribute(ATTRIBUTE_RECORDINGS);
        if (recording.getState() != RecordingState.CLOSED) {
            changes.put(id, newValue);
        } else {
            changes.remove(id);
        }
        return new AttributeChangeNotification(getObjectName(), sequenceNumber.incrementAndGet(), System.currentTimeMillis(), "Recording " + recording.getName() + " is "
                + recording.getState(), ATTRIBUTE_RECORDINGS, newValue.getClass().getName(), oldValue, newValue);
    } catch (AttributeNotFoundException | MBeanException | ReflectionException e) {
        throw new RuntimeException("Could not create notifcation for FlightRecorderMXBean. " + e.getMessage(), e);
    }
}
 
Example 5
Source File: RecordingInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
RecordingInfo(Recording recording) {
    id = recording.getId();
    name = recording.getName();
    state = recording.getState().toString();
    dumpOnExit = recording.getDumpOnExit();
    size = recording.getSize();
    disk = recording.isToDisk();

    Duration d = recording.getMaxAge();
    if (d == null) {
        maxAge = 0;
    } else {
        maxAge = d.getSeconds();
    }
    maxSize = recording.getMaxSize();
    Instant s = recording.getStartTime();
    startTime = s == null ? 0L : s.toEpochMilli();
    Instant st = recording.getStopTime();
    stopTime = st == null ? 0L : st.toEpochMilli();
    Path p = recording.getDestination();
    destination = p == null ? null : p.toString();
    Duration duration = recording.getDuration();
    durationInSeconds = duration == null ? 0 : duration.getSeconds();
    settings = recording.getSettings();
}
 
Example 6
Source File: TestCopyToRunning.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static Recording getRecording(long recId) {
    for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            return r;
        }
    }
    Asserts.fail("Could not find recording with id " + recId);
    return null;
}
 
Example 7
Source File: AbstractDCmd.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private Recording findRecordingById(int id) throws DCmdException {
    for (Recording r : getFlightRecorder().getRecordings()) {
        if (r.getId() == id) {
            return r;
        }
    }
    throw new DCmdException("Could not find %d.\n\nUse JFR.check without options to see list of all available recordings.", id);
}
 
Example 8
Source File: JmxHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static Recording getJavaRecording(long recId) {
    for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            return r;
        }
    }
    Asserts.fail("No Recording with id " + recId);
    return null;
}
 
Example 9
Source File: AbstractDCmd.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private Recording findRecordingById(int id) throws DCmdException {
    for (Recording r : getFlightRecorder().getRecordings()) {
        if (r.getId() == id) {
            return r;
        }
    }
    throw new DCmdException("Could not find %d.\n\nUse JFR.check without options to see list of all available recordings.", id);
}
 
Example 10
Source File: CommonHelper.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static Recording verifyExists(long recId, List<Recording> recordings) {
    for (Recording r : recordings) {
        if (recId == r.getId()) {
            return r;
        }
    }
    Asserts.fail("Recording not found, id=" + recId);
    return null;
}
 
Example 11
Source File: TestRecordingSettings.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 {
    Map<String, String> settings = new HashMap<>();
    settings.put("java.exception_throw#enabled", "false");
    settings.put("java.exception_throw#threshold", "2 s");
    settings.put("java.exception_throw#thread", "true");
    settings.put("java.exception_throw#stackTrace", "false");
    settings.put("os.information#enabled", "true");
    settings.put("os.information#period", "400 ms");

    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();
    long recId = bean.newRecording();
    bean.setRecordingSettings(recId, settings);

    // Verify that JMX input and output settings are equal.
    JmxHelper.verifyMapEquals(settings, JmxHelper.getFlighteRecorderMXBean().getRecordingSettings(recId));

    // Verify that settings from Java API is correct.
    Recording recording = null;
    for (Recording r :  FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            recording = r;
            break;
        }
    }
    Asserts.assertNotNull(recording, "No Recording with id " + recId);
    JmxHelper.verifyMapEquals(settings, recording.getSettings());

    bean.startRecording(recId);
    bean.stopRecording(recId);
    bean.closeRecording(recId);
}
 
Example 12
Source File: TestCopyToRunning.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static Recording getRecording(long recId) {
    for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            return r;
        }
    }
    Asserts.fail("Could not find recording with id " + recId);
    return null;
}
 
Example 13
Source File: JmxHelper.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static Recording getJavaRecording(long recId) {
    for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            return r;
        }
    }
    Asserts.fail("No Recording with id " + recId);
    return null;
}
 
Example 14
Source File: AbstractDCmd.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private Recording findRecordingById(int id) throws DCmdException {
    for (Recording r : getFlightRecorder().getRecordings()) {
        if (r.getId() == id) {
            return r;
        }
    }
    throw new DCmdException("Could not find %d.\n\nUse JFR.check without options to see list of all available recordings.", id);
}
 
Example 15
Source File: CommonHelper.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static Recording verifyExists(long recId, List<Recording> recordings) {
    for (Recording r : recordings) {
        if (recId == r.getId()) {
            return r;
        }
    }
    Asserts.fail("Recording not found, id=" + recId);
    return null;
}
 
Example 16
Source File: JmxHelper.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static Recording getJavaRecording(long recId) {
    for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            return r;
        }
    }
    Asserts.fail("No Recording with id " + recId);
    return null;
}
 
Example 17
Source File: TestRecordingSettings.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 {
    Map<String, String> settings = new HashMap<>();
    settings.put("java.exception_throw#enabled", "false");
    settings.put("java.exception_throw#threshold", "2 s");
    settings.put("java.exception_throw#thread", "true");
    settings.put("java.exception_throw#stackTrace", "false");
    settings.put("os.information#enabled", "true");
    settings.put("os.information#period", "400 ms");

    FlightRecorderMXBean bean = JmxHelper.getFlighteRecorderMXBean();
    long recId = bean.newRecording();
    bean.setRecordingSettings(recId, settings);

    // Verify that JMX input and output settings are equal.
    JmxHelper.verifyMapEquals(settings, JmxHelper.getFlighteRecorderMXBean().getRecordingSettings(recId));

    // Verify that settings from Java API is correct.
    Recording recording = null;
    for (Recording r :  FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            recording = r;
            break;
        }
    }
    Asserts.assertNotNull(recording, "No Recording with id " + recId);
    JmxHelper.verifyMapEquals(settings, recording.getSettings());

    bean.startRecording(recId);
    bean.stopRecording(recId);
    bean.closeRecording(recId);
}
 
Example 18
Source File: TestCopyToRunning.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static Recording getRecording(long recId) {
    for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            return r;
        }
    }
    Asserts.fail("Could not find recording with id " + recId);
    return null;
}
 
Example 19
Source File: JmxHelper.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static Recording getJavaRecording(long recId) {
    for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
        if (r.getId() == recId) {
            return r;
        }
    }
    Asserts.fail("No Recording with id " + recId);
    return null;
}
 
Example 20
Source File: CommonHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static Recording verifyExists(long recId, List<Recording> recordings) {
    for (Recording r : recordings) {
        if (recId == r.getId()) {
            return r;
        }
    }
    Asserts.fail("Recording not found, id=" + recId);
    return null;
}