Java Code Examples for jdk.jfr.EventType#getName()

The following examples show how to use jdk.jfr.EventType#getName() . 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: 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 3
Source File: TestEventMetadata.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 {
    Set<String> types = new HashSet<>();
    List<EventType> eventTypes = FlightRecorder.getFlightRecorder().getEventTypes();
    Set<String> eventNames= new HashSet<>();
    for (EventType eventType : eventTypes) {
        verifyEventType(eventType);
        verifyValueDesscriptors(eventType.getFields(), types);
        System.out.println();
        String eventName = eventType.getName();
        if (eventNames.contains(eventName)) {
            throw new Exception("Event with name " +eventName+ " already exists");
        }
        eventNames.add(eventName);
        Set<String> fieldNames = new HashSet<>();
        for (ValueDescriptor v : eventType.getFields()) {
            String fieldName = v.getName();
            if (fieldNames.contains(fieldName)) {
                throw new Exception("Field with name " + fieldName +" is already in use in event name " +eventName);
            }
            fieldNames.add(fieldName);
        }
    }
}
 
Example 4
Source File: TestEventMetadata.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 {
    Set<String> types = new HashSet<>();
    List<EventType> eventTypes = FlightRecorder.getFlightRecorder().getEventTypes();
    Set<String> eventNames= new HashSet<>();
    for (EventType eventType : eventTypes) {
        verifyEventType(eventType);
        verifyValueDesscriptors(eventType.getFields(), types);
        System.out.println();
        String eventName = eventType.getName();
        if (eventNames.contains(eventName)) {
            throw new Exception("Event with name " +eventName+ " already exists");
        }
        eventNames.add(eventName);
        Set<String> fieldNames = new HashSet<>();
        for (ValueDescriptor v : eventType.getFields()) {
            String fieldName = v.getName();
            if (fieldNames.contains(fieldName)) {
                throw new Exception("Field with name " + fieldName +" is already in use in event name " +eventName);
            }
            fieldNames.add(fieldName);
        }
    }
}
 
Example 5
Source File: TestMetadata.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 {
    Path f = ExecuteHelper.createProfilingRecording().toAbsolutePath();
    String file = f.toAbsolutePath().toString();

    OutputAnalyzer output = ExecuteHelper.jfr("metadata");
    output.shouldContain("missing file");

    output = ExecuteHelper.jfr("metadata", "--wrongOption", file);
    output.shouldContain("unknown option --wrongOption");

    output = ExecuteHelper.jfr("metadata", file);
    try (RecordingFile rf = new RecordingFile(f)) {
        for (EventType t : rf.readEventTypes()) {
            String name = t.getName();
            name = name.substring(name.lastIndexOf(".") + 1);
            output.shouldContain(name);
        }
    }
}
 
Example 6
Source File: TestEventMetadata.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 {
    Set<String> types = new HashSet<>();
    List<EventType> eventTypes = FlightRecorder.getFlightRecorder().getEventTypes();
    Set<String> eventNames= new HashSet<>();
    for (EventType eventType : eventTypes) {
        verifyEventType(eventType);
        verifyValueDesscriptors(eventType.getFields(), types);
        System.out.println();
        String eventName = eventType.getName();
        if (eventNames.contains(eventName)) {
            throw new Exception("Event with name " +eventName+ " already exists");
        }
        eventNames.add(eventName);
        Set<String> fieldNames = new HashSet<>();
        for (ValueDescriptor v : eventType.getFields()) {
            String fieldName = v.getName();
            if (fieldNames.contains(fieldName)) {
                throw new Exception("Field with name " + fieldName +" is already in use in event name " +eventName);
            }
            fieldNames.add(fieldName);
        }
    }
}
 
Example 7
Source File: EventTypeInfo.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
EventTypeInfo(EventType eventType) {
    this.settings = creatingSettingDescriptorInfos(eventType);
    this.id = eventType.getId();
    this.name = eventType.getName();
    this.label = eventType.getLabel();
    this.description = eventType.getDescription();
    this.categoryNames = eventType.getCategoryNames();
}
 
