ostore.tapestry.impl
Class TapestryVerifier

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

public class TapestryVerifier
extends Object

An object of this class can be used to verify certain properties about a Tapestry network, given complete knowledge about the network. For example, given everyone's Guids and RoutingTables, it can verify the correctness of each RoutingTable.

Once a TapestryVerifier has first been populated with data (either through the constructor or a call to addData), that will be the only kind of data the object will accept. For example, if you construct a TapestryVerifier with the (guids[], tables[]) constructor, you cannot later call the addData( guid, table, revpointers) method.

Version:
$Id: TapestryVerifier.java,v 1.6 2003/03/17 23:58:30 ravenben Exp $
Author:
Jeremy Stribling

Inner Class Summary
 class TapestryVerifier.Tree
          Organizes guids into a tree-like data structure that makes it easy to tell who should know about each other.
 
Field Summary
static String ERROR_BAD_GUID_DIGITS
           
static String ERROR_BAD_LAT_ORDER
           
static String ERROR_BAD_REVPOINTER
           
static String ERROR_DUPLICATE_GUID
           
static String ERROR_GUID_NOT_IN_REVS
           
static String ERROR_NO_DATA
           
static String ERROR_NO_GUID
           
static String ERROR_NO_LAT
           
static String ERROR_ROUTING_HOLE
           
 
Constructor Summary
TapestryVerifier()
          Create an empty TapestryVerifier, and fill it up with data one at a time later.
TapestryVerifier(SecureHash[] guids, RoutingTable[] tables)
          Create a TapestryVerifier that can verify that every RoutingTable is correct as well.
TapestryVerifier(SecureHash[] guids, RoutingTable[] tables, HashMap[] revpointers)
          Create a TapestryVerifier that can verify that every RoutingTable is correct as well, and also verify that every revpointers map is correct.
 
Method Summary
 void addData(SecureHash guid, RoutingTable table)
          Consider more data.
 void addData(SecureHash guid, RoutingTable table, HashMap revpointers)
          Consider more data.
 String getErrors()
          Return the String of all the errors from the last verify.
static void main(String[] args)
           
 void printErrors()
          Prints the errors from the last verify() call to STDOUT.
 void reset()
          This should be called when getting ready to populate this Verifier with a new set of data, or if the guids of any nodes have changed.
 boolean verify()
          Verify all the info we have about this Tapestry network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_NO_GUID

public static final String ERROR_NO_GUID

ERROR_NO_DATA

public static final String ERROR_NO_DATA

ERROR_BAD_GUID_DIGITS

public static final String ERROR_BAD_GUID_DIGITS

ERROR_NO_LAT

public static final String ERROR_NO_LAT

ERROR_BAD_LAT_ORDER

public static final String ERROR_BAD_LAT_ORDER

ERROR_GUID_NOT_IN_REVS

public static final String ERROR_GUID_NOT_IN_REVS

ERROR_ROUTING_HOLE

public static final String ERROR_ROUTING_HOLE

ERROR_BAD_REVPOINTER

public static final String ERROR_BAD_REVPOINTER

ERROR_DUPLICATE_GUID

public static final String ERROR_DUPLICATE_GUID
Constructor Detail

TapestryVerifier

public TapestryVerifier()
Create an empty TapestryVerifier, and fill it up with data one at a time later.

TapestryVerifier

public TapestryVerifier(SecureHash[] guids,
                        RoutingTable[] tables)
Create a TapestryVerifier that can verify that every RoutingTable is correct as well. All holes are filled that should be filled, all nodes are sorted correctly according to the latencies recorded, no nodes are in incorrect spots, etc.
Parameters:
guids - An array of all known guids in the network.
tables - An array of all RoutingTables for all nodes, in the same order as the corresponding guids.

TapestryVerifier

public TapestryVerifier(SecureHash[] guids,
                        RoutingTable[] tables,
                        HashMap[] revpointers)
Create a TapestryVerifier that can verify that every RoutingTable is correct as well, and also verify that every revpointers map is correct. All nodes in each revpointers are actually being pointed to in the corresponding RoutingTable, all nodes in RoutingTable are in corresponding revpointers, etc.
Parameters:
guids - An array of all known guids in the network.
tables - An array of all RoutingTables for all nodes, in the same order as the corresponding guids.
revpointers - An array of the revpointer HashMaps for all nodes, in the same order as the corresponding guids.
Method Detail

addData

public void addData(SecureHash guid,
                    RoutingTable table)
Consider more data.
Parameters:
guid - a guid of a node in the network
table - the RoutingTable of the node

addData

public void addData(SecureHash guid,
                    RoutingTable table,
                    HashMap revpointers)
Consider more data.
Parameters:
guid - a guid of a node in the network
table - the RoutingTable of the node
revpointers - the reverse pointers of the node

printErrors

public void printErrors()
Prints the errors from the last verify() call to STDOUT.

getErrors

public String getErrors()
Return the String of all the errors from the last verify. This is useful if the caller wants to parse it and take corrective measures. Returns null if no errors or if verify() hasn't been called.

reset

public void reset()
This should be called when getting ready to populate this Verifier with a new set of data, or if the guids of any nodes have changed.

verify

public boolean verify()
Verify all the info we have about this Tapestry network. Returns true if everything was correct. Otherwise, it will return false and the errors can be printed to STDOUT with a call to printErrors. verify will cache its answer after the first call, and that answer will remain valid until more data is added.
Returns:
whether all data is consistent for this Tapestry network

main

public static void main(String[] args)