Java Code Examples for jdk.jfr.Event#set()

The following examples show how to use jdk.jfr.Event#set() . 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: TestDynamicAnnotations.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void testEventFactoryExample() throws IOException {
     List<ValueDescriptor> fields = new ArrayList<>();
     List<AnnotationElement> messageAnnotations = Collections.singletonList(new AnnotationElement(Label.class, "Message"));
     fields.add(new ValueDescriptor(String.class, "message", messageAnnotations));
     List<AnnotationElement> numberAnnotations = Collections.singletonList(new AnnotationElement(Label.class, "Number"));
     fields.add(new ValueDescriptor(int.class, "number", numberAnnotations));

     String[] category = { "Example", "Getting Started" };
     List<AnnotationElement> eventAnnotations = new ArrayList<>();
     eventAnnotations.add(new AnnotationElement(Name.class, "com.example.HelloWorld"));
     eventAnnotations.add(new AnnotationElement(Label.class, "Hello World"));
     eventAnnotations.add(new AnnotationElement(Description.class, "Helps programmer getting started"));
     eventAnnotations.add(new AnnotationElement(Category.class, category));

     EventFactory f = EventFactory.create(eventAnnotations, fields);

     Event event = f.newEvent();
     event.set(0, "hello, world!");
     event.set(1, 4711);
     event.commit();
}
 
Example 2
Source File: TestDynamicAnnotations.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void testEventFactoryExample() throws IOException {
     List<ValueDescriptor> fields = new ArrayList<>();
     List<AnnotationElement> messageAnnotations = Collections.singletonList(new AnnotationElement(Label.class, "Message"));
     fields.add(new ValueDescriptor(String.class, "message", messageAnnotations));
     List<AnnotationElement> numberAnnotations = Collections.singletonList(new AnnotationElement(Label.class, "Number"));
     fields.add(new ValueDescriptor(int.class, "number", numberAnnotations));

     String[] category = { "Example", "Getting Started" };
     List<AnnotationElement> eventAnnotations = new ArrayList<>();
     eventAnnotations.add(new AnnotationElement(Name.class, "com.example.HelloWorld"));
     eventAnnotations.add(new AnnotationElement(Label.class, "Hello World"));
     eventAnnotations.add(new AnnotationElement(Description.class, "Helps programmer getting started"));
     eventAnnotations.add(new AnnotationElement(Category.class, category));

     EventFactory f = EventFactory.create(eventAnnotations, fields);

     Event event = f.newEvent();
     event.set(0, "hello, world!");
     event.set(1, 4711);
     event.commit();
}
 
Example 3
Source File: TestDynamicAnnotations.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void testEventFactoryExample() throws IOException {
     List<ValueDescriptor> fields = new ArrayList<>();
     List<AnnotationElement> messageAnnotations = Collections.singletonList(new AnnotationElement(Label.class, "Message"));
     fields.add(new ValueDescriptor(String.class, "message", messageAnnotations));
     List<AnnotationElement> numberAnnotations = Collections.singletonList(new AnnotationElement(Label.class, "Number"));
     fields.add(new ValueDescriptor(int.class, "number", numberAnnotations));

     String[] category = { "Example", "Getting Started" };
     List<AnnotationElement> eventAnnotations = new ArrayList<>();
     eventAnnotations.add(new AnnotationElement(Name.class, "com.example.HelloWorld"));
     eventAnnotations.add(new AnnotationElement(Label.class, "Hello World"));
     eventAnnotations.add(new AnnotationElement(Description.class, "Helps programmer getting started"));
     eventAnnotations.add(new AnnotationElement(Category.class, category));

     EventFactory f = EventFactory.create(eventAnnotations, fields);

     Event event = f.newEvent();
     event.set(0, "hello, world!");
     event.set(1, 4711);
     event.commit();
}
 
Example 4
Source File: TestDynamicAnnotations.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void testECID() throws Exception {
    List<ValueDescriptor> fields = new ArrayList<>();

    List<AnnotationElement> fieldAnnotations = new ArrayList<>();
    fieldAnnotations.add(new AnnotationElement(ECID.class));
    ValueDescriptor ecidField = new ValueDescriptor(String.class, "ecid", fieldAnnotations);
    fields.add(ecidField);

    EventFactory f = EventFactory.create(fieldAnnotations, fields);

    String ecidValue = "131739871298371279812";
    try (Recording r = new Recording()) {
        r.start();
        Event event = f.newEvent();
        event.set(0, ecidValue);
        event.commit();
        r.stop();
        List<RecordedEvent> events = Events.fromRecording(r);
        Events.hasEvents(events);
        Events.assertField(events.get(0), "ecid").equal(ecidValue);
    }
    EventType type = f.getEventType();
    ECID e = type.getAnnotation(ECID.class);
    if (e == null) {
        throw new Exception("Missing ECID annotation");
    }
}
 