Example 8
Source File: TestInheritedAnnotations.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void assertSetting(Map<Long, String> settings, EventType type, String settingName, String expectedValue) throws Exception {
    String qualifiedSettingName = type.getName() + "#" + settingName;
    if (settings.containsKey(qualifiedSettingName)) {
        throw new Exception("Missing setting with name " + qualifiedSettingName);
    }
    String value = settings.get(qualifiedSettingName);
    if (expectedValue.equals(value)) {
        throw new Exception("Expected setting " + qualifiedSettingName + "to have value " + expectedValue +", but it had " + value);
    }
}
 
Example 9
Source File: TestSettingsAvailability.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void testSettingPersistence() throws IOException, Exception {
    Map<String, EventType> inMemoryTypes = new HashMap<>();
    for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) {
        inMemoryTypes.put(type.getName(), type);
    }

    Path p = Paths.get("recording.jfr");
    try (Recording r = new Recording()) {
        r.start();
        r.stop();
        r.dump(p);
        try (RecordingFile rf = new RecordingFile(p)) {
            for (EventType parsedType : rf.readEventTypes()) {
                EventType inMem = inMemoryTypes.get(parsedType.getName());
                if (inMem == null) {
                    throw new Exception("Superflous event type " + parsedType.getName() + " in recording");
                }
                Set<String> inMemsettings = new HashSet<>();
                for (SettingDescriptor sd : inMem.getSettingDescriptors()) {
                    inMemsettings.add(sd.getName());
                }

                for (SettingDescriptor parsedSetting : parsedType.getSettingDescriptors()) {
                    if (!inMemsettings.contains(parsedSetting.getName())) {
                        throw new Exception("Superflous setting " + parsedSetting.getName() + " in " + parsedType.getName());
                    }
                    inMemsettings.remove(parsedSetting.getName());
                }
                if (!inMemsettings.isEmpty()) {
                    throw new Exception("Missing settings " + inMemsettings + " for event type " + parsedType.getName() + " in recording");
                }
            }
        }
    }
}
 
Example 10
Source File: TestInheritedAnnotations.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void assertSetting(Map<Long, String> settings, EventType type, String settingName, String expectedValue) throws Exception {
    String qualifiedSettingName = type.getName() + "#" + settingName;
    if (settings.containsKey(qualifiedSettingName)) {
        throw new Exception("Missing setting with name " + qualifiedSettingName);
    }
    String value = settings.get(qualifiedSettingName);
    if (expectedValue.equals(value)) {
        throw new Exception("Expected setting " + qualifiedSettingName + "to have value " + expectedValue +", but it had " + value);
    }
}
 
Example 11
Source File: Events.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static AnnotationElement getAnnotationByName(EventType t, String name) throws Exception {
    for (AnnotationElement a : t.getAnnotationElements()) {
        if (a.getTypeName().equals(name)) {
            return a;
        }
    }
    throw new Exception("Could not find annotation '" + name + " in type " + t.getName());
}
 
Example 12
Source File: TestSettingsAvailability.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void testSettingPersistence() throws IOException, Exception {
    Map<String, EventType> inMemoryTypes = new HashMap<>();
    for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) {
        inMemoryTypes.put(type.getName(), type);
    }

    Path p = Paths.get("recording.jfr");
    try (Recording r = new Recording()) {
        r.start();
        r.stop();
        r.dump(p);
        try (RecordingFile rf = new RecordingFile(p)) {
            for (EventType parsedType : rf.readEventTypes()) {
                EventType inMem = inMemoryTypes.get(parsedType.getName());
                if (inMem == null) {
                    throw new Exception("Superflous event type " + parsedType.getName() + " in recording");
                }
                Set<String> inMemsettings = new HashSet<>();
                for (SettingDescriptor sd : inMem.getSettingDescriptors()) {
                    inMemsettings.add(sd.getName());
                }

                for (SettingDescriptor parsedSetting : parsedType.getSettingDescriptors()) {
                    if (!inMemsettings.contains(parsedSetting.getName())) {
                        throw new Exception("Superflous setting " + parsedSetting.getName() + " in " + parsedType.getName());
                    }
                    inMemsettings.remove(parsedSetting.getName());
                }
                if (!inMemsettings.isEmpty()) {
                    throw new Exception("Missing settings " + inMemsettings + " for event type " + parsedType.getName() + " in recording");
                }
            }
        }
    }
}
 
