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

The following examples show how to use jdk.jfr.Recording#getSettings() . 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: DCmdCheck.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void printSetttings(Recording recording) {
    Map<String, String> settings = recording.getSettings();
    for (EventType eventType : sortByEventPath(getFlightRecorder().getEventTypes())) {
        StringJoiner sj = new StringJoiner(",", "[", "]");
        sj.setEmptyValue("");
        for (SettingDescriptor s : eventType.getSettingDescriptors()) {
            String settingsPath = eventType.getName() + "#" + s.getName();
            if (settings.containsKey(settingsPath)) {
                sj.add(s.getName() + "=" + settings.get(settingsPath));
            }
        }
        String settingsText = sj.toString();
        if (!settingsText.isEmpty()) {
            print(" %s (%s)", eventType.getLabel(), eventType.getName());
            println();
            println("   " + settingsText);
        }
    }
}
 
Example 2
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 3
Source File: TestRecordingBase.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void testGetSettings() throws Throwable {
    String eventPath = "my/test/enabledPath";
    String settingName = "myTestSetting";
    String settingValue = "myTestValue";

    Recording r = new Recording();
    r.enable(eventPath).with(settingName, settingValue);

    boolean isEnabledPathFound = false;
    boolean isSettingFound = false;
    Map<String, String> settings = r.getSettings();
    for (String name : settings.keySet()) {
        System.out.println("name=" + name + ", value=" + settings.get(name));
        if (name.contains(eventPath) && name.contains("#enabled")) {
            isEnabledPathFound = true;
            assertEquals("true", settings.get(name), "Wrong value for enabled path: " + name);
        }
        if  (name.contains(eventPath) && name.contains(settingName)) {
            isSettingFound = true;
            assertEquals(settingValue, settings.get(name), "Wrong value for setting: " + name);
        }
    }
    assertTrue(isEnabledPathFound, "Enabled path not found in settings");
    assertTrue(isSettingFound, "Test setting not found in settings");
    r.close();
}
 
Example 4
Source File: DCmdCheck.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void printSetttings(Recording recording) {
    Map<String, String> settings = recording.getSettings();
    for (EventType eventType : sortByEventPath(getFlightRecorder().getEventTypes())) {
        StringJoiner sj = new StringJoiner(",", "[", "]");
        sj.setEmptyValue("");
        for (SettingDescriptor s : eventType.getSettingDescriptors()) {
            String settingsPath = eventType.getName() + "#" + s.getName();
            if (settings.containsKey(settingsPath)) {
                sj.add(s.getName() + "=" + settings.get(settingsPath));
            }
        }
        String settingsText = sj.toString();
        if (!settingsText.isEmpty()) {
            print(" %s (%s)", eventType.getLabel(), eventType.getName());
            println();
            println("   " + settingsText);
        }
    }
}
 
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: TestRecordingBase.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void testGetSettings() throws Throwable {
    String eventPath = "my/test/enabledPath";
    String settingName = "myTestSetting";
    String settingValue = "myTestValue";

    Recording r = new Recording();
    r.enable(eventPath).with(settingName, settingValue);

    boolean isEnabledPathFound = false;
    boolean isSettingFound = false;
    Map<String, String> settings = r.getSettings();
    for (String name : settings.keySet()) {
        System.out.println("name=" + name + ", value=" + settings.get(name));
        if (name.contains(eventPath) && name.contains("#enabled")) {
            isEnabledPathFound = true;
            assertEquals("true", settings.get(name), "Wrong value for enabled path: " + name);
        }
        if  (name.contains(eventPath) && name.contains(settingName)) {
            isSettingFound = true;
            assertEquals(settingValue, settings.get(name), "Wrong value for setting: " + name);
        }
    }
    assertTrue(isEnabledPathFound, "Enabled path not found in settings");
    assertTrue(isSettingFound, "Test setting not found in settings");
    r.close();
}
 
Example 7
Source File: DCmdCheck.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void printSetttings(Recording recording) {
    Map<String, String> settings = recording.getSettings();
    for (EventType eventType : sortByEventPath(getFlightRecorder().getEventTypes())) {
        StringJoiner sj = new StringJoiner(",", "[", "]");
        sj.setEmptyValue("");
        for (SettingDescriptor s : eventType.getSettingDescriptors()) {
            String settingsPath = eventType.getName() + "#" + s.getName();
            if (settings.containsKey(settingsPath)) {
                sj.add(s.getName() + "=" + settings.get(settingsPath));
            }
        }
        String settingsText = sj.toString();
        if (!settingsText.isEmpty()) {
            print(" %s (%s)", eventType.getLabel(), eventType.getName());
            println();
            println("   " + settingsText);
        }
    }
}
 
Example 8
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 9
Source File: TestRecordingBase.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void testGetSettings() throws Throwable {
    String eventPath = "my/test/enabledPath";
    String settingName = "myTestSetting";
    String settingValue = "myTestValue";

    Recording r = new Recording();
    r.enable(eventPath).with(settingName, settingValue);

    boolean isEnabledPathFound = false;
    boolean isSettingFound = false;
    Map<String, String> settings = r.getSettings();
    for (String name : settings.keySet()) {
        System.out.println("name=" + name + ", value=" + settings.get(name));
        if (name.contains(eventPath) && name.contains("#enabled")) {
            isEnabledPathFound = true;
            assertEquals("true", settings.get(name), "Wrong value for enabled path: " + name);
        }
        if  (name.contains(eventPath) && name.contains(settingName)) {
            isSettingFound = true;
            assertEquals(settingValue, settings.get(name), "Wrong value for setting: " + name);
        }
    }
    assertTrue(isEnabledPathFound, "Enabled path not found in settings");
    assertTrue(isSettingFound, "Test setting not found in settings");
    r.close();
}