All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class magician.PerfTools.EventManager

java.lang.Object
   |
   +----magician.PerfTools.EventManager

public class EventManager
extends Object
implements Sleeper, PerfConstants
EventManager is a class that manages the event list. Initially, EventManager allocates itself a circular list of free NetEvents. When an event is posted the next free slot is allocated to the event. The writeToOutput() routine writes all the recorded events to the given output stream.

See Also:
NetEvent

Variable Index

 o alarm
 o ALL_EVENT_LISTN
 o EVENTCLASS
 o eventListeners
 o EventQ
 o size
 o tracelevel
 o used

Constructor Index

 o EventManager(int)
creates a pool of free NetEvents

Method Index

 o addListenerForAllEvents(NetEventListener, boolean)
adds listener for all events generated by EventManager.
 o addListenerForEvent(String, NetEventListener, boolean)
adds listener for specific events generated by EventManager.
 o flushBuffers(long)
Classes intending to use periodic flushing of the buffers must call this method to initiate a timer.
 o getFreeEvent()
returns the next free event in the circular list.
 o postEvent(int, String, long, long)
posts an event by calling the NetEvent's update method (if provided) to record event information, else declare the variables of the NetEvent class as public and update them directly in this method.
 o postEvent(int, String, long, long, String)
posts an event by calling the NetEvent's update method (if provided) to record event information, else declare the variables of the NetEvent class as public and update them directly in this method.
 o removeListenerForAllEvents(NetEventListener)
removes listener registered for all events generated by EventManager.
 o removeListenerForEvent(String, NetEventListener)
removes listener from specific events generated by EventManager.
 o stop()
stops the EventManager and prints out all records to the output stream.
 o traceDepthSupported(int)
check if event at particular depth should be logged
 o wakeup()
calls internal dump routine to write records to output stream.
 o writeToOutput()
writes out all the NetEvent objects to all listeners

Variables

 o EVENTCLASS
 static final String EVENTCLASS
 o ALL_EVENT_LISTN
 static final String ALL_EVENT_LISTN
 o size
 protected int size
 o used
 protected int used
 o EventQ
 protected CircularList EventQ
 o alarm
 protected Alarm alarm
 o eventListeners
 protected EventListenerTable eventListeners
 o tracelevel
 protected int tracelevel

Constructors

 o EventManager
 public EventManager(int size) throws IllegalArgumentException, ClassNotFoundException
creates a pool of free NetEvents

Parameters:
EventName - name of Event structure being logged
size - requires size of event pool to be created initially
Throws: IllegalArgumentException
thrown if the size of the list is not a positive number
Throws: ClassNotFoundException
thrown if the class definition does not exist

Methods

 o flushBuffers
 protected boolean flushBuffers(long bufferFlushInterval)
Classes intending to use periodic flushing of the buffers must call this method to initiate a timer.

Parameters:
bufferFlushInterval - the interval in milliseconds
Returns:
s true if buffer flushing is enabled else returns false.
 o getFreeEvent
 protected NetEvent getFreeEvent()
returns the next free event in the circular list. Also does house keeping.

 o traceDepthSupported
 public boolean traceDepthSupported(int depth)
check if event at particular depth should be logged

Parameters:
depth - trace level for event
Returns:
s true if event can be logged
 o postEvent
 public synchronized void postEvent(int traceDepth,
                                    String eventName,
                                    long eventTime,
                                    long packetID,
                                    String otherParams)
posts an event by calling the NetEvent's update method (if provided) to record event information, else declare the variables of the NetEvent class as public and update them directly in this method. Classes implementing this method must call getFreeEvent() to get the NetEvent object to update.

 o postEvent
 public synchronized void postEvent(int traceDepth,
                                    String eventName,
                                    long eventTime,
                                    long packetID)
posts an event by calling the NetEvent's update method (if provided) to record event information, else declare the variables of the NetEvent class as public and update them directly in this method. Classes implementing this method must call getFreeEvent() to get the NetEvent object to update.

 o wakeup
 public void wakeup()
calls internal dump routine to write records to output stream.

 o addListenerForEvent
 public void addListenerForEvent(String EventName,
                                 NetEventListener listener,
                                 boolean syncFlag)
adds listener for specific events generated by EventManager. Listener must conform to the NetEventListener interface. The listener can choose to be notified synchronously or asynchronously. Typically, synchronous notification is to be used for alarms while asynchronous notification is to be used for normal reporting.

Parameters:
EventName - event to listen
listener - name of event listener
syncFlag - set to true if notification must be immediate
See Also:
NetEventListener
 o addListenerForAllEvents
 public void addListenerForAllEvents(NetEventListener listener,
                                     boolean syncFlag)
adds listener for all events generated by EventManager. Listener must conform to the NetEventListener interface. The listener can choose to be notified synchronously or asynchronously. Typically, synchronous notification is to be used for alarms while asynchronous notification is to be used for normal reporting.

Parameters:
listener - name of event listener
syncFlag - set to true if notification must be immediate
See Also:
NetEventListener
 o removeListenerForEvent
 public boolean removeListenerForEvent(String EventName,
                                       NetEventListener listener)
removes listener from specific events generated by EventManager. Listener must conform to the NetEventListener interface

Parameters:
EventName - name of event
listener - name of event listener
See Also:
NetEventListener
 o removeListenerForAllEvents
 public boolean removeListenerForAllEvents(NetEventListener listener)
removes listener registered for all events generated by EventManager. Listener must conform to the NetEventListener interface

Parameters:
EventName - name of event
listener - name of event listener
See Also:
NetEventListener
 o writeToOutput
 protected synchronized void writeToOutput()
writes out all the NetEvent objects to all listeners

 o stop
 public void stop()
stops the EventManager and prints out all records to the output stream.


All Packages  Class Hierarchy  This Package  Previous  Next  Index
1