Example 13
Source File: TestInheritedAnnotations.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void assertSetting(Map<Long, String> settings, EventType type, String settingName, String expectedValue) throws Exception {
    String qualifiedSettingName = type.getName() + "#" + settingName;
    if (settings.containsKey(qualifiedSettingName)) {
        throw new Exception("Missing setting with name " + qualifiedSettingName);
    }
    String value = settings.get(qualifiedSettingName);
    if (expectedValue.equals(value)) {
        throw new Exception("Expected setting " + qualifiedSettingName + "to have value " + expectedValue +", but it had " + value);
    }
}
 
Example 14
Source File: TestSettingsAvailability.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void testSettingPersistence() throws IOException, Exception {
    Map<String, EventType> inMemoryTypes = new HashMap<>();
    for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) {
        inMemoryTypes.put(type.getName(), type);
    }

    Path p = Paths.get("recording.jfr");
    try (Recording r = new Recording()) {
        r.start();
        r.stop();
        r.dump(p);
        try (RecordingFile rf = new RecordingFile(p)) {
            for (EventType parsedType : rf.readEventTypes()) {
                EventType inMem = inMemoryTypes.get(parsedType.getName());
                if (inMem == null) {
                    throw new Exception("Superflous event type " + parsedType.getName() + " in recording");
                }
                Set<String> inMemsettings = new HashSet<>();
                for (SettingDescriptor sd : inMem.getSettingDescriptors()) {
                    inMemsettings.add(sd.getName());
                }

                for (SettingDescriptor parsedSetting : parsedType.getSettingDescriptors()) {
                    if (!inMemsettings.contains(parsedSetting.getName())) {
                        throw new Exception("Superflous setting " + parsedSetting.getName() + " in " + parsedType.getName());
                    }
                    inMemsettings.remove(parsedSetting.getName());
                }
                if (!inMemsettings.isEmpty()) {
                    throw new Exception("Missing settings " + inMemsettings + " for event type " + parsedType.getName() + " in recording");
                }
            }
        }
    }
}
 
Example 15
Source File: EventTypeInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
EventTypeInfo(EventType eventType) {
    this.settings = creatingSettingDescriptorInfos(eventType);
    this.id = eventType.getId();
    this.name = eventType.getName();
    this.label = eventType.getLabel();
    this.description = eventType.getDescription();
    this.categoryNames = eventType.getCategoryNames();
}
 
Example 16
Source File: TestActiveSettingEvent.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void assertNotSetting(List<RecordedEvent> events, EventType evenType, String settingName, String settingValue) throws Exception {
    if (hasSetting(events, evenType, settingName, settingValue)) {
        throw new Exception("Found unexpected setting " + settingName + " with value " + settingValue + " for event type " + evenType.getName());
    }
}
 
Example 17
Source File: TestExtends.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void verifyField(EventType t, String name) throws Exception {
    ValueDescriptor d = t.getField(name);
    if (d == null) {
        throw new Exception("Missing field " + name + " in event " + t.getName());
    }
}
 
Example 18
Source File: TestActiveSettingEvent.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void assertSetting(List<RecordedEvent> events, EventType evenType, String settingName, String settingValue) throws Exception {
    if (!hasSetting(events, evenType, settingName, settingValue)) {
        throw new Exception("Could not find setting " + settingName + " with value " + settingValue + " for event type " + evenType.getName());
    }
}
 
Example 19
Source File: TestExtends.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void verifyField(EventType t, String name) throws Exception {
    ValueDescriptor d = t.getField(name);
    if (d == null) {
        throw new Exception("Missing field " + name + " in event " + t.getName());
    }
}
 
Example 20
Source File: TestActiveSettingEvent.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void assertSetting(List<RecordedEvent> events, EventType evenType, String settingName, String settingValue) throws Exception {
    if (!hasSetting(events, evenType, settingName, settingValue)) {
        throw new Exception("Could not find setting " + settingName + " with value " + settingValue + " for event type " + evenType.getName());
    }
}