jdk.jfr.SettingDescriptor Java Examples
The following examples show how to use
jdk.jfr.SettingDescriptor.
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: TestGetLabel.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertNull(plain.getLabel()); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(AnnotatedSetting.LABEL, annotatedType.getLabel()); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getLabel(), "Annotated Method"); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertNull(overridden.getLabel()); SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); Asserts.assertEquals(protectedBase.getLabel(), "Protected Base"); SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); Asserts.assertEquals(publicBase.getLabel(), AnnotatedSetting.LABEL); SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); Asserts.assertNull(packageProtectedBase.getLabel()); CustomEvent.assertOnDisk((x, y) -> Objects.equals(x.getLabel(), y.getLabel()) ? 0 : 1); }
Example #2
Source File: TestGetTypeName.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertEquals(plain.getTypeName(), PlainSetting.class.getName()); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(annotatedType.getTypeName(), AnnotatedSetting.NAME); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getTypeName(), AnnotatedSetting.NAME); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertEquals(overridden.getTypeName(), PlainSetting.class.getName()); SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); Asserts.assertEquals(protectedBase.getTypeName(), PlainSetting.class.getName()); SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); Asserts.assertEquals(publicBase.getTypeName(), AnnotatedSetting.NAME); SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); Asserts.assertEquals(packageProtectedBase.getTypeName(), PlainSetting.class.getName()); CustomEvent.assertOnDisk((x, y) -> x.getTypeName().compareTo(y.getTypeName())); }
Example #3
Source File: TestDefaultValue.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertEquals(plain.getDefaultValue(), "plain"); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(annotatedType.getDefaultValue(), AnnotatedSetting.DEFAULT_VALUE); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getDefaultValue(), AnnotatedSetting.DEFAULT_VALUE); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertEquals(overridden.getDefaultValue(), PlainSetting.DEFAULT_VALUE); CustomEvent.assertOnDisk((x, y) -> x.getName().compareTo(y.getName())); }
Example #4
Source File: TypeLibrary.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Iterates all reachable types from a start collection * * @param rootSet the types to start from * @param p if a type should be accepted * @param c action to take on an accepted type */ private static void visitReachable(Collection<Type> rootSet, Predicate<Type> p, Consumer<Type> c) { Queue<Type> typeQ = new ArrayDeque<>(rootSet); while (!typeQ.isEmpty()) { Type type = typeQ.poll(); if (p.test(type)) { c.accept(type); visitAnnotations(typeQ, type.getAnnotationElements()); for (ValueDescriptor v : type.getFields()) { typeQ.add(PrivateAccess.getInstance().getType(v)); visitAnnotations(typeQ, v.getAnnotationElements()); } if (type instanceof PlatformEventType) { PlatformEventType pe = (PlatformEventType) type; for (SettingDescriptor s : pe.getAllSettings()) { typeQ.add(PrivateAccess.getInstance().getType(s)); visitAnnotations(typeQ, s.getAnnotationElements()); } } } } }
Example #5
Source File: DCmdCheck.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 #6
Source File: TestGetAnnotation.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Label al = annotatedType.getAnnotation(Label.class); Asserts.assertNull(al); // we should not inherit annotation from type Description ad = annotatedType.getAnnotation(Description.class); Asserts.assertNull(ad); // we should not inherit annotation from type Timestamp at = annotatedType.getAnnotation(Timestamp.class); Asserts.assertNull(at); // we should not inherit annotation from type SettingDescriptor newName = Events.getSetting(type, "newName"); Label nl = newName.getAnnotation(Label.class); Asserts.assertEquals(nl.value(), "Annotated Method"); Description nd = newName.getAnnotation(Description.class); Asserts.assertEquals(nd.value(), "Description of an annotated method"); Timespan nt = newName.getAnnotation(Timespan.class); Asserts.assertEquals(nt.value(), Timespan.NANOSECONDS); }
Example #7
Source File: TestDefaultValue.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertEquals(plain.getDefaultValue(), "plain"); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(annotatedType.getDefaultValue(), AnnotatedSetting.DEFAULT_VALUE); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getDefaultValue(), AnnotatedSetting.DEFAULT_VALUE); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertEquals(overridden.getDefaultValue(), PlainSetting.DEFAULT_VALUE); CustomEvent.assertOnDisk((x, y) -> x.getName().compareTo(y.getName())); }
Example #8
Source File: TestSettingsAvailability.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void testSetting(String eventName, String... settingNames) throws Exception { for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventName.equals(type.getName())) { Set<String> settings = new HashSet<>(); for (SettingDescriptor sd : type.getSettingDescriptors()) { settings.add(sd.getName()); } for (String settingName : settingNames) { if (!settings.contains(settingName)) { throw new Exception("Missing setting " + settingName + " in " + eventName); } settings.remove(settingName); } if (!settings.isEmpty()) { throw new Exception("Superflous settings " + settings + " in event " + eventName); } } } }
Example #9
Source File: TestSettingsAvailability.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void testSetting(String eventName, String... settingNames) throws Exception { for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventName.equals(type.getName())) { Set<String> settings = new HashSet<>(); for (SettingDescriptor sd : type.getSettingDescriptors()) { settings.add(sd.getName()); } for (String settingName : settingNames) { if (!settings.contains(settingName)) { throw new Exception("Missing setting " + settingName + " in " + eventName); } settings.remove(settingName); } if (!settings.isEmpty()) { throw new Exception("Superflous settings " + settings + " in event " + eventName); } } } }
Example #10
Source File: TestGetDescription.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertNull(plain.getDescription()); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(annotatedType.getDescription(), AnnotatedSetting.DESCRIPTION); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getDescription(), CustomEvent.DESCRIPTION_OF_AN_ANNOTATED_METHOD); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertNull(overridden.getDescription()); SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); Asserts.assertEquals(protectedBase.getDescription(), "Description of protected base"); SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); Asserts.assertEquals(publicBase.getDescription(), AnnotatedSetting.DESCRIPTION); SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); Asserts.assertNull(packageProtectedBase.getDescription()); CustomEvent.assertOnDisk((x, y) -> Objects.equals(x.getDescription(), y.getDescription()) ? 0 : 1); }
Example #11
Source File: TestGetName.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); // subclass Events.getSetting(type, "plain"); Events.getSetting(type, "annotatedType"); Events.getSetting(type, "newName"); Events.getSetting(type, "overridden"); // base class Events.getSetting(type, "overridden"); Events.getSetting(type, "protectedBase"); Events.getSetting(type, "publicBase"); Events.getSetting(type, "packageProtectedBase"); int defaultNumberOfSettings = 3; // Enabled , Stack Trace, Threshold if (type.getSettingDescriptors().size() != 8 + defaultNumberOfSettings) { for (SettingDescriptor s : type.getSettingDescriptors()) { System.out.println(s.getName()); } throw new Exception("Wrong number of settings"); } CustomEvent.assertOnDisk((x, y) -> x.getName().compareTo(y.getName())); }
Example #12
Source File: DCmdCheck.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 #13
Source File: TestLabel.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // Event EventType t = EventType.getEventType(LabelEvent.class); Asserts.assertEquals(t.getLabel(), "Event Label", "Incorrect label for event"); // Field ValueDescriptor field = t.getField("labledField"); Asserts.assertEquals(field.getLabel(), "Field Label", "Incorrect label for field"); // Annotation AnnotationElement awl = Events.getAnnotationByName(t, AnnotionWithLabel.class.getName()); Label label = awl.getAnnotation(Label.class); Asserts.assertEquals(label.value(), "Annotation Label", "Incorrect label for annotation"); // Setting for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Label settingLabel = v.getAnnotation(Label.class); Asserts.assertEquals(settingLabel.value(), "Setting Label", "Incorrect label for setting"); } } }
Example #14
Source File: TestDescription.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType t = EventType.getEventType(DescriptionEvent.class); // field description AnnotationElement aMax = Events.getAnnotation(t.getField("field"), Description.class); String d = (String) aMax.getValue("value"); Asserts.assertEquals("Field Annotation", d, "Incorrect annotation for field, got '" + d + "'"); // event description d = t.getAnnotation(Description.class).value(); Asserts.assertEquals("Event Annotation", d, "Incorrect annotation for event, got '" + d + "'"); // annotation description AnnotationElement a = Events.getAnnotationByName(t, AnnotationWithDescription.class.getName()); Description de = a.getAnnotation(Description.class); Asserts.assertEquals("Meta Annotation", de.value(), "Incorrect annotation for event, got '" + de.value() + "'"); for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Description settingDescription = v.getAnnotation(Description.class); Asserts.assertEquals(settingDescription.value(), "Setting description", "Incorrect description for setting"); } } }
Example #15
Source File: CustomEvent.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void assertOnDisk(Comparator<SettingDescriptor> c) throws Exception { EventType in = EventType.getEventType(CustomEvent.class); Path p = Paths.get("custom.jfr"); try (Recording r = new Recording()) { r.start(); r.stop(); r.dump(p); } try (RecordingFile f = new RecordingFile(p)) { for (EventType out : f.readEventTypes()) { if (out.getName().equals(CustomEvent.class.getName())) { if (out.getSettingDescriptors().size() != in.getSettingDescriptors().size()) { throw new Exception("Number of settings doesn't match"); } for (SettingDescriptor os : out.getSettingDescriptors()) { SettingDescriptor is = Events.getSetting(in, os.getName()); if (c.compare(os, is) != 0) { throw new Exception("Setting with name " + is.getName() + " doesn't match"); } } return; } } } throw new Exception("Could not event type with name " + CustomEvent.class.getName()); }
Example #16
Source File: TestName.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType t = EventType.getEventType(NamedEvent.class); ValueDescriptor testField = t.getField("testField"); SettingDescriptor setting = getSetting(t, "name"); AnnotationElement a = Events.getAnnotationByName(t, "com.oracle.TestAnnotation"); // Check that names are overridden Asserts.assertNotNull(testField, "Can't find expected field testField"); Asserts.assertEquals(t.getName(), "com.oracle.TestEvent", "Incorrect name for event"); Asserts.assertEquals(a.getTypeName(), "com.oracle.TestAnnotation", "Incorrect name for annotation"); Asserts.assertEquals(a.getTypeName(), "com.oracle.TestAnnotation", "Incorrect name for annotation"); Asserts.assertEquals(setting.getName(), "name", "Incorrect name for setting"); // Check that @Name is persisted assertAnnotation(t.getAnnotation(Name.class), "@Name should be persisted on event"); assertAnnotation(testField.getAnnotation(Name.class), "@Name should be persisted on field"); assertAnnotation(a.getAnnotation(Name.class), "@Name should be persisted on annotations"); assertAnnotation(setting.getAnnotation(Name.class), "@Name should be persisted on setting"); }
Example #17
Source File: TestDescription.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType t = EventType.getEventType(DescriptionEvent.class); // field description AnnotationElement aMax = Events.getAnnotation(t.getField("field"), Description.class); String d = (String) aMax.getValue("value"); Asserts.assertEquals("Field Annotation", d, "Incorrect annotation for field, got '" + d + "'"); // event description d = t.getAnnotation(Description.class).value(); Asserts.assertEquals("Event Annotation", d, "Incorrect annotation for event, got '" + d + "'"); // annotation description AnnotationElement a = Events.getAnnotationByName(t, AnnotationWithDescription.class.getName()); Description de = a.getAnnotation(Description.class); Asserts.assertEquals("Meta Annotation", de.value(), "Incorrect annotation for event, got '" + de.value() + "'"); for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Description settingDescription = v.getAnnotation(Description.class); Asserts.assertEquals(settingDescription.value(), "Setting description", "Incorrect description for setting"); } } }
Example #18
Source File: TestGetDescription.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertNull(plain.getDescription()); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(annotatedType.getDescription(), AnnotatedSetting.DESCRIPTION); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getDescription(), CustomEvent.DESCRIPTION_OF_AN_ANNOTATED_METHOD); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertNull(overridden.getDescription()); SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); Asserts.assertEquals(protectedBase.getDescription(), "Description of protected base"); SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); Asserts.assertEquals(publicBase.getDescription(), AnnotatedSetting.DESCRIPTION); SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); Asserts.assertNull(packageProtectedBase.getDescription()); CustomEvent.assertOnDisk((x, y) -> Objects.equals(x.getDescription(), y.getDescription()) ? 0 : 1); }
Example #19
Source File: TypeLibrary.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Iterates all reachable types from a start collection * * @param rootSet the types to start from * @param p if a type should be accepted * @param c action to take on an accepted type */ private static void visitReachable(Collection<Type> rootSet, Predicate<Type> p, Consumer<Type> c) { Queue<Type> typeQ = new ArrayDeque<>(rootSet); while (!typeQ.isEmpty()) { Type type = typeQ.poll(); if (p.test(type)) { c.accept(type); visitAnnotations(typeQ, type.getAnnotationElements()); for (ValueDescriptor v : type.getFields()) { typeQ.add(PrivateAccess.getInstance().getType(v)); visitAnnotations(typeQ, v.getAnnotationElements()); } if (type instanceof PlatformEventType) { PlatformEventType pe = (PlatformEventType) type; for (SettingDescriptor s : pe.getAllSettings()) { typeQ.add(PrivateAccess.getInstance().getType(s)); visitAnnotations(typeQ, s.getAnnotationElements()); } } } } }
Example #20
Source File: DCmdCheck.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 #21
Source File: TestGetName.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); // subclass Events.getSetting(type, "plain"); Events.getSetting(type, "annotatedType"); Events.getSetting(type, "newName"); Events.getSetting(type, "overridden"); // base class Events.getSetting(type, "overridden"); Events.getSetting(type, "protectedBase"); Events.getSetting(type, "publicBase"); Events.getSetting(type, "packageProtectedBase"); int defaultNumberOfSettings = 3; // Enabled , Stack Trace, Threshold if (type.getSettingDescriptors().size() != 8 + defaultNumberOfSettings) { for (SettingDescriptor s : type.getSettingDescriptors()) { System.out.println(s.getName()); } throw new Exception("Wrong number of settings"); } CustomEvent.assertOnDisk((x, y) -> x.getName().compareTo(y.getName())); }
Example #22
Source File: TestGetName.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); // subclass Events.getSetting(type, "plain"); Events.getSetting(type, "annotatedType"); Events.getSetting(type, "newName"); Events.getSetting(type, "overridden"); // base class Events.getSetting(type, "overridden"); Events.getSetting(type, "protectedBase"); Events.getSetting(type, "publicBase"); Events.getSetting(type, "packageProtectedBase"); int defaultNumberOfSettings = 3; // Enabled , Stack Trace, Threshold if (type.getSettingDescriptors().size() != 8 + defaultNumberOfSettings) { for (SettingDescriptor s : type.getSettingDescriptors()) { System.out.println(s.getName()); } throw new Exception("Wrong number of settings"); } CustomEvent.assertOnDisk((x, y) -> x.getName().compareTo(y.getName())); }
Example #23
Source File: TestLabel.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // Event EventType t = EventType.getEventType(LabelEvent.class); Asserts.assertEquals(t.getLabel(), "Event Label", "Incorrect label for event"); // Field ValueDescriptor field = t.getField("labledField"); Asserts.assertEquals(field.getLabel(), "Field Label", "Incorrect label for field"); // Annotation AnnotationElement awl = Events.getAnnotationByName(t, AnnotionWithLabel.class.getName()); Label label = awl.getAnnotation(Label.class); Asserts.assertEquals(label.value(), "Annotation Label", "Incorrect label for annotation"); // Setting for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Label settingLabel = v.getAnnotation(Label.class); Asserts.assertEquals(settingLabel.value(), "Setting Label", "Incorrect label for setting"); } } }
Example #24
Source File: TestSettingsAvailability.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void testSetting(String eventName, String... settingNames) throws Exception { for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventName.equals(type.getName())) { Set<String> settings = new HashSet<>(); for (SettingDescriptor sd : type.getSettingDescriptors()) { settings.add(sd.getName()); } for (String settingName : settingNames) { if (!settings.contains(settingName)) { throw new Exception("Missing setting " + settingName + " in " + eventName); } settings.remove(settingName); } if (!settings.isEmpty()) { throw new Exception("Superflous settings " + settings + " in event " + eventName); } } } }
Example #25
Source File: TestDefaultValue.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertEquals(plain.getDefaultValue(), "plain"); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(annotatedType.getDefaultValue(), AnnotatedSetting.DEFAULT_VALUE); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getDefaultValue(), AnnotatedSetting.DEFAULT_VALUE); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertEquals(overridden.getDefaultValue(), PlainSetting.DEFAULT_VALUE); CustomEvent.assertOnDisk((x, y) -> x.getName().compareTo(y.getName())); }
Example #26
Source File: TestGetAnnotation.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Label al = annotatedType.getAnnotation(Label.class); Asserts.assertNull(al); // we should not inherit annotation from type Description ad = annotatedType.getAnnotation(Description.class); Asserts.assertNull(ad); // we should not inherit annotation from type Timestamp at = annotatedType.getAnnotation(Timestamp.class); Asserts.assertNull(at); // we should not inherit annotation from type SettingDescriptor newName = Events.getSetting(type, "newName"); Label nl = newName.getAnnotation(Label.class); Asserts.assertEquals(nl.value(), "Annotated Method"); Description nd = newName.getAnnotation(Description.class); Asserts.assertEquals(nd.value(), "Description of an annotated method"); Timespan nt = newName.getAnnotation(Timespan.class); Asserts.assertEquals(nt.value(), Timespan.NANOSECONDS); }
Example #27
Source File: TestGetContentType.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertNull(plain.getContentType()); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertNull(annotatedType.getContentType(), Timestamp.class.getName()); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getContentType(), Timespan.class.getName()); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertNull(overridden.getContentType()); SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); Asserts.assertEquals(protectedBase.getContentType(), Frequency.class); SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); Asserts.assertEquals(publicBase.getContentType(), Timestamp.class.getName()); SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); Asserts.assertNull(packageProtectedBase.getContentType()); CustomEvent.assertOnDisk((x, y) -> Objects.equals(x.getContentType(), y.getContentType()) ? 0 : 1); }
Example #28
Source File: CustomEvent.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void assertOnDisk(Comparator<SettingDescriptor> c) throws Exception { EventType in = EventType.getEventType(CustomEvent.class); Path p = Paths.get("custom.jfr"); try (Recording r = new Recording()) { r.start(); r.stop(); r.dump(p); } try (RecordingFile f = new RecordingFile(p)) { for (EventType out : f.readEventTypes()) { if (out.getName().equals(CustomEvent.class.getName())) { if (out.getSettingDescriptors().size() != in.getSettingDescriptors().size()) { throw new Exception("Number of settings doesn't match"); } for (SettingDescriptor os : out.getSettingDescriptors()) { SettingDescriptor is = Events.getSetting(in, os.getName()); if (c.compare(os, is) != 0) { throw new Exception("Setting with name " + is.getName() + " doesn't match"); } } return; } } } throw new Exception("Could not event type with name " + CustomEvent.class.getName()); }
Example #29
Source File: TestGetTypeName.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertEquals(plain.getTypeName(), PlainSetting.class.getName()); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(annotatedType.getTypeName(), AnnotatedSetting.NAME); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getTypeName(), AnnotatedSetting.NAME); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertEquals(overridden.getTypeName(), PlainSetting.class.getName()); SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); Asserts.assertEquals(protectedBase.getTypeName(), PlainSetting.class.getName()); SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); Asserts.assertEquals(publicBase.getTypeName(), AnnotatedSetting.NAME); SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); Asserts.assertEquals(packageProtectedBase.getTypeName(), PlainSetting.class.getName()); CustomEvent.assertOnDisk((x, y) -> x.getTypeName().compareTo(y.getTypeName())); }
Example #30
Source File: TestGetLabel.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor plain = Events.getSetting(type, "plain"); Asserts.assertNull(plain.getLabel()); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Asserts.assertEquals(AnnotatedSetting.LABEL, annotatedType.getLabel()); SettingDescriptor newName = Events.getSetting(type, "newName"); Asserts.assertEquals(newName.getLabel(), "Annotated Method"); SettingDescriptor overridden = Events.getSetting(type, "overridden"); Asserts.assertNull(overridden.getLabel()); SettingDescriptor protectedBase = Events.getSetting(type, "protectedBase"); Asserts.assertEquals(protectedBase.getLabel(), "Protected Base"); SettingDescriptor publicBase = Events.getSetting(type, "publicBase"); Asserts.assertEquals(publicBase.getLabel(), AnnotatedSetting.LABEL); SettingDescriptor packageProtectedBase = Events.getSetting(type, "packageProtectedBase"); Asserts.assertNull(packageProtectedBase.getLabel()); CustomEvent.assertOnDisk((x, y) -> Objects.equals(x.getLabel(), y.getLabel()) ? 0 : 1); }