viceroy
Class PapersPlusAlgorithm
java.lang.Object
|
+--viceroy.PapersAlgorithm
|
+--viceroy.PapersPlusAlgorithm
- All Implemented Interfaces:
- LookupAlgorithm
- public class PapersPlusAlgorithm
- extends PapersAlgorithm
resembles the paper's algorithm but has a small
extra check: in the Traverse Tree phase, before doing
anything, i check if the left child or the right is
responsible for the value. if so then without any other check,
goto the ring phase with the child that is responsible.
- Since:
- 1.92
- Author:
- Anat Talmy
, Oren Dobzinski
|
Field Summary |
private static org.apache.log4j.Logger |
logger
logger for debug |
| 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 |
logger
private static final org.apache.log4j.Logger logger
- logger for debug
PapersPlusAlgorithm
public PapersPlusAlgorithm(AuthorizedViceroyPeer first)
- Empty Ctor to avoid duplication.
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
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( leftChild && leftChild.isResponsible(val) )
goto leftChild
if( rightChild && rightChild.isResponsible(val) )
goto rightChild
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 goto traverse ring phase
- Overrides:
lookupTraverseTree in class PapersAlgorithm
- Parameters:
peer - the current peervalueToLook -
- Returns:
- the next peer to go to according the lookup algorithm
- Throws:
ResourceNotFoundException