oogp2p.chord
Class ChordNode

java.lang.Object
  extended byoogp2p.chord.ChordNode
All Implemented Interfaces:
java.io.Serializable

public class ChordNode
extends java.lang.Object
implements java.io.Serializable

ChordNode.java Created: Sun Sep 28 16:27:51 2003

Version:
Author:
Chris Zeiders, OogP2P
See Also:
Serialized Form

Field Summary
private  java.util.Vector Fingers
           
private  java.util.AbstractMap myKeys
           
private  ChordLocation myLocation
           
private  ChordLocation myPredecessor
           
private  ChordLocation mySuccessor
           
private  int SIZE
           
 
Constructor Summary
ChordNode()
           
ChordNode(ChordLocation loc)
           
 
Method Summary
 void addKey(byte[] key, java.net.InetAddress nodeIP)
           
private  int BigIntLog(java.math.BigInteger subtraction)
           
 void buildFingers(ChordLocation n)
           
private  boolean checkByteEquality(byte[] b, byte[] key)
           
private  boolean checkByteEquality(int[] b, int[] key)
           
private  ChordLocation closestPreceedingNode(ChordLocation id)
           
 void create()
           
 java.util.Vector findSuccessor(ChordLocation id)
           
private  ChordLocation firstSuccessor()
           
 void fixKeys()
           
 ChordLocation getFinger(int fingerPos)
           
 java.net.InetAddress getIP()
           
 ChordLocation getLocation()
           
 java.util.Iterator getMapping(byte[] key)
           
private  java.math.BigInteger getModValue()
           
 ChordLocation getPredecessor()
           
 ChordLocation getSuccessor()
           
 java.net.InetAddress getSuccessorIP()
          Returns IP of sucessor.
private  byte[] modifyByteArray(byte[] tempSumBytes)
           
 void notify(ChordLocation node)
           
 void printFingers()
           
 void printKeys()
           
private  java.lang.String printVal(byte[] b)
           
 void refreshFingers()
           
 void setFinger(ChordLocation updatedLoc, int fingerPos)
           
 void setPredecessor(ChordLocation pnode)
           
 void setSuccessor(ChordLocation node)
           
 void stabilize(ChordLocation pofs)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Fingers

private java.util.Vector Fingers

myKeys

private java.util.AbstractMap myKeys

myLocation

private ChordLocation myLocation

mySuccessor

private ChordLocation mySuccessor

myPredecessor

private ChordLocation myPredecessor

SIZE

private int SIZE
Constructor Detail

ChordNode

public ChordNode()

ChordNode

public ChordNode(ChordLocation loc)
Method Detail

addKey

public void addKey(byte[] key,
                   java.net.InetAddress nodeIP)
Parameters:
key -
nodeIP - Inserts the key,nodeIP pair into the map

fixKeys

public void fixKeys()

firstSuccessor

private ChordLocation firstSuccessor()

closestPreceedingNode

private ChordLocation closestPreceedingNode(ChordLocation id)

getLocation

public ChordLocation getLocation()

setPredecessor

public void setPredecessor(ChordLocation pnode)
Parameters:
pnode - predecessor

findSuccessor

public java.util.Vector findSuccessor(ChordLocation id)
                               throws java.net.UnknownHostException
Parameters:
id -
Returns:
returns Vector...first index is boolean (true if found the succ, fals otherwise) 2nd index is either the ChordLocation of the succ or an InetAddress of who forward on to
Throws:
java.net.UnknownHostException

getIP

public java.net.InetAddress getIP()
Returns:

getSuccessor

public ChordLocation getSuccessor()
Returns:

notify

public void notify(ChordLocation node)
Parameters:
node - node thinks it might be our predecessor

getPredecessor

public ChordLocation getPredecessor()
Returns:

create

public void create()

setSuccessor

public void setSuccessor(ChordLocation node)
Parameters:
node -

toString

public java.lang.String toString()

stabilize

public void stabilize(ChordLocation pofs)
Parameters:
pofs - -- my Successors' Predecssor

getModValue

private java.math.BigInteger getModValue()
Returns:
returns a BigInteger who is the modulo of the ring size (ie, 2^SIZE -1)...(it is minus 1 since has values range from 0 - 2^SIZE-1)

getSuccessorIP

public java.net.InetAddress getSuccessorIP()
Returns IP of sucessor.


buildFingers

public void buildFingers(ChordLocation n)
Parameters:
n -

modifyByteArray

private byte[] modifyByteArray(byte[] tempSumBytes)
Parameters:
tempSumBytes -
Returns:
returns a byte array who's indices are relevant to the appropriate hash (used strictly as a debugging tool for one byte)

BigIntLog

private int BigIntLog(java.math.BigInteger subtraction)
Parameters:
subtraction -
Returns:

refreshFingers

public void refreshFingers()

getFinger

public ChordLocation getFinger(int fingerPos)
Parameters:
fingerPos -
Returns:
the node in Fingers at position fingerPos

setFinger

public void setFinger(ChordLocation updatedLoc,
                      int fingerPos)
Parameters:
fingerPos - Sets the updatedNode in Fingers at position fingerPos

printFingers

public void printFingers()

printKeys

public void printKeys()

getMapping

public java.util.Iterator getMapping(byte[] key)
Parameters:
key -
Returns:
Iterator over Vector containg all IP's possessing that file

checkByteEquality

private boolean checkByteEquality(int[] b,
                                  int[] key)
Parameters:
b -
key -
Returns:
returns treu if b and key are equivalent

checkByteEquality

private boolean checkByteEquality(byte[] b,
                                  byte[] key)
Parameters:
b -
key -
Returns:
returns treu if b and key are equivalent

printVal

private java.lang.String printVal(byte[] b)
Parameters:
b -
Returns: