Rice Pastry API

rice.p2p.past.gc
Class GCId

java.lang.Object
  extended byrice.p2p.past.gc.GCId
All Implemented Interfaces:
java.lang.Comparable, Id, java.io.Serializable

public class GCId
extends java.lang.Object
implements Id

Version:
$Id: GCId.java 3274 2006-05-15 16:17:47Z jeffh $
Author:
Alan Mislove
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class rice.p2p.commonapi.Id
Id.Distance
 
Field Summary
protected  long expiration
          The ringId which this ringId represents
protected  Id id
          The id which this ringId represents
static short TYPE
          DESCRIBE THE FIELD
 
Constructor Summary
GCId(Id id, long expiration)
          Constructor
GCId(InputBuffer buf, Endpoint endpoint)
          Constructor for GCId.
 
Method Summary
 Id addToId(Id.Distance offset)
          Returns an Id corresponding to this Id plus a given distance
 boolean clockwise(Id nid)
          Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring.
 int compareTo(java.lang.Object o)
          Returns this id compared to the target
 Id.Distance distanceFromId(Id nid)
          Returns the shorter numerical distance on the ring between a pair of Ids.
 boolean equals(java.lang.Object o)
          Returns whether or not this object is equal to the provided one
 int getByteArrayLength()
          Returns the length of the byte[] representing this Id
 long getExpiration()
          Returns this gcid's expiration time
 Id getId()
          Returns this gcid's id
 short getType()
          Raw Serialization **************************************
 int hashCode()
          Returns the hashCode
 boolean isBetween(Id ccw, Id cw)
          Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle
 Id.Distance longDistanceFromId(Id nid)
          Returns the longer numerical distance on the ring between a pair of Ids.
 void serialize(OutputBuffer buf)
          DESCRIBE THE METHOD
 byte[] toByteArray()
          Returns a (mutable) byte array representing this Id
 void toByteArray(byte[] array, int offset)
          Stores the byte[] value of this Id in the provided byte array
 java.lang.String toString()
          Returns a string representing this ring Id.
 java.lang.String toStringFull()
          Returns a string representing the full length of this Id.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected Id id
The id which this ringId represents


expiration

protected long expiration
The ringId which this ringId represents


TYPE

public static final short TYPE
DESCRIBE THE FIELD

See Also:
Constant Field Values
Constructor Detail

GCId

public GCId(Id id,
            long expiration)
Constructor

Parameters:
id - DESCRIBE THE PARAMETER
expiration - DESCRIBE THE PARAMETER

GCId

public GCId(InputBuffer buf,
            Endpoint endpoint)
     throws java.io.IOException
Constructor for GCId.

Parameters:
buf - DESCRIBE THE PARAMETER
endpoint - DESCRIBE THE PARAMETER
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION
Method Detail

getId

public Id getId()
Returns this gcid's id

Returns:
The id of this ringid

getExpiration

public long getExpiration()
Returns this gcid's expiration time

Returns:
The expiration time of this gcid

isBetween

public boolean isBetween(Id ccw,
                         Id cw)
Checks if this Id is between two given ids ccw (inclusive) and cw (exclusive) on the circle

Specified by:
isBetween in interface Id
Parameters:
ccw - the counterclockwise id
cw - the clockwise id
Returns:
true if this is between ccw (inclusive) and cw (exclusive), false otherwise

getByteArrayLength

public int getByteArrayLength()
Returns the length of the byte[] representing this Id

Specified by:
getByteArrayLength in interface Id
Returns:
The length of the byte[] representing this Id

getType

public short getType()
Raw Serialization **************************************

Specified by:
getType in interface Id
Returns:
The Type value

clockwise

public boolean clockwise(Id nid)
Checks to see if the Id nid is clockwise or counterclockwise from this, on the ring. An Id is clockwise if it is within the half circle clockwise from this on the ring. An Id is considered counter-clockwise from itself.

Specified by:
clockwise in interface Id
Parameters:
nid - The id to compare to
Returns:
true if clockwise, false otherwise.

addToId

public Id addToId(Id.Distance offset)
Returns an Id corresponding to this Id plus a given distance

Specified by:
addToId in interface Id
Parameters:
offset - the distance to add
Returns:
the new Id

distanceFromId

public Id.Distance distanceFromId(Id nid)
Returns the shorter numerical distance on the ring between a pair of Ids.

Specified by:
distanceFromId in interface Id
Parameters:
nid - the other node id.
Returns:
the distance between this and nid.

longDistanceFromId

public Id.Distance longDistanceFromId(Id nid)
Returns the longer numerical distance on the ring between a pair of Ids.

Specified by:
longDistanceFromId in interface Id
Parameters:
nid - the other node id.
Returns:
the distance between this and nid.

toByteArray

public byte[] toByteArray()
Returns a (mutable) byte array representing this Id

Specified by:
toByteArray in interface Id
Returns:
A byte[] representing this Id

toByteArray

public void toByteArray(byte[] array,
                        int offset)
Stores the byte[] value of this Id in the provided byte array

Specified by:
toByteArray in interface Id
Parameters:
array - DESCRIBE THE PARAMETER
offset - DESCRIBE THE PARAMETER

equals

public boolean equals(java.lang.Object o)
Returns whether or not this object is equal to the provided one

Parameters:
o - The object to compare to
Returns:
Whether or not this is object is equal

hashCode

public int hashCode()
Returns the hashCode

Returns:
hashCode

toString

public java.lang.String toString()
Returns a string representing this ring Id.

Returns:
A string with all of this Id

toStringFull

public java.lang.String toStringFull()
Returns a string representing the full length of this Id.

Specified by:
toStringFull in interface Id
Returns:
A string with all of this Id

compareTo

public int compareTo(java.lang.Object o)
Returns this id compared to the target

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - DESCRIBE THE PARAMETER
Returns:
The comparison

serialize

public void serialize(OutputBuffer buf)
               throws java.io.IOException
DESCRIBE THE METHOD

Specified by:
serialize in interface Id
Parameters:
buf - DESCRIBE THE PARAMETER
Throws:
java.io.IOException - DESCRIBE THE EXCEPTION

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection