peersim.pastry
Class LeafSet

java.lang.Object
  extended by peersim.pastry.LeafSet
All Implemented Interfaces:
java.lang.Cloneable

public class LeafSet
extends java.lang.Object
implements java.lang.Cloneable

LeafSet class encapsulate functionalities of a Leaf Set table in a Pastry Node, allowing automatic "intellingent" adding of the entries, and facilitating extraction of information

Title: MSPASTRY

Description: MsPastry implementation for PeerSim

Copyright: Copyright (c) 2007

Company: The Pastry Group


Field Summary
static int BIN
          shortcut to base-representation specifier
static int DEC
          shortcut to base-representation specifier
static int HEX
          shortcut to base-representation specifier
 int hsize
          size of both left and right part of the leaf set.
static int NIB
          shortcut to base-representation specifier
 java.math.BigInteger nodeId
          pivot nodeId, this is needed in order to know how to organize adding/positioning/searching of the entries of the leaf set
 
Constructor Summary
LeafSet(java.math.BigInteger myNodeId, int size)
          Creates a new Leaf Set by pivoting it with the specified nodeId, and with the desired size of the vector.
LeafSet(long myNodeId, int size)
          shortcut constructor to use integers instead of BigIntegers.
 
Method Summary
 java.lang.Object clone()
          produces an exact deep clone of this Object, everything is copied
 boolean containsNodeId(java.math.BigInteger node)
          returns true iff whe specified node is found in the table
 boolean encompass(java.math.BigInteger k)
          returns true if key is between the leftmost and the rightmost.
 java.math.BigInteger[] listAllNodes()
          Outputs an (ordered, from min to max) array of all nodes in the leaf set.
 void push(java.math.BigInteger newNode)
          push into the leafset the specified node, by according the properties specified by the mspastry protocol
 void push(long newNode)
          shortcut for push(new BigInteger(""+newNode));
 boolean removeNodeId(java.math.BigInteger b)
          permanently removes the specified NodeId from this Leaf Set.
 java.lang.String toString()
          Outputs a representation of this leafset in the form:
[L3;L2;L1;L0]pivot[R0;R1;R2;R3]
each entry is represented only partially, to allow a shorter represantation (i.e.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hsize

public int hsize
size of both left and right part of the leaf set.


nodeId

public java.math.BigInteger nodeId
pivot nodeId, this is needed in order to know how to organize adding/positioning/searching of the entries of the leaf set


HEX

public static final int HEX
shortcut to base-representation specifier

See Also:
Constant Field Values

DEC

public static final int DEC
shortcut to base-representation specifier

See Also:
Constant Field Values

NIB

public static final int NIB
shortcut to base-representation specifier

See Also:
Constant Field Values

BIN

public static final int BIN
shortcut to base-representation specifier

See Also:
Constant Field Values
Constructor Detail

LeafSet

public LeafSet(long myNodeId,
               int size)
shortcut constructor to use integers instead of BigIntegers.

Parameters:
myNodeId - long
size - int

LeafSet

public LeafSet(java.math.BigInteger myNodeId,
               int size)
Creates a new Leaf Set by pivoting it with the specified nodeId, and with the desired size of the vector. Half of the size will be used to store nodes lessed than the pivot nodeId, the other half for the greater entries. Note: is size is an odd number, (size+1) will always be considered

Parameters:
myNodeId - BigInteger the pivot nodeId of the leafset, i.e. the nodeid of the pastry node owner
size - int must be > 0, and possibily an even number
Method Detail

removeNodeId

public boolean removeNodeId(java.math.BigInteger b)
permanently removes the specified NodeId from this Leaf Set.

Parameters:
b - BigInteger
Returns:
boolean true is some element is removed, false if the element does not exists

push

public void push(long newNode)
shortcut for push(new BigInteger(""+newNode));

Parameters:
newNode - long

push

public void push(java.math.BigInteger newNode)
push into the leafset the specified node, by according the properties specified by the mspastry protocol

Parameters:
newNode - long

containsNodeId

public boolean containsNodeId(java.math.BigInteger node)
returns true iff whe specified node is found in the table

Parameters:
node - BigInteger
Returns:
boolean

encompass

public boolean encompass(java.math.BigInteger k)
returns true if key is between the leftmost and the rightmost. it does not require that key is contained in the table, only requires that the key is greater-equal than the min nodeid stored and lesser-equal than the max nodeid stored. Note: this.ls.encompass(this.ls.nodeid) always returns true, in all cases.

Parameters:
k - BigInteger
Returns:
boolean

listAllNodes

public java.math.BigInteger[] listAllNodes()
Outputs an (ordered, from min to max) array of all nodes in the leaf set. The actual pivot nodeid is not included.

Returns:
BigInteger[]

clone

public java.lang.Object clone()
produces an exact deep clone of this Object, everything is copied

Overrides:
clone in class java.lang.Object
Returns:
Object

toString

public java.lang.String toString()
Outputs a representation of this leafset in the form:
[L3;L2;L1;L0]pivot[R0;R1;R2;R3]
each entry is represented only partially, to allow a shorter represantation (i.e. is cut after the 4th cipher, e.g.: "4eb0-")

Overrides:
toString in class java.lang.Object
Returns:
String