public class EventReceiver extends Object implements IEventReceivingService, IEventReportingService
Event
s from remote services. Start events
are maintained in a cache until their corresponding end event is received at
which point they are propagated to an EventReceiver.EventBTree
which is used for
reporting purposes.Modifier and Type | Class and Description |
---|---|
static class |
EventReceiver.EventBTree
|
Modifier and Type | Field and Description |
---|---|
protected LinkedHashMap<UUID,Event> |
eventCache
Basically a ring buffer of events without a capacity limit and with
random access by the event
UUID . |
protected long |
eventHistoryMillis
The maximum age of an
Event that will be keep "on the books". |
protected static org.apache.log4j.Logger |
log
Logs
Event s in a tab-delimited format @ INFO. |
protected UnisolatedReadWriteIndex |
ndx
The completed events are removed from the
eventCache and written
onto the #eventBTree . |
Constructor and Description |
---|
EventReceiver(long eventHistoryMillis,
EventReceiver.EventBTree eventBTree) |
Modifier and Type | Method and Description |
---|---|
Lock |
getWriteLock()
Return the write lock for the
EventReceiver.EventBTree . |
protected void |
logEvent(Event e)
Logs the completed event using a tab-delimited format @ INFO on
log . |
void |
notifyEvent(Event e)
Accepts the event, either updates the existing event with the same
UUID or adds the event to the set of recent events, and then
prunes the set of recent events so that all completed events older than
eventHistoryMillis are discarded. |
protected void |
pruneHistory(long now)
Any completed events which are older (LT) than the cutoff point (now -
eventHistoryMillis } are discarded. |
long |
rangeCount(long fromTime,
long toTime)
Reports the #of completed events that start in the given
interval.
|
Iterator<Event> |
rangeIterator(long fromTime,
long toTime)
Visits completed events that start in the given interval in order
by their start time.
|
protected static final transient org.apache.log4j.Logger log
Event
s in a tab-delimited format @ INFO.
Note: If you enable more detailed logging (DEBUG, etc). then that will get mixed up with your tab-delimited events log and you may have to filter it out before you can process the events log analytically.
protected final long eventHistoryMillis
Event
that will be keep "on the books".
Events older than this are purged.protected final LinkedHashMap<UUID,Event> eventCache
UUID
. New events are added to the
collection by notifyEvent(Event)
. That method also scans the
head of the collection, purging any events that are older than the
desired #of minutes of event history to retain.
Since this is a "linked" collection, the order of the events in the collection will always reflect their arrival time. This lets us scan the events in temporal order, filtering for desired criteria and makes it possible to prune the events in the buffer as new events arrive.
protected final UnisolatedReadWriteIndex ndx
eventCache
and written
onto the #eventBTree
. This is done in order to get the events
out of memory and onto disk and to decouple the
IEventReceivingService
from the IEventReportingService
.public EventReceiver(long eventHistoryMillis, EventReceiver.EventBTree eventBTree)
eventHistoryMillis
- The maximum age of an Event
that will be keep "on the
books". Events older than this are purged. An error is logged
if an event is purged before its end() event arrives. This
generally indicates a code path where Event.end()
is
not getting called but could also indicate a disconnected
client or service.eventStore
- A BTree
used to record the completed events and to
implement the IEventReportingService
interface.public Lock getWriteLock()
EventReceiver.EventBTree
.public void notifyEvent(Event e) throws IOException
UUID
or adds the event to the set of recent events, and then
prunes the set of recent events so that all completed events older than
eventHistoryMillis
are discarded.
An error is logged if an event is purged before its end() event arrives.
This generally indicates a code path where Event.end()
is not
getting called but could also indicate a disconnected client or service.
notifyEvent
in interface IEventReceivingService
IOException
protected void pruneHistory(long now)
eventHistoryMillis
} are discarded.protected void logEvent(Event e)
public long rangeCount(long fromTime, long toTime)
IEventReportingService
rangeCount
in interface IEventReportingService
fromTime
- The first start time to be included.toTime
- The first start time to be excluded.public Iterator<Event> rangeIterator(long fromTime, long toTime)
IEventReportingService
rangeIterator
in interface IEventReportingService
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.