Class ListenerTracker
- java.lang.Object
-
- org.apache.jackrabbit.commons.observation.ListenerTracker
-
public class ListenerTracker extends Object
Tracks event deliveries to an event listener and the way the listener processes the events. The collected information is made available through theEventListenerMBean
interface.
-
-
Field Summary
Fields Modifier and Type Field Description protected Exception
initStackTrace
-
Constructor Summary
Constructors Constructor Description ListenerTracker(EventListener listener, int eventTypes, String absPath, boolean isDeep, String[] uuid, String[] nodeTypeName, boolean noLocal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
afterEventDelivery()
Called just after theEventListener.onEvent(EventIterator)
method has been called (even if the call threw an exception).protected void
beforeEventDelivery()
Called just before theEventListener.onEvent(EventIterator)
method is called.EventListenerMBean
getListenerMBean()
EventListener
getTrackedListener()
void
recordOneSecond()
Records the number of measured values over the past second and resets the counter.void
recordProducerTime(long time, TimeUnit unit)
Record additional producer time spent outside of the listeners, e.g.void
recordQueueLength(long length)
Applications should call this to report the current queue length.void
recordQueueLength(long length, long headTimestamp)
Applications should call this to report the current queue length when an item is removed from the queue.String
toString()
protected void
warn(String message)
Called to log a deprecation warning about the detected behavior of the decorated listener.
-
-
-
Field Detail
-
initStackTrace
protected final Exception initStackTrace
-
-
Constructor Detail
-
ListenerTracker
public ListenerTracker(EventListener listener, int eventTypes, String absPath, boolean isDeep, String[] uuid, String[] nodeTypeName, boolean noLocal)
-
-
Method Detail
-
warn
protected void warn(String message)
Called to log a deprecation warning about the detected behavior of the decorated listener. Subclasses should override this method that by default does nothing.- Parameters:
message
- warning message
-
beforeEventDelivery
protected void beforeEventDelivery()
Called just before theEventListener.onEvent(EventIterator)
method is called. The default implementation of this method does nothing, but subclasses can override it to add custom processing.
-
afterEventDelivery
protected void afterEventDelivery()
Called just after theEventListener.onEvent(EventIterator)
method has been called (even if the call threw an exception). The default implementation of this method does nothing, but subclasses can override it to add custom processing.
-
recordQueueLength
public void recordQueueLength(long length)
Applications should call this to report the current queue length.- Parameters:
length
-
-
recordQueueLength
public void recordQueueLength(long length, long headTimestamp)
Applications should call this to report the current queue length when an item is removed from the queue.- Parameters:
length
- the length of the queue after the item was removed.headTimestamp
- the time in milliseconds when the head item was created and put into the queue.
-
recordOneSecond
public void recordOneSecond()
Records the number of measured values over the past second and resets the counter. This method should be scheduled to be called once per second.
-
recordProducerTime
public void recordProducerTime(long time, TimeUnit unit)
Record additional producer time spent outside of the listeners, e.g. beforeonEvent()
is called.- Parameters:
time
- the amount of time.unit
- the time unit.
-
getTrackedListener
public EventListener getTrackedListener()
-
getListenerMBean
public EventListenerMBean getListenerMBean()
-
-