Package org.apache.cassandra.diag
Class DiagnosticEventService
java.lang.Object
org.apache.cassandra.diag.DiagnosticEventService
- All Implemented Interfaces:
DiagnosticEventServiceMBean
Service for publishing and consuming
DiagnosticEvents.-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Removes all active subscribers.voidKill switch for disabling all events immediately, without restarting the node.voiddisableEventPersistence(String eventClazz) Stop storing events.voidenableEventPersistence(String eventClazz) Start storing events to make them available viaDiagnosticEventServiceMBean.readEvents(String, Long, int).<E extends DiagnosticEvent>
booleanhasSubscribers(Class<E> event) Indicates if anyConsumerhas been registered for the specified class of events.<E extends DiagnosticEvent,T extends Enum<T>>
booleanhasSubscribers(Class<E> event, T eventType) Indicates if anyConsumerhas been registered for the specified class of events.static DiagnosticEventServiceinstance()boolean<E extends DiagnosticEvent>
booleanIndicates if events are enabled for specified event class based onDatabaseDescriptor.diagnosticEventsEnabled()andhasSubscribers(Class).<E extends DiagnosticEvent,T extends Enum<T>>
booleanIndicates if events are enabled for specified event class based onDatabaseDescriptor.diagnosticEventsEnabled()andhasSubscribers(Class, Enum).voidpublish(DiagnosticEvent event) Makes provided event available to all subscribers.readEvents(String eventClazz, Long lastKey, int limit) Retrieved all events of specified type starting with provided key.<E extends DiagnosticEvent>
voidRegisters event handler for specified class of events.<E extends DiagnosticEvent,T extends Enum<T>>
voidRegisters event handler for specified class of events.voidsubscribeAll(Consumer<DiagnosticEvent> consumer) Registers event handler for all DiagnosticEvents published from this point.<E extends DiagnosticEvent>
voidunsubscribe(Class<E> event, Consumer<E> consumer) De-registers event handler from receiving any further events.<E extends DiagnosticEvent>
voidunsubscribe(Consumer<E> consumer) De-registers event handler from receiving any further events.
-
Method Details
-
publish
Makes provided event available to all subscribers. -
subscribe
Registers event handler for specified class of events.- Parameters:
event- DiagnosticEvent class implementationconsumer- Consumer for received events
-
subscribe
public <E extends DiagnosticEvent,T extends Enum<T>> void subscribe(Class<E> event, T eventType, Consumer<E> consumer) Registers event handler for specified class of events.- Parameters:
event- DiagnosticEvent class implementationconsumer- Consumer for received events
-
subscribeAll
Registers event handler for all DiagnosticEvents published from this point.- Parameters:
consumer- Consumer for received events
-
unsubscribe
De-registers event handler from receiving any further events.- Parameters:
consumer- Consumer registered for receiving events
-
unsubscribe
De-registers event handler from receiving any further events.- Parameters:
event- DiagnosticEvent class to unsubscribe fromconsumer- Consumer registered for receiving events
-
hasSubscribers
Indicates if anyConsumerhas been registered for the specified class of events.- Parameters:
event- DiagnosticEvent class implementation
-
hasSubscribers
public <E extends DiagnosticEvent,T extends Enum<T>> boolean hasSubscribers(Class<E> event, T eventType) Indicates if anyConsumerhas been registered for the specified class of events.- Parameters:
event- DiagnosticEvent class implementationeventType- Subscribed event type matched againstDiagnosticEvent.getType()
-
isEnabled
Indicates if events are enabled for specified event class based onDatabaseDescriptor.diagnosticEventsEnabled()andhasSubscribers(Class).- Parameters:
event- DiagnosticEvent class implementation
-
isEnabled
public <E extends DiagnosticEvent,T extends Enum<T>> boolean isEnabled(Class<E> event, T eventType) Indicates if events are enabled for specified event class based onDatabaseDescriptor.diagnosticEventsEnabled()andhasSubscribers(Class, Enum).- Parameters:
event- DiagnosticEvent class implementationeventType- Subscribed event type matched againstDiagnosticEvent.getType()
-
instance
-
cleanup
public void cleanup()Removes all active subscribers. Should only be called from testing. -
isDiagnosticsEnabled
public boolean isDiagnosticsEnabled()- Specified by:
isDiagnosticsEnabledin interfaceDiagnosticEventServiceMBean
-
disableDiagnostics
public void disableDiagnostics()Description copied from interface:DiagnosticEventServiceMBeanKill switch for disabling all events immediately, without restarting the node. Please edit cassandra.yaml for making this permanent.- Specified by:
disableDiagnosticsin interfaceDiagnosticEventServiceMBean
-
readEvents
public SortedMap<Long,Map<String, readEventsSerializable>> (String eventClazz, Long lastKey, int limit) Description copied from interface:DiagnosticEventServiceMBeanRetrieved all events of specified type starting with provided key. Result will be sorted chronologically.- Specified by:
readEventsin interfaceDiagnosticEventServiceMBean- Parameters:
eventClazz- fqn of event classlastKey- ID of first event to retrievelimit- number of results to return
-
enableEventPersistence
Description copied from interface:DiagnosticEventServiceMBeanStart storing events to make them available viaDiagnosticEventServiceMBean.readEvents(String, Long, int).- Specified by:
enableEventPersistencein interfaceDiagnosticEventServiceMBean
-
disableEventPersistence
Description copied from interface:DiagnosticEventServiceMBeanStop storing events.- Specified by:
disableEventPersistencein interfaceDiagnosticEventServiceMBean
-