Java Code Examples for jdk.jfr.EventType#getId()
The following examples show how to use
jdk.jfr.EventType#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: TestEventTypes.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void assertSame(List<EventTypeInfo> infos, List<EventType> types) { List<Long> ids = new ArrayList<>(); for (EventTypeInfo info : infos) { long id = info.getId(); Asserts.assertFalse(ids.contains(id), "EventTypeInfo.id not unique:" + id); ids.add(id); boolean isFound = false; for (EventType type : types) { if (type.getId() == id) { assertSame(info, type); isFound = true; break; } } if (!isFound) { String msg = "No EventType for EventTypeInfo"; System.out.println(msg + ": " + info); Asserts.fail(msg); } } Asserts.assertEquals(infos.size(), types.size(), "Number of EventTypeInfos != EventTypes"); }
Example 2
Source File: TestRegistered.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { try { EventType.getEventType(NotRegisteredByDefaultEvent.class); throw new Exception("Should not be able to get event type from unregistered event type"); } catch (IllegalStateException ise) { // as expected } EventType registered = EventType.getEventType(RegisteredByDefaultEvent.class); boolean registeredWorking = false; for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (registered.getId() == type.getId()) { registeredWorking = true; } } if (!registeredWorking) { Asserts.fail("Default regsitration is not working, can't validate @NoAutoRegistration"); } }
Example 3
Source File: TestEventTypes.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void assertSame(List<EventTypeInfo> infos, List<EventType> types) { List<Long> ids = new ArrayList<>(); for (EventTypeInfo info : infos) { long id = info.getId(); Asserts.assertFalse(ids.contains(id), "EventTypeInfo.id not unique:" + id); ids.add(id); boolean isFound = false; for (EventType type : types) { if (type.getId() == id) { assertSame(info, type); isFound = true; break; } } if (!isFound) { String msg = "No EventType for EventTypeInfo"; System.out.println(msg + ": " + info); Asserts.fail(msg); } } Asserts.assertEquals(infos.size(), types.size(), "Number of EventTypeInfos != EventTypes"); }
Example 4
Source File: MetadataRepository.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private EventHandler makeHandler(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) throws InternalError { SecuritySupport.addHandlerExport(eventClass); PlatformEventType pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields); EventType eventType = PrivateAccess.getInstance().newEventType(pEventType); EventControl ec = new EventControl(pEventType, eventClass); Class<? extends EventHandler> handlerClass = null; try { String eventHandlerName = EventHandlerCreator.makeEventHandlerName(eventType.getId()); handlerClass = Class.forName(eventHandlerName, false, Event.class.getClassLoader()).asSubclass(EventHandler.class); // Created eagerly on class load, tag as instrumented pEventType.setInstrumented(); Logger.log(JFR_SYSTEM, DEBUG, "Found existing event handler for " + eventType.getName()); } catch (ClassNotFoundException cne) { EventHandlerCreator ehc = new EventHandlerCreator(eventType.getId(), ec.getSettingInfos(), eventType, eventClass); handlerClass = ehc.makeEventHandlerClass(); Logger.log(LogTag.JFR_SYSTEM, DEBUG, "Created event handler for " + eventType.getName()); } EventHandler handler = EventHandlerCreator.instantiateEventHandler(handlerClass, true, eventType, ec); Utils.setHandler(eventClass, handler); return handler; }
Example 5
Source File: MetadataRepository.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private EventHandler makeHandler(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) throws InternalError { PlatformEventType pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields); EventType eventType = PrivateAccess.getInstance().newEventType(pEventType); EventControl ec = new EventControl(pEventType, eventClass); Class<? extends EventHandler> handlerClass = null; try { String eventHandlerName = EventHandlerCreator.makeEventHandlerName(eventType.getId()); handlerClass = Class.forName(eventHandlerName, false, Event.class.getClassLoader()).asSubclass(EventHandler.class); // Created eagerly on class load, tag as instrumented pEventType.setInstrumented(); Logger.log(JFR_SYSTEM, DEBUG, "Found existing event handler for " + eventType.getName()); } catch (ClassNotFoundException cne) { EventHandlerCreator ehc = new EventHandlerCreator(eventType.getId(), ec.getSettingInfos(), eventType, eventClass); handlerClass = ehc.makeEventHandlerClass(); Logger.log(LogTag.JFR_SYSTEM, DEBUG, "Created event handler for " + eventType.getName()); } EventHandler handler = EventHandlerCreator.instantiateEventHandler(handlerClass, true, eventType, ec); Utils.setHandler(eventClass, handler); return handler; }
Example 6
Source File: MetadataRepository.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private EventHandler makeHandler(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) throws InternalError { SecuritySupport.addHandlerExport(eventClass); PlatformEventType pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields); EventType eventType = PrivateAccess.getInstance().newEventType(pEventType); EventControl ec = new EventControl(pEventType, eventClass); Class<? extends EventHandler> handlerClass = null; try { String eventHandlerName = EventHandlerCreator.makeEventHandlerName(eventType.getId()); handlerClass = Class.forName(eventHandlerName, false, Event.class.getClassLoader()).asSubclass(EventHandler.class); // Created eagerly on class load, tag as instrumented pEventType.setInstrumented(); Logger.log(JFR_SYSTEM, DEBUG, "Found existing event handler for " + eventType.getName()); } catch (ClassNotFoundException cne) { EventHandlerCreator ehc = new EventHandlerCreator(eventType.getId(), ec.getSettingInfos(), eventType, eventClass); handlerClass = ehc.makeEventHandlerClass(); Logger.log(LogTag.JFR_SYSTEM, DEBUG, "Created event handler for " + eventType.getName()); } EventHandler handler = EventHandlerCreator.instantiateEventHandler(handlerClass, true, eventType, ec); Utils.setHandler(eventClass, handler); return handler; }
Example 7
Source File: TestRegistered.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { try { EventType.getEventType(NotRegisteredByDefaultEvent.class); throw new Exception("Should not be able to get event type from unregistered event type"); } catch (IllegalStateException ise) { // as expected } EventType registered = EventType.getEventType(RegisteredByDefaultEvent.class); boolean registeredWorking = false; for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (registered.getId() == type.getId()) { registeredWorking = true; } } if (!registeredWorking) { Asserts.fail("Default regsitration is not working, can't validate @NoAutoRegistration"); } }
Example 8
Source File: TestEventTypes.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void assertSame(List<EventTypeInfo> infos, List<EventType> types) { List<Long> ids = new ArrayList<>(); for (EventTypeInfo info : infos) { long id = info.getId(); Asserts.assertFalse(ids.contains(id), "EventTypeInfo.id not unique:" + id); ids.add(id); boolean isFound = false; for (EventType type : types) { if (type.getId() == id) { assertSame(info, type); isFound = true; break; } } if (!isFound) { String msg = "No EventType for EventTypeInfo"; System.out.println(msg + ": " + info); Asserts.fail(msg); } } Asserts.assertEquals(infos.size(), types.size(), "Number of EventTypeInfos != EventTypes"); }
Example 9
Source File: TestEventFactoryRegisterTwice.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void verifyRegistered(EventType eventType) { // Verify the event is registered boolean found = false; for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventType.getId() == type.getId()) { found = true; } } if(!found) { Asserts.fail("Event not registered"); } }
Example 10
Source File: TestActiveSettingEvent.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static boolean hasSetting(List<RecordedEvent> events, EventType evenType, String settingName, String settingValue) throws Exception { for (RecordedEvent e : events) { if (e.getEventType().getName().equals(ACTIVE_SETTING_EVENT_NAME)) { String name = e.getValue("name"); String value = e.getValue("value"); Long id = e.getValue("id"); if (evenType.getId() == id && name.equals(settingName) && settingValue.equals(value)) { return true; } } } return false; }
Example 11
Source File: TestEventFactoryRegistration.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void verifyRegistered(EventType eventType) { // Verify the event is registered boolean found = false; for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventType.getId() == type.getId()) { found = true; } } if(!found) { Asserts.fail("Event not registered"); } }
Example 12
Source File: TestEventFactoryRegistration.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void verifyRegistered(EventType eventType) { // Verify the event is registered boolean found = false; for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventType.getId() == type.getId()) { found = true; } } if(!found) { Asserts.fail("Event not registered"); } }
Example 13
Source File: TestEventFactoryRegistration.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void verifyUnregistered(EventType eventType) { // Verify the event is not registered for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventType.getId() == type.getId()) { Asserts.fail("Event is not unregistered"); } } }
Example 14
Source File: TestEventFactoryRegisterTwice.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void verifyRegistered(EventType eventType) { // Verify the event is registered boolean found = false; for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventType.getId() == type.getId()) { found = true; } } if(!found) { Asserts.fail("Event not registered"); } }
Example 15
Source File: TestEventFactoryRegistration.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void verifyUnregistered(EventType eventType) { // Verify the event is not registered for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventType.getId() == type.getId()) { Asserts.fail("Event is not unregistered"); } } }
Example 16
Source File: TestEventFactoryRegistration.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void verifyUnregistered(EventType eventType) { // Verify the event is not registered for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventType.getId() == type.getId()) { Asserts.fail("Event is not unregistered"); } } }
Example 17
Source File: TestEventFactoryRegisterTwice.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void verifyRegistered(EventType eventType) { // Verify the event is registered boolean found = false; for (EventType type : FlightRecorder.getFlightRecorder().getEventTypes()) { if (eventType.getId() == type.getId()) { found = true; } } if(!found) { Asserts.fail("Event not registered"); } }
Example 18
Source File: TestActiveSettingEvent.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static boolean hasSetting(List<RecordedEvent> events, EventType evenType, String settingName, String settingValue) throws Exception { for (RecordedEvent e : events) { if (e.getEventType().getName().equals(ACTIVE_SETTING_EVENT_NAME)) { String name = e.getValue("name"); String value = e.getValue("value"); Long id = e.getValue("id"); if (evenType.getId() == id && name.equals(settingName) && settingValue.equals(value)) { return true; } } } return false; }
Example 19
Source File: EventTypeInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 20
Source File: EventTypeInfo.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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(); }