Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.mit.media.hive.agent.filter
Class MovingAverageAgentImpl  view MovingAverageAgentImpl download MovingAverageAgentImpl.java

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended byedu.mit.media.hive.agent.AgentImpl
                  extended byedu.mit.media.hive.agent.EventReceivingAgentImpl
                      extended byedu.mit.media.hive.agent.filter.MovingAverageAgentImpl
All Implemented Interfaces:
edu.mit.media.hive.agent.Agent, edu.mit.media.hive.rdf.Describable, EventFloatTranslatingAgent, java.util.EventListener, edu.mit.media.hive.agent.EventReceivingAgent, edu.mit.media.hive.agent.FloatSourceAgent, java.rmi.Remote, edu.mit.media.hive.event.RemoteEventListener, java.io.Serializable

public class MovingAverageAgentImpl
extends edu.mit.media.hive.agent.EventReceivingAgentImpl
implements EventFloatTranslatingAgent

Chaining agent - takes in event input from an agent, produces a time average. This has two parameters - how many milliseconds to remember, and how many milliseconds to average over. If historyLength is 300000 and averageWindow is 10000, then what we get is a 5 minute moving average of the number of events per 10 seconds.


Field Summary
protected  int averageWindow
           
protected  int[] eventCounts
           
protected  int eventCountScan
           
protected  int historyLength
           
protected  int lastValidNumber
           
protected  float movingAverage
           
 
Fields inherited from class edu.mit.media.hive.agent.EventReceivingAgentImpl
agentSubscriptions
 
Fields inherited from class edu.mit.media.hive.agent.AgentImpl
AGENTKILLED, AGENTMOVED, agentThreadGroup, commandList, commands, description, icon, iconName, myCell, readyFlag, stopCode, timeToStop
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
MovingAverageAgentImpl()
           
 
Method Summary
protected  void buildEventCounts()
           
 void doBehavior()
          Do the basic behavior for an agent, the agent's main loop.
 void doLocalSetup()
          Handle the setup when an agent arrives on a host -- it is appropriate to allocate system resources (file descriptors, etc) here and even to locate other agents that this agent needs to communicate with.
 int getAverageWindow()
           
 float getFloat(edu.mit.media.hive.agent.Agent sender)
           
 int getHistoryLength()
           
 void notify(edu.mit.media.hive.event.HiveEvent event)
          Called when an event is sent from a source.
 void setAverageWindow(int aw)
           
 void setHistoryLength(int hl)
           
protected  void updateAverage()
           
 
Methods inherited from class edu.mit.media.hive.agent.EventReceivingAgentImpl
connectTo, diePlease, disconnectFrom, disconnectFromAll, listAllIncomingConnections, notify, subscribeTo
 
Methods inherited from class edu.mit.media.hive.agent.AgentImpl
addActionCommand, blockUntilReady, configure, doBehaviour, doLocalCleanup, getActionCommands, getCell, getComponentManagerShadow, getDescription, getIcon, getIconName, getName, getThreadGroup, invokeActionCommand, isReady, isTimeToStop, listAllOutgoingConnections, loadIcon, moveTo, onDying, onMoving, setCell, setDescription, setIconName, setIsReady, setThreadGroup, setTimeToStop, waitUntilDeath
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.mit.media.hive.agent.Agent
blockUntilReady, configure, connectTo, diePlease, disconnectFrom, disconnectFromAll, getActionCommands, getCell, getDescription, getIcon, getName, invokeActionCommand, isReady, listAllIncomingConnections, listAllOutgoingConnections
 
Methods inherited from interface edu.mit.media.hive.rdf.Describable
setDescription
 
Methods inherited from interface edu.mit.media.hive.event.RemoteEventListener
notify
 

Field Detail

eventCounts

protected int[] eventCounts

eventCountScan

protected int eventCountScan

lastValidNumber

protected int lastValidNumber

movingAverage

protected float movingAverage

historyLength

protected int historyLength

averageWindow

protected int averageWindow
Constructor Detail

MovingAverageAgentImpl

public MovingAverageAgentImpl()
                       throws java.rmi.RemoteException
Method Detail

doLocalSetup

public void doLocalSetup()
Description copied from class: edu.mit.media.hive.agent.AgentImpl
Handle the setup when an agent arrives on a host -- it is appropriate to allocate system resources (file descriptors, etc) here and even to locate other agents that this agent needs to communicate with. This method replaces arriveAt


setAverageWindow

public void setAverageWindow(int aw)

setHistoryLength

public void setHistoryLength(int hl)

buildEventCounts

protected void buildEventCounts()

doBehavior

public void doBehavior()
Description copied from class: edu.mit.media.hive.agent.AgentImpl
Do the basic behavior for an agent, the agent's main loop. Override this to provide your particular agent's behavior. Note: the doBehavior loop should not exit. Please call waitUntilDeath() at the end of this method, this will prevent the Cell from believing this agent prematurely exited.


updateAverage

protected void updateAverage()

getFloat

public float getFloat(edu.mit.media.hive.agent.Agent sender)
Specified by:
getFloat in interface edu.mit.media.hive.agent.FloatSourceAgent

notify

public void notify(edu.mit.media.hive.event.HiveEvent event)
Description copied from interface: edu.mit.media.hive.agent.EventReceivingAgent
Called when an event is sent from a source.

Specified by:
notify in interface edu.mit.media.hive.agent.EventReceivingAgent

getAverageWindow

public int getAverageWindow()

getHistoryLength

public int getHistoryLength()