com.bigdata.service
Class Event

java.lang.Object
  extended by com.bigdata.service.Event
All Implemented Interfaces:
Serializable

public class Event
extends Object
implements Serializable

An event. Events are queued by the IBigdataClient and self-reported periodically to the ILoadBalancerService. The event is assigned a UUID when it is created and the ILoadBalancerService assigned start and end event times based on its local clock as the events are received (this helps to reduce the demand on the ITransactionService for global timestamp).

Version:
$Id: Event.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form
TODO:
compact event serialization when reporting to the ILoadBalancerService, including factoring out of the common metadata (some stuff will always be the same for a given reported and does not need to be reported with each event)., Add a level property to events? (but events are not meant to replace logging)

Field Summary
protected  boolean complete
          true iff the event event has been generated.
protected  Map<String,Object> details
          Event details.
protected  long endTime
          The event end time.
 UUID eventUUID
          Unique event identifier.
protected  IBigdataFederation fed
           
 String hostname
          The host on which the event was generated.
protected static org.apache.log4j.Logger log
           
 Object majorEventType
          Major event type (classification or category).
 Object minorEventType
          Minor event type (classification or category).
protected  long receiptTime
          The time when the event was received.
 EventResource resource
          The resource for which the event is reported (store file, index name, etc).
 Class serviceIface
          The most interesting class or interface for the service which generated that event.
 String serviceName
          The name of the service which generated the event.
 UUID serviceUUID
          The UUID for the service which generated that event.
protected  long startTime
          The event start time.
 
Constructor Summary
  Event(IBigdataFederation fed, EventResource resource, Object majorEventType)
           
  Event(IBigdataFederation fed, EventResource resource, Object majorEventType, Map<String,Object> details)
          Event ctor.
protected Event(IBigdataFederation fed, EventResource resource, Object majorEventType, Object minorEventType, Map<String,Object> details)
          Sub-event ctor.
protected Event(String s)
          Construct an event from the tab-delimited serialization produced from toString().
 
Method Summary
 Event addDetail(String name, Object value)
          Add a detail.
 Event addDetails(Map<String,Object> details)
          Add details.
 Event end()
          Sends the end event.
static Event fromString(String s)
          Reconstruct an event object from a string.
 Map<String,Object> getDetails()
          Event details.
 long getElapsed()
          The elapsed time for the event.
 long getEndTime()
           
static String getHeader()
          A header that can be used to interpret the output of toString() (with newline).
 long getStartTime()
           
 boolean isComplete()
          true iff the event event has been generated.
protected static Map<String,Object> newDetails()
          Factory for the details hash map.
 Event newSubEvent(Object minorEventType)
          A child event (major type is the type of the parent).
 Event newSubEvent(Object minorEventType, Map<String,Object> details)
          A child event (major type is the type of the parent).
protected  void sendEvent()
          Dispatch the Event via AbstractFederation.sendEvent(Event).
 Event start()
          Send the start event.
 String toString()
          Tab-delimited format (with newline).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final transient org.apache.log4j.Logger log

fed

protected transient IBigdataFederation fed

eventUUID

public final UUID eventUUID
Unique event identifier.


hostname

public final String hostname
The host on which the event was generated.


serviceIface

public final Class serviceIface
The most interesting class or interface for the service which generated that event.


serviceName

public final String serviceName
The name of the service which generated the event.


serviceUUID

public final UUID serviceUUID
The UUID for the service which generated that event.


resource

public final EventResource resource
The resource for which the event is reported (store file, index name, etc). Note that the serviceUUID will also be reported.


majorEventType

public final Object majorEventType
Major event type (classification or category).


minorEventType

public final Object minorEventType
Minor event type (classification or category).


details

protected Map<String,Object> details
Event details.


startTime

protected long startTime
The event start time. Assigned locally. The recipient may use [endTime - startTime] to adjust the event to its local clock.


endTime

protected long endTime
The event end time. Assigned locally. The recipient may use [endTime - startTime] to adjust the event to its local clock.


receiptTime

protected transient long receiptTime
The time when the event was received. The recipient may use [endTime - startTime] to adjust the event to its local clock.


complete

protected boolean complete
true iff the event event has been generated.

Constructor Detail

Event

public Event(IBigdataFederation fed,
             EventResource resource,
             Object majorEventType)

Event

public Event(IBigdataFederation fed,
             EventResource resource,
             Object majorEventType,
             Map<String,Object> details)
Event ctor.

Parameters:
fed - The federation object (used to send the event to an aggregator).
resource - The resource for which the event was generated (store, index partition, etc).
majorEventType - The major type of the event (use of enums is encouraged).
details - Optional details for the event.

Event

protected Event(IBigdataFederation fed,
                EventResource resource,
                Object majorEventType,
                Object minorEventType,
                Map<String,Object> details)
Sub-event ctor.

Parameters:
fed - The federation object (used to send the event to an aggregator).
resource - The resource for which the event was generated (store, index partition, etc).
majorEventType - The major type of the event (use of enums is encouraged).
minorEventType - The minor type of the event (use of enums is encouraged).
details - Optional details for the event.
TODO:
consider passing along the UUID of the parent event but then must correlate that UUID when the event is received.

Event

protected Event(String s)
         throws ClassNotFoundException
Construct an event from the tab-delimited serialization produced from toString().

Parameters:
s - the tab delimited serialization
Throws:
ClassNotFoundException - if any fields specify an invalid classname
Method Detail

getDetails

public Map<String,Object> getDetails()
Event details.


addDetails

public Event addDetails(Map<String,Object> details)
Add details.

Parameters:
details -
Returns:
This Event.

newDetails

protected static Map<String,Object> newDetails()
Factory for the details hash map. This is a synchronized collection since the event can be serialized concurrent with end() which would otherwise lead to a ConcurrentModificationException. It can not be a ConcurrentHashMap since that class does not support null values.


addDetail

public Event addDetail(String name,
                       Object value)
Add a detail.

Parameters:
name -
value -
Returns:
This Event.

isComplete

public boolean isComplete()
true iff the event event has been generated.


getStartTime

public long getStartTime()

getEndTime

public long getEndTime()

getElapsed

public long getElapsed()
The elapsed time for the event.


newSubEvent

public Event newSubEvent(Object minorEventType)
A child event (major type is the type of the parent).

Parameters:
minorEventType -
Returns:
The sub-event.

newSubEvent

public Event newSubEvent(Object minorEventType,
                         Map<String,Object> details)
A child event (major type is the type of the parent).

Parameters:
minorEventType -
details - Optional ordered (name,value) array.
Returns:
The sub-event.

start

public Event start()
Send the start event.

Note: If you want to report an event with a duration then you MUST use start() when the event starts and end() when the event ends. If you want to report an "instantaneous" event then you can just use end().


end

public Event end()
Sends the end event.

Note: You can use this method for "instantaneous" events.

Returns:
The event.

sendEvent

protected void sendEvent()
                  throws IOException
Dispatch the Event via AbstractFederation.sendEvent(Event).

Throws:
IOException

getHeader

public static String getHeader()
A header that can be used to interpret the output of toString() (with newline).


toString

public String toString()
Tab-delimited format (with newline). The details columns are written in a dense format where each (name,value) pair is expressed as name=value, so only the non-null columns are written out.

Overrides:
toString in class Object

fromString

public static Event fromString(String s)
                        throws ClassNotFoundException
Reconstruct an event object from a string. Useful for post-mortem analysis.

Parameters:
s - the tab-delimited format create by toString().
Returns:
a new event object
Throws:
ClassNotFoundException - if any CSV fields specify an invalid classname


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.