gov.sns.tools.correlator
Class Correlator

java.lang.Object
  |
  +--gov.sns.tools.correlator.Correlator
Direct Known Subclasses:
ChannelCorrelator

public abstract class Correlator
extends java.lang.Object

The Correlator is the class that is used to setup monitoring of correlated events. It is the sole entry point to the outside world. When correlations are found, the Correlator broadcasts the correlation. Note that all time is in seconds unless otherwise stated.


Field Summary
protected  double _binTimespan
           
protected  CorrelationTester correlationTester
           
protected  MessageCenter localCenter
           
 
Constructor Summary
Correlator(double aBinTimespan)
          Creates new Correlator
Correlator(double aBinTimespan, CorrelationFilter aFilter)
          Correlator constructor
 
Method Summary
 void addListener(CorrelationNotice listener)
          Register the listener as a receiver of Correlation notices from this correlator.
protected  void addSource(java.lang.Object source, java.lang.String sourceName)
          Add a source to monitor.
protected  void addSource(java.lang.Object source, java.lang.String sourceName, RecordFilter recordFilter)
          Add a source to monitor.
 double binTimespan()
          maximum time span allowed for events to be considered correlated
 void dispose()
          Dispose of the correlator and its overhead
 Correlation fetchCorrelationWithTimeout(double aTimeout)
          fetchCorrelationWithTimeout() is a convenience method that allows the user a simple way to fetch a correlation without handling events and implementing a listener.
 java.util.Collection getNamesOfSources()
          Get all the names of all the sources managed by this correlator
protected  java.util.Collection getSourceAgents()
          Get all of the channel agents managed by this correlator
 boolean hasSource(java.lang.String sourceName)
          See if we already manage this channel
 boolean isRunning()
          Determine if the correlator is running
 void monitorWithTimeout(double timeout)
          Monitor and post the best partial correlation if the timeout is exceeded.
protected abstract  SourceAgent newSourceAgent(java.lang.Object source, java.lang.String sourceName, RecordFilter recordFilter)
           
 int numSources()
          Number of channels being managed
 void pulseMonitorWithTimeout(double timeout)
          Monitor until the timeout or until a complete correlation is found
protected  void registerEvents()
          Register for notices.
 void removeAllSources()
          Stop managing all registered sources
 void removeListener(CorrelationNotice listener)
          Unregister the listener as a receiver of Correlation notices from this correlator.
 void removeSource(java.lang.String sourceName)
          Stop managing the specified source.
 void setBinTimespan(double timespan)
          Set the maximum time span allowed for events to be considered correlated
 void setCorrelationFilter(CorrelationFilter newFilter)
          Set the correlation filter to the one specified.
 void startMonitoring()
          Start monitoring the managed sources.
 void stopMonitoring()
          Stop monitoring the managed sources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

localCenter

protected MessageCenter localCenter

_binTimespan

protected double _binTimespan

correlationTester

protected CorrelationTester correlationTester
Constructor Detail

Correlator

public Correlator(double aBinTimespan)
Creates new Correlator


Correlator

public Correlator(double aBinTimespan,
                  CorrelationFilter aFilter)
Correlator constructor

Method Detail

registerEvents

protected void registerEvents()
Register for notices.


addListener

public void addListener(CorrelationNotice listener)
Register the listener as a receiver of Correlation notices from this correlator.


removeListener

public void removeListener(CorrelationNotice listener)
Unregister the listener as a receiver of Correlation notices from this correlator.


binTimespan

public double binTimespan()
maximum time span allowed for events to be considered correlated


setBinTimespan

public void setBinTimespan(double timespan)
Set the maximum time span allowed for events to be considered correlated


setCorrelationFilter

public void setCorrelationFilter(CorrelationFilter newFilter)
Set the correlation filter to the one specified.

Parameters:
newFilter - The correlation filter to use.

getSourceAgents

protected java.util.Collection getSourceAgents()
Get all of the channel agents managed by this correlator


getNamesOfSources

public java.util.Collection getNamesOfSources()
Get all the names of all the sources managed by this correlator


numSources

public int numSources()
Number of channels being managed


hasSource

public boolean hasSource(java.lang.String sourceName)
See if we already manage this channel


addSource

protected void addSource(java.lang.Object source,
                         java.lang.String sourceName)
Add a source to monitor. The name provided with each source must be unique to that source. Subclasses need to wrap this method to enforce the source type.


addSource

protected void addSource(java.lang.Object source,
                         java.lang.String sourceName,
                         RecordFilter recordFilter)
Add a source to monitor. If we already monitor a source as determined by the source name, then do nothing. The record filter is used to determine whether or not to accept a reading of the specified source when the event is handled. You can create your own custom filter or use a pre-built one. Subclasses need to wrap this method to enforce the source type.


newSourceAgent

protected abstract SourceAgent newSourceAgent(java.lang.Object source,
                                              java.lang.String sourceName,
                                              RecordFilter recordFilter)

removeSource

public void removeSource(java.lang.String sourceName)
Stop managing the specified source.


removeAllSources

public void removeAllSources()
Stop managing all registered sources


pulseMonitorWithTimeout

public void pulseMonitorWithTimeout(double timeout)
Monitor until the timeout or until a complete correlation is found

Parameters:
timeout - time to wait in seconds

monitorWithTimeout

public void monitorWithTimeout(double timeout)
Monitor and post the best partial correlation if the timeout is exceeded. The timeout is rescheduled after every post.

Parameters:
timeout - time to wait in seconds

startMonitoring

public void startMonitoring()
Start monitoring the managed sources.


stopMonitoring

public void stopMonitoring()
Stop monitoring the managed sources.


isRunning

public boolean isRunning()
Determine if the correlator is running

Returns:
true if the correlator is running and false otherwise.

dispose

public void dispose()
Dispose of the correlator and its overhead


fetchCorrelationWithTimeout

public Correlation fetchCorrelationWithTimeout(double aTimeout)
fetchCorrelationWithTimeout() is a convenience method that allows the user a simple way to fetch a correlation without handling events and implementing a listener. The method spawns a fetch and blocks until a correlation is retrieved or the timeout has expired. The resulting correlation is returned. If no correlation was found within the timeout, null is returned.