ostore.tapestry.patchwork
Class PatchworkModel.Delta

java.lang.Object
  |
  +--ostore.tapestry.patchwork.PatchworkModel.Delta
All Implemented Interfaces:
Model.Delta, QueueElementIF, QuickSerializable
Enclosing class:
PatchworkModel

public static class PatchworkModel.Delta
extends Object
implements Model.Delta

A PatchworkModel.Delta object contains a diff of the sufficient statistics for a PatchworkModel.

Version:
$Id: PatchworkModel.java,v 1.11 2003/02/05 22:49:38 hling Exp $
Author:
Jeremy Stribling

Constructor Summary
PatchworkModel.Delta()
          Construct a new Delta.
PatchworkModel.Delta(InputBuffer buffer)
          Construct a Delta from its QuickSerializable form.
PatchworkModel.Delta(QSVector toBeRemoved)
          Construct a new Delta.
 
Method Summary
 Object clone()
          Clone this delta
 Matrix getMatrix()
          Returns a Matrix containing all the delta information.
 QSVector getToBeRemoved()
          Get the list of SecureHashs whose statistics should be removed from the Model>/code>
 double lookupDouble(SecureHash peer, int type)
          Returns the most recently probed value from delta update with type type for the specified node id peer.
 void serialize(OutputBuffer buffer)
          Specified by ostore.util.QuickSerializable
 void storeDeltas(SecureHash id, Array deltas)
          Store an Array representing the deltas for the node id.
 Model.Delta sum(Model.Delta other)
          Specified by ostore.oil.Model.Delta interface
 String toString()
          Returns a String representation of this Delta
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PatchworkModel.Delta

public PatchworkModel.Delta(InputBuffer buffer)
                     throws QSException
Construct a Delta from its QuickSerializable form.

PatchworkModel.Delta

public PatchworkModel.Delta()
Construct a new Delta.

PatchworkModel.Delta

public PatchworkModel.Delta(QSVector toBeRemoved)
Construct a new Delta.
Parameters:
toBeRemoved - a QSVector of SecureHashs that should be removed from the Model.
Method Detail

storeDeltas

public void storeDeltas(SecureHash id,
                        Array deltas)
Store an Array representing the deltas for the node id. The deltas are doubles indexed by QSInt types in PatchworkModel. Overwrites any existing deltas for that id.
Parameters:
id - the node to record deltas for
deltas - the deltas themselves

lookupDouble

public double lookupDouble(SecureHash peer,
                           int type)
Returns the most recently probed value from delta update with type type for the specified node id peer. Returns Double.NaN if a value is not recorded.
Parameters:
peer - the node for which to lookup the statistic
type - the type of statistic to collect (i.e. LATENCY, BANDWIDTH, etc)
Returns:
the statistic if it exists, Double.NaN otherwise
Throws:
InvalidTypeException - if an invalid type is passed in

getMatrix

public Matrix getMatrix()
Returns a Matrix containing all the delta information. Arrays of deltas are indexed by SecureHash while deltas within those Arrays are indexed by QSInts.
Returns:
the Matrix of deltas

getToBeRemoved

public QSVector getToBeRemoved()
Get the list of SecureHashs whose statistics should be removed from the Model>/code>

sum

public Model.Delta sum(Model.Delta other)
Specified by ostore.oil.Model.Delta interface
Specified by:
sum in interface Model.Delta
Following copied from interface: ostore.oil.Model.Delta
Parameters:
other - The other Delta.
Returns:
a new Delta, constructed such that applying it to a Model produces an equivalent Model to that produced by adding first this, then other.
Throws:
IllegalArgumentException - if other is not an instance of a compatible Delta subclass.

serialize

public void serialize(OutputBuffer buffer)
Specified by ostore.util.QuickSerializable
Specified by:
serialize in interface QuickSerializable
Following copied from interface: ostore.util.QuickSerializable
Parameters:
buffer - the output buffer to add the object to

clone

public Object clone()
             throws CloneNotSupportedException
Clone this delta
Overrides:
clone in class Object

toString

public String toString()
Returns a String representation of this Delta
Overrides:
toString in class Object