Example 5
Source File: TestDynamicAnnotations.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void testECID() throws Exception {
    List<ValueDescriptor> fields = new ArrayList<>();

    List<AnnotationElement> fieldAnnotations = new ArrayList<>();
    fieldAnnotations.add(new AnnotationElement(ECID.class));
    ValueDescriptor ecidField = new ValueDescriptor(String.class, "ecid", fieldAnnotations);
    fields.add(ecidField);

    EventFactory f = EventFactory.create(fieldAnnotations, fields);

    String ecidValue = "131739871298371279812";
    try (Recording r = new Recording()) {
        r.start();
        Event event = f.newEvent();
        event.set(0, ecidValue);
        event.commit();
        r.stop();
        List<RecordedEvent> events = Events.fromRecording(r);
        Events.hasEvents(events);
        Events.assertField(events.get(0), "ecid").equal(ecidValue);
    }
    EventType type = f.getEventType();
    ECID e = type.getAnnotation(ECID.class);
    if (e == null) {
        throw new Exception("Missing ECID annotation");
    }
}
 
Example 6
Source File: TestDynamicAnnotations.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void testECID() throws Exception {
    List<ValueDescriptor> fields = new ArrayList<>();

    List<AnnotationElement> fieldAnnotations = new ArrayList<>();
    fieldAnnotations.add(new AnnotationElement(ECID.class));
    ValueDescriptor ecidField = new ValueDescriptor(String.class, "ecid", fieldAnnotations);
    fields.add(ecidField);

    EventFactory f = EventFactory.create(fieldAnnotations, fields);

    String ecidValue = "131739871298371279812";
    try (Recording r = new Recording()) {
        r.start();
        Event event = f.newEvent();
        event.set(0, ecidValue);
        event.commit();
        r.stop();
        List<RecordedEvent> events = Events.fromRecording(r);
        Events.hasEvents(events);
        Events.assertField(events.get(0), "ecid").equal(ecidValue);
    }
    EventType type = f.getEventType();
    ECID e = type.getAnnotation(ECID.class);
    if (e == null) {
        throw new Exception("Missing ECID annotation");
    }
}
 
Example 7
Source File: TestLargeJavaEvent64k.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype prototype, Map<String, Object> fields) {
    for (Map.Entry<String, Object> entry : fields.entrySet()) {
        int index = prototype.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}
 
Example 8
Source File: TestLargeJavaEvent512k.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype prototype, Map<String, Object> fields) {
    for (Map.Entry<String, Object> entry : fields.entrySet()) {
        int index = prototype.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}
 
Example 9
Source File: TestEventFactory.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype eventTypeProto) {
    for (Map.Entry<String, Object> entry : EVENT_VALUES.entrySet()) {
        int index = eventTypeProto.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}
 
Example 10
Source File: TestLargeJavaEvent64k.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype prototype, Map<String, Object> fields) {
    for (Map.Entry<String, Object> entry : fields.entrySet()) {
        int index = prototype.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}
 
Example 11
Source File: TestLargeJavaEvent512k.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype prototype, Map<String, Object> fields) {
    for (Map.Entry<String, Object> entry : fields.entrySet()) {
        int index = prototype.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}
 
Example 12
Source File: TestEventFactory.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype eventTypeProto) {
    for (Map.Entry<String, Object> entry : EVENT_VALUES.entrySet()) {
        int index = eventTypeProto.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}
 
Example 13
Source File: TestLargeJavaEvent64k.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype prototype, Map<String, Object> fields) {
    for (Map.Entry<String, Object> entry : fields.entrySet()) {
        int index = prototype.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}
 
Example 14
Source File: TestLargeJavaEvent512k.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype prototype, Map<String, Object> fields) {
    for (Map.Entry<String, Object> entry : fields.entrySet()) {
        int index = prototype.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}
 
Example 15
Source File: TestEventFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static void setEventValues(Event event, EventFactory f, EventTypePrototype eventTypeProto) {
    for (Map.Entry<String, Object> entry : EVENT_VALUES.entrySet()) {
        int index = eventTypeProto.getFieldIndex(entry.getKey());
        event.set(index, entry.getValue());
    }
}