ostore.tapestry.impl
Class RoutingTable

java.lang.Object
  |
  +--ostore.tapestry.impl.RoutingTable

public class RoutingTable
extends Object

Implements the routing table interface.

Version:
$Id: RoutingTable.java,v 1.7 2002/03/27 00:08:07 ravenben Exp $
Author:
Ben Y. Zhao

Inner Class Summary
static class RoutingTable.Available
           
 
Field Summary
static int BITS_PER_DIGIT
           
static int DIGIT_VALUES
           
static int DIGITS_PER_GUID
           
 
Constructor Summary
RoutingTable(NodeId self_node_id)
           
 
Method Summary
 void addBackup(int digit, int value, NodeId nid, Long latency, SecureHash guid)
          Add alternate/backup routes to the routing table
 void addDistance(long rtt, NodeId nid, SecureHash newguid)
          Method to add the latency measurement to the data structures
 void addSelf(SecureHash self)
           
 int bits_per_digit()
           
 int digit_values()
           
 int digits_per_guid()
           
static int[] digits(SecureHash h)
           
 RouteEntry getEntry(int digit, int value)
           
 SecureHash node_id_to_guid(NodeId node_id)
           
 void optimize(long delta, NodeId nid, SecureHash newguid)
           
 String printGuid(SecureHash x)
           
 NodeId read(int which_digit, int digit_value)
           
 NodeId surrogate(int[] dest_digits, int dest_digit, int hop)
          Find the surrogate for an empty routing table entry.
 String toString()
           
 void write(int which_digit, int digit_value, NodeId node_id, SecureHash node_guid, Long latency)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BITS_PER_DIGIT

public static final int BITS_PER_DIGIT

DIGITS_PER_GUID

public static final int DIGITS_PER_GUID

DIGIT_VALUES

public static final int DIGIT_VALUES
Constructor Detail

RoutingTable

public RoutingTable(NodeId self_node_id)
Method Detail

digit_values

public int digit_values()

digits_per_guid

public int digits_per_guid()

bits_per_digit

public int bits_per_digit()

node_id_to_guid

public SecureHash node_id_to_guid(NodeId node_id)

read

public NodeId read(int which_digit,
                   int digit_value)

write

public void write(int which_digit,
                  int digit_value,
                  NodeId node_id,
                  SecureHash node_guid,
                  Long latency)

optimize

public void optimize(long delta,
                     NodeId nid,
                     SecureHash newguid)
Parameters:
newguid - The guid of some node
nid - The nodeid of that node
delta - is the estimated RTT distance from us to that node

addBackup

public void addBackup(int digit,
                      int value,
                      NodeId nid,
                      Long latency,
                      SecureHash guid)
Add alternate/backup routes to the routing table
Parameters:
digit - digit of entry being added
value - value of entry's Guid at the relevant digit
nid - NodeId of entry being added
latency - Last tested latency of new entry
guid - Guid of new entry

getEntry

public RouteEntry getEntry(int digit,
                           int value)

addDistance

public void addDistance(long rtt,
                        NodeId nid,
                        SecureHash newguid)
Method to add the latency measurement to the data structures
Parameters:
rtt - Estimated roundtrip distance
nid - NodeId of new node
newguid - Guid of new node

surrogate

public NodeId surrogate(int[] dest_digits,
                        int dest_digit,
                        int hop)
Find the surrogate for an empty routing table entry.
Parameters:
dest_digits - The array of ints representing the destination guid
dest_digit - The digit value that points to an empty entry
hop - Which hop are we looking for the surrogate route on
Returns:
null if we are definitely the surrogate, and the NodeId of the next person to ask if we cannot tell from this hop yet.

addSelf

public void addSelf(SecureHash self)

digits

public static int[] digits(SecureHash h)

toString

public String toString()
Overrides:
toString in class Object

printGuid

public String printGuid(SecureHash x)