bamboo.vivaldi
Class VirtualCoordinate

java.lang.Object
  extended by bamboo.vivaldi.VirtualCoordinate
All Implemented Interfaces:
ostore.util.QuickSerializable
Direct Known Subclasses:
FiveDVC, SpecialVC

public class VirtualCoordinate
extends Object
implements ostore.util.QuickSerializable

Virtual network coordinates as calculated by Vivaldi. The update algorithm is included in this class.

Version:
$Id: VirtualCoordinate.java,v 1.3 2004/03/10 20:39:43 czerwin Exp $
Author:
Steven E. Czerwinski

Field Summary
protected  double[] _coordinate
           
protected  double _delta
          The dampening factor applied to each sample's update.
 
Constructor Summary
protected VirtualCoordinate()
          Creates an virtual coordinate at the origin of the space.
  VirtualCoordinate(ostore.util.InputBuffer buffer)
           
 
Method Summary
protected  double[] displacement(VirtualCoordinate remote)
          Returns a unit vector in the direction towards the remote coordinate.
 double distance(VirtualCoordinate destination)
          Calculates the distance between this coordinate to the given destination.
 boolean equals(Object other)
           
 double[] getCoordinates()
          Returns a copy of the coordinate array.
protected  int getDimensions()
          Returns the number of dimensions to use for this version of the virtual coordinates.
protected  double[] random_displacement()
           
protected  double[] random_displacement(double[] dir, int size)
          Creates a unit vector in a random direction.
protected  double[] random_displacement(int size)
           
 void serialize(ostore.util.OutputBuffer buffer)
           
 String toString()
           
 void update(VirtualCoordinate remote_coord, double latency)
          Update this coordinate's position with the given latency sample.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_delta

protected double _delta
The dampening factor applied to each sample's update. (From Vivaldi's algorithm.)


_coordinate

protected double[] _coordinate
Constructor Detail

VirtualCoordinate

protected VirtualCoordinate()
Creates an virtual coordinate at the origin of the space.

Parameters:
dimensions - The number of dimensions to have

VirtualCoordinate

public VirtualCoordinate(ostore.util.InputBuffer buffer)
                  throws ostore.util.QSException
Throws:
ostore.util.QSException
Method Detail

getDimensions

protected int getDimensions()
Returns the number of dimensions to use for this version of the virtual coordinates.


serialize

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

distance

public double distance(VirtualCoordinate destination)
Calculates the distance between this coordinate to the given destination. This will be an estimate of the one-way network latencies between the two nodes in milliseconds.

Parameters:
destination - The coordinate to compare this object against.
Returns:
The distance between the coordinates, as expressed by one-way network latency in milliseconds.

displacement

protected double[] displacement(VirtualCoordinate remote)
Returns a unit vector in the direction towards the remote coordinate. If the coordinates are the same, null is returned since you cannot produce a unit vector.

Parameters:
remote - The remote coordinate.
Returns:
A unit vector in the direction towards the remote, or null if the coords are the same.

random_displacement

protected double[] random_displacement(double[] dir,
                                       int size)
Creates a unit vector in a random direction.


random_displacement

protected double[] random_displacement(int size)

random_displacement

protected double[] random_displacement()

update

public void update(VirtualCoordinate remote_coord,
                   double latency)
Update this coordinate's position with the given latency sample.

Parameters:
remote_coord - The node's coordinate used to get the latency sample.
latency - The measured network latency (one-way, in milliseconds) to the remote node.

equals

public boolean equals(Object other)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

getCoordinates

public double[] getCoordinates()
Returns a copy of the coordinate array.