viceroy
Class TraverseTreePlusAlgorithm

java.lang.Object
  |
  +--viceroy.PapersAlgorithm
        |
        +--viceroy.TraverseTreePlusAlgorithm
All Implemented Interfaces:
LookupAlgorithm

public class TraverseTreePlusAlgorithm
extends PapersAlgorithm
implements LookupAlgorithm

Change the TraverseTree phase in the lookup algorithm The change is as follows: if one of the children exists - certainly go to one of them. else goto TraveseRingPhase

Since:
1.72
Author:
Anat Talmy
, Oren Dobzinski

Field Summary
private static org.apache.log4j.Logger logger
          logger for debug
 
Fields inherited from class viceroy.PapersAlgorithm
messagePath, state
 
Constructor Summary
TraverseTreePlusAlgorithm(AuthorizedViceroyPeer peer)
          a constructor
 
Method Summary
protected  ViceroyPeer lookupTraverseTree(AuthorizedViceroyPeer peer, Resource valueToLook)
          Performs the traverse tree phase in the lookup algorithm.
 LookupAlgorithm newLookupAlgorithm(AuthorizedViceroyPeer peer)
          creates a fresh new lookup algorithm, with empty path
 
Methods inherited from class viceroy.PapersAlgorithm
getLookupState, getMessagePath, goToLeftChild, goToParent, goToPredecessor, goToRightChild, goToSuccessor, howOvershoots, lookupProceedToRoot, lookupTraverseRing, nextOnLookup, overshoots
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface viceroy.LookupAlgorithm
getMessagePath, nextOnLookup
 

Field Detail

logger

private static final org.apache.log4j.Logger logger
logger for debug

Constructor Detail

TraverseTreePlusAlgorithm

public TraverseTreePlusAlgorithm(AuthorizedViceroyPeer peer)
a constructor

Parameters:
peer -
Method Detail

lookupTraverseTree

protected ViceroyPeer lookupTraverseTree(AuthorizedViceroyPeer peer,
                                         Resource valueToLook)
                                  throws ResourceNotFoundException
Performs the traverse tree phase in the lookup algorithm. This phase is as follows: if one of the children exists - certainly go to one of them.
 if( clockwiseDist(this,val) < 1/2^level &&
     leftChild &&
     !overshoot(leftChild,val) )
   goto leftChild
 
 else if ( clockwiseDist(this,val) >=1/2^level &&
           rightChild &&
           !overshoot(rightChild,val) )
        goto rightChild
 
 else if ( leftChild && rightChild==null )
        goto leftChild
        
 else if ( rightChild && leftChild==null )
        goto rightChild
        
 else if ( leftChild && rightChild)
         goto the child that least overshoots
               
 else goto traverse ring phase
 

Overrides:
lookupTraverseTree in class PapersAlgorithm
Parameters:
peer - the current peer
valueToLook -
Returns:
the next peer to go to according the lookup algorithm
Throws:
ResourceNotFoundException

newLookupAlgorithm

public LookupAlgorithm newLookupAlgorithm(AuthorizedViceroyPeer peer)
creates a fresh new lookup algorithm, with empty path

Specified by:
newLookupAlgorithm in interface LookupAlgorithm
Overrides:
newLookupAlgorithm in class PapersAlgorithm
Parameters:
peer - starting point of the new algorithm
Returns:
a fresh new lookup algorithm, with empty path