oogp2p.chord
Class ChordNode
java.lang.Object
oogp2p.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
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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
ChordNode
public ChordNode()
ChordNode
public ChordNode(ChordLocation loc)
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: