gov.sns.tools.correlator
Class SourceAgent

java.lang.Object
  |
  +--gov.sns.tools.correlator.SourceAgent
All Implemented Interfaces:
gov.sns.tools.correlator.StateNotice
Direct Known Subclasses:
ChannelAgent

public abstract class SourceAgent
extends java.lang.Object
implements gov.sns.tools.correlator.StateNotice

Generator manages a single channel. It performs any setup, monitors the channel and it manages a circular buffer of bin agents that gather correlated events.


Field Summary
protected  java.lang.String _name
           
protected  gov.sns.tools.correlator.BinUpdate binUpdateProxy
           
protected  MessageCenter localCenter
           
 
Constructor Summary
SourceAgent(MessageCenter newLocalCenter, java.lang.String name, RecordFilter recordFilter, CorrelationTester tester)
          Creates new ChannelAgent
 
Method Summary
 void binTimespanChanged(Correlator sender, double newTimespan)
          Handle the bin timespan changed event.
 void correlationFilterChanged(Correlator sender, CorrelationFilter newFilter)
          Implement StateNotice interface to listen for change of state
 java.lang.String name()
          Name of the managed source
protected  void postEvent(java.lang.Object record, double timestamp)
          This method is used to advertise a new event record received by the event handler of the SourceAgent subclass.
 void reset()
          clear memory of all events
 void setBinTimespan(double timespan)
          set the timespan to each bin
protected abstract  void setupEventHandler(RecordFilter recordFilter)
          Subclasses implement this method to handle the monitoring of its sources in a way specific to the particular SourceAgent subclass.
protected  void shutdown()
          shutdown this channel agent and remove itself
 void sourceAdded(Correlator sender, java.lang.String name, int newCount)
          Handle the source added event.
 void sourceRemoved(Correlator sender, java.lang.String name, int newCount)
          Handle the source removed event.
abstract  boolean startMonitor()
          Start monitoring the channel
abstract  void stopMonitor()
          Stop monitoring the channel
 void willStartMonitoring(Correlator sender)
          Handle the advance notice of the correlator starting.
 void willStopMonitoring(Correlator sender)
          Handle the advance notice of the correlator stopping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_name

protected java.lang.String _name

localCenter

protected MessageCenter localCenter

binUpdateProxy

protected gov.sns.tools.correlator.BinUpdate binUpdateProxy
Constructor Detail

SourceAgent

public SourceAgent(MessageCenter newLocalCenter,
                   java.lang.String name,
                   RecordFilter recordFilter,
                   CorrelationTester tester)
Creates new ChannelAgent

Method Detail

setupEventHandler

protected abstract void setupEventHandler(RecordFilter recordFilter)
Subclasses implement this method to handle the monitoring of its sources in a way specific to the particular SourceAgent subclass. When an event is captured and it passes the filter test, this method should call postEvent().

See Also:
postEvent(java.lang.Object, double)

reset

public void reset()
clear memory of all events


setBinTimespan

public void setBinTimespan(double timespan)
set the timespan to each bin


postEvent

protected final void postEvent(java.lang.Object record,
                               double timestamp)
This method is used to advertise a new event record received by the event handler of the SourceAgent subclass. When an event record has passed the the filter test it should be posted via this method so that other stakeholders (i.e. the bin agents) can handle the event properly.


name

public java.lang.String name()
Name of the managed source


startMonitor

public abstract boolean startMonitor()
Start monitoring the channel


stopMonitor

public abstract void stopMonitor()
Stop monitoring the channel


shutdown

protected void shutdown()
shutdown this channel agent and remove itself


sourceAdded

public void sourceAdded(Correlator sender,
                        java.lang.String name,
                        int newCount)
Description copied from interface: gov.sns.tools.correlator.StateNotice
Handle the source added event.

Specified by:
sourceAdded in interface gov.sns.tools.correlator.StateNotice
Parameters:
sender - The correlator to which the source has been added.
name - The name identifying the new source.
newCount - The new number of sources correlated.

sourceRemoved

public void sourceRemoved(Correlator sender,
                          java.lang.String name,
                          int newCount)
Description copied from interface: gov.sns.tools.correlator.StateNotice
Handle the source removed event.

Specified by:
sourceRemoved in interface gov.sns.tools.correlator.StateNotice
Parameters:
sender - The correlator from which the source has been removed.
name - The name identifying the new source.
newCount - The new number of sources correlated.

binTimespanChanged

public void binTimespanChanged(Correlator sender,
                               double newTimespan)
Description copied from interface: gov.sns.tools.correlator.StateNotice
Handle the bin timespan changed event.

Specified by:
binTimespanChanged in interface gov.sns.tools.correlator.StateNotice
Parameters:
sender - The correlator whose timespan bin has changed.
newTimespan - The new timespan used by the correlator.

willStopMonitoring

public void willStopMonitoring(Correlator sender)
Description copied from interface: gov.sns.tools.correlator.StateNotice
Handle the advance notice of the correlator stopping.

Specified by:
willStopMonitoring in interface gov.sns.tools.correlator.StateNotice
Parameters:
sender - The correlator that will stop.

willStartMonitoring

public void willStartMonitoring(Correlator sender)
Description copied from interface: gov.sns.tools.correlator.StateNotice
Handle the advance notice of the correlator starting.

Specified by:
willStartMonitoring in interface gov.sns.tools.correlator.StateNotice
Parameters:
sender - The correlator that will start.

correlationFilterChanged

public void correlationFilterChanged(Correlator sender,
                                     CorrelationFilter newFilter)
Implement StateNotice interface to listen for change of state

Specified by:
correlationFilterChanged in interface gov.sns.tools.correlator.StateNotice
Parameters:
sender - The correlator whose correlation filter has changed.
newFilter - The new correlation filter to use.