example.aggregation
Class AverageFunction

java.lang.Object
  extended by peersim.vector.SingleValueHolder
      extended by example.aggregation.AverageFunction
All Implemented Interfaces:
java.lang.Cloneable, CDProtocol, Protocol, SingleValue

public class AverageFunction
extends SingleValueHolder
implements CDProtocol

This class provides an implementation for the averaging function in the aggregation framework. When a pair of nodes interact, their values are averaged. The class subclasses SingleValueHolder in order to provide a consistent access to the averaging variable value. Note that this class does not override the clone method, because it does not have any state other than what is inherited from SingleValueHolder.


Field Summary
 
Fields inherited from class peersim.vector.SingleValueHolder
value
 
Constructor Summary
AverageFunction(java.lang.String prefix)
          Creates a new AverageFunction protocol instance.
 
Method Summary
 void nextCycle(Node node, int protocolID)
          Using an underlying Linkable protocol choses a neighbor and performs a variance reduction step.
 
Methods inherited from class peersim.vector.SingleValueHolder
clone, getValue, setValue, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface peersim.core.Protocol
clone
 

Constructor Detail

AverageFunction

public AverageFunction(java.lang.String prefix)
Creates a new AverageFunction protocol instance.

Parameters:
prefix - the component prefix declared in the configuration file.
Method Detail

nextCycle

public void nextCycle(Node node,
                      int protocolID)
Using an underlying Linkable protocol choses a neighbor and performs a variance reduction step.

Specified by:
nextCycle in interface CDProtocol
Parameters:
node - the node on which this component is run.
protocolID - the id of this protocol in the protocol array.