oogp2p.chord
Class ChordLocation

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

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

ChordLocation. Adapted from Stuart Anderson's implementation of ChordLocation

See Also:
Serialized Form

Field Summary
private  java.lang.String IPAddr
           
private  byte[] key
           
private static java.security.MessageDigest md
           
static int NUM_HASH_BYTES
           
private  int port
           
 
Constructor Summary
  ChordLocation(byte[] bs)
           
(package private) ChordLocation(java.lang.String IP, int p)
          This is the basic constructor - it calculates the key for a node.
 
Method Summary
 java.lang.String addr()
          This selector returns the IP address of the node.
static int convbyte(byte b)
           
 java.lang.String displayIdAsBytes()
           
 boolean equals(ChordLocation l1)
          An equality test for locations.
static byte[] getHash(java.lang.String item)
           
 java.math.BigInteger getIdAsBigInt()
           
 byte[] id()
          This selector returns the value of the SHA key for the node.
 boolean isBetween(ChordLocation left, ChordLocation right)
           
 boolean lessThan(ChordLocation l1)
          Compare the keys of two locations....are you less than l1?
 int portNo()
          This selector returns the port number of the location.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IPAddr

private java.lang.String IPAddr

port

private int port

key

private byte[] key

NUM_HASH_BYTES

public static int NUM_HASH_BYTES

md

private static java.security.MessageDigest md
Constructor Detail

ChordLocation

ChordLocation(java.lang.String IP,
              int p)
This is the basic constructor - it calculates the key for a node.


ChordLocation

public ChordLocation(byte[] bs)
Parameters:
bs -
Method Detail

getHash

public static byte[] getHash(java.lang.String item)

id

public byte[] id()
This selector returns the value of the SHA key for the node.


addr

public java.lang.String addr()
This selector returns the IP address of the node.


portNo

public int portNo()
This selector returns the port number of the location.


convbyte

public static int convbyte(byte b)
Parameters:
b -
Returns:
converts byte b into an unsigned int

equals

public boolean equals(ChordLocation l1)
An equality test for locations.


displayIdAsBytes

public java.lang.String displayIdAsBytes()

lessThan

public boolean lessThan(ChordLocation l1)
Compare the keys of two locations....are you less than l1?


getIdAsBigInt

public java.math.BigInteger getIdAsBigInt()

isBetween

public boolean isBetween(ChordLocation left,
                         ChordLocation right)
Parameters:
left -
right -
Returns:
checks if l is between left and right (non-inclusive) with them being in a ring formation

toString

public java.lang.String toString()