tapestry.patchwork
Class PatchworkTable

java.lang.Object
  |
  +--tapestry.patchwork.PatchworkTable
All Implemented Interfaces:
QuickSerializable

public class PatchworkTable
extends Object
implements QuickSerializable

The PatchworkTable is built by the Patchwork code, and is used for collecting statistics about other nodes. It remembers observations sent to it and when recalculate is called it produces a PatchworkTable.Delta that contains the difference between the current model and the last one produced from a call to recalculate.

It combines new and old statistics using weighted function, where the new statistic is considered as important as the "alpha" value, default at 80%.

It only considers a change worthy of noting if it is greater than some threshold, default at 1%.

Currently, the measurement types are as follows:

latency (in microseconds): Patch.LATENCY

bandwidth: Patch.BANDWIDTH

loss (in percent, from 0 to 100, where 100 is complete loss): Patch.LOSS

Version:
$Id: PatchworkTable.java,v 1.2 2004/05/06 22:34:27 hweather Exp $
Author:
Jeremy Stribling

Nested Class Summary
static class PatchworkTable.Delta
          A PatchworkTable.Delta object contains a diff of the sufficient statistics for a PatchworkTable.
static class PatchworkTable.Observation
          A Patchwork.Observation object contains an observation recorded by the patchwork stage.
 
Constructor Summary
PatchworkTable()
          Create a new PatchworkTable.
PatchworkTable(InputBuffer buffer)
           
 
Method Summary
 void add_delta(PatchworkTable.Delta d)
          Update this copy of a table with a delta produced by Patchwork
protected  double getAlpha()
          How important is the current value of a statistic when calculating overall statistics?
 PatchworkStats getStats(NodeId peer, byte type)
          Get the current statistic data structure for a node.
protected  double getThreshold()
          How much does a statistic need to change for it to be considered worthy of recording?
protected  boolean initStat(NodeId peer, byte type, long value)
          Initialize a value for some statistic, only if no values have yet been recorded.
protected  PatchworkTable.Delta recalculate()
          Specified by tapestry.repairmonitor.Model interface
protected  void record(PatchworkTable.Observation obs)
          Specified by tapestry.repairmonitor.Model interface
protected  void record(PatchworkTable.Observation[] observations)
          Specified by tapestry.repairmonitor.Model interface
protected  void remove(NodeId peer)
          Tells the model to remove all statistics for this peer at the time of the next recalculation.
 void serialize(OutputBuffer buffer)
          Specified by ostore.util.QuickSerializable
protected  void setAlpha(double newAlpha)
           
protected  void setThreshold(double newThresh)
           
 String toString()
          Returns a string representation of the object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PatchworkTable

public PatchworkTable()
Create a new PatchworkTable.


PatchworkTable

public PatchworkTable(InputBuffer buffer)
               throws QSException
Method Detail

record

protected void record(PatchworkTable.Observation[] observations)
Specified by tapestry.repairmonitor.Model interface


record

protected void record(PatchworkTable.Observation obs)
Specified by tapestry.repairmonitor.Model interface


getStats

public PatchworkStats getStats(NodeId peer,
                               byte type)
Get the current statistic data structure for a node.

Parameters:
peer - the node you're interested in
type - the type of statistic desired (see class description for valid types.

initStat

protected boolean initStat(NodeId peer,
                           byte type,
                           long value)
Initialize a value for some statistic, only if no values have yet been recorded.

Returns:
whether this succeeded

remove

protected void remove(NodeId peer)
Tells the model to remove all statistics for this peer at the time of the next recalculation. This is best called when it is known for certain that a node wil not be observed ever again, or at least for a long time.

Parameters:
peer - the node for which to remove the statistics

add_delta

public void add_delta(PatchworkTable.Delta d)
Update this copy of a table with a delta produced by Patchwork


recalculate

protected PatchworkTable.Delta recalculate()
Specified by tapestry.repairmonitor.Model interface


getAlpha

protected double getAlpha()
How important is the current value of a statistic when calculating overall statistics?


getThreshold

protected double getThreshold()
How much does a statistic need to change for it to be considered worthy of recording?


setAlpha

protected void setAlpha(double newAlpha)

setThreshold

protected void setThreshold(double newThresh)

serialize

public void serialize(OutputBuffer buffer)
Specified by ostore.util.QuickSerializable

Specified by:
serialize in interface QuickSerializable

toString

public String toString()
Returns a string representation of the object

Overrides:
toString in class Object