Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rice.pastry.routing
Class RouteSet

    java.lang.Object
      rice.pastry.routing.RouteSet

All Implemented Interfaces:
  java.io.Serializable, java.util.Observer, NodeHandleSet, NodeSetI

    public class RouteSet

extends java.lang.Object
implements NodeSetI, java.io.Serializable, java.util.Observer

A set of nodes typically stored in the routing table. The set contains a bounded number of the closest node handles. Since proximity value can change unpredictably, we don't keep the set in sorted order.

Version:
  $Id: RouteSet.java 3801 2007-07-18 15:04:40Z jeffh $
Author:
  Andrew Ladd, Peter Druschel
See Also:
  Serialized Form

Field Summary
`static short` | `TYPE`

Constructor Summary
`RouteSet(InputBuffer buf, NodeHandleFactory nhf, PastryNode local)`
`RouteSet(int maxSize, int row, int col, PastryNode local)`
`RouteSet(int maxSize, int row, int col, PastryNode local, NodeHandle initialVal)` Constructor.

Method Summary
`int` | `capacity()`
`NodeHandle` | `closestNode()` Return the closest live node in the set.
`NodeHandle` | `closestNode(int minLiveness)` Return the closest live node in the set.
`void` | `destroy()`
`NodeHandle` | `get(Id nid)` Returns the node handle with the matching node id or null if none exists.
`NodeHandle` | `get(int i)` Returns the node in the ith position in the set.
`NodeHandle` | `getHandle(Id id)` Finds the NodeHandle associated with the Id.
`NodeHandle` | `getHandle(int i)` Gets the ith element in the set.
`int` | `getIndex(Id nid)` Get the index of the node id.
`int` | `getIndex(NodeHandle nh)` Get the index of the node id.
`int` | `getIndexHandle(Id id)` Gets the index of the element with the given node id.
`short` | `getType()`
`boolean` | `member(Id nid)` Membership test.
`boolean` | `member(NodeHandle nh)` Membership test.
`boolean` | `memberHandle(Id id)` Verifies if the set contains this particular id.
`void` | `pingAllNew()` Pings all new nodes in the RouteSet.
`boolean` | `put(NodeHandle handle)` Puts a node into the set.
`boolean` | `putHandle(NodeHandle handle)` Puts a NodeHandle into the set.
`NodeHandle` | `remove(Id nid)` Removes a node from a set.
`NodeHandle` | `remove(NodeHandle nh)` Removes a node from a set.
`NodeHandle` | `removeHandle(Id id)` Removes a node id and its handle from the set.
`void` | `serialize(OutputBuffer buf)` +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + maxSize + theSize + closest + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + NodeHandle 1st + ...
`void` | `setRoutingTable(RoutingTable rt)`
`int` | `size()` Return the current size of the set.
`java.lang.String` | `toString()`
`void` | `update(java.util.Observable o, java.lang.Object arg)` Is called by the Observer pattern whenever the liveness or proximity of a registered node handle is changed.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### TYPE

    public static final short TYPE

See Also:
  Constant Field Values

Constructor Detail

### RouteSet

    public RouteSet(int maxSize,
                    int row,
                    int col,
                    PastryNode local,
                    NodeHandle initialVal)

  Constructor.

  Parameters:
    `maxSize` - the maximum number of nodes that fit in this set.

### RouteSet

    public RouteSet(int maxSize,
                    int row,
                    int col,
                    PastryNode local)

### RouteSet

    public RouteSet(InputBuffer buf,
                    NodeHandleFactory nhf,
                    PastryNode local)
             throws java.io.IOException

Throws:
  `java.io.IOException`

Method Detail

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### put

    public boolean put(NodeHandle handle)

  Puts a node into the set. The insertion succeeds either if the set is below is maximal size or if the handle is closer than the most distant member in the set.

  Specified by:
    `put` in interface `NodeSetI`
  Parameters:
    `handle` - the handle to put.
  Returns:
    true if the put succeeded, false otherwise.

### update

    public void update(java.util.Observable o,
                       java.lang.Object arg)

  Is called by the Observer pattern whenever the liveness or proximity of a registered node handle is changed.

  Specified by:
    `update` in interface `java.util.Observer`
  Parameters:
    `o` - The node handle
    `arg` - the event type (PROXIMITY_CHANGE, DECLARED_LIVE, DECLARED_DEAD)

### remove

    public NodeHandle remove(Id nid)

  Removes a node from a set.

  Parameters:
    `nid` - the node id to remove.
  Returns:
    the removed handle or null.

### remove

    public NodeHandle remove(NodeHandle nh)

  Removes a node from a set.

  Specified by:
    `remove` in interface `NodeSetI`
  Parameters:
    `nid` - the node id to remove.
  Returns:
    the removed handle or null.

### setRoutingTable

    public void setRoutingTable(RoutingTable rt)

### member

    public boolean member(NodeHandle nh)

  Membership test.

  Specified by:
    `member` in interface `NodeSetI`
  Parameters:
    `nid` - the node id to membership of.
  Returns:
    true if it is a member, false otherwise.

### member

    public boolean member(Id nid)

  Membership test.

  Parameters:
    `nid` - the node id to membership of.
  Returns:
    true if it is a member, false otherwise.

### size

    public int size()

  Return the current size of the set.

  Specified by:
    `size` in interface `NodeHandleSet`
  Specified by:
    `size` in interface `NodeSetI`
  Returns:
    the size.

### capacity

    public int capacity()

### pingAllNew

    public void pingAllNew()

  Pings all new nodes in the RouteSet. No longer- Called from RouteMaintenance.

### closestNode

    public NodeHandle closestNode()

  Return the closest live node in the set.

  Returns:
    the closest node, or null if no live node exists in the set.

### closestNode

    public NodeHandle closestNode(int minLiveness)

  Return the closest live node in the set.

  Returns:
    the closest node, or null if no live node exists in the set.

### get

    public NodeHandle get(int i)

  Returns the node in the ith position in the set.

  Specified by:
    `get` in interface `NodeSetI`
  Parameters:
    `i` - an index.
  Returns:
    the ith node.

### get

    public NodeHandle get(Id nid)

  Returns the node handle with the matching node id or null if none exists.

  Specified by:
    `get` in interface `NodeSetI`
  Parameters:
    `nid` - the node id.
  Returns:
    the node handle.

### getIndex

    public int getIndex(Id nid)

  Get the index of the node id.

  Specified by:
    `getIndex` in interface `NodeSetI`
  Parameters:
    `nid` - the node id.
  Returns:
    the node.

### getIndex

    public int getIndex(NodeHandle nh)

  Get the index of the node id.

  Specified by:
    `getIndex` in interface `NodeSetI`
  Returns:
    the node.

### putHandle

    public boolean putHandle(NodeHandle handle)

  Puts a NodeHandle into the set.

  Specified by:
    `putHandle` in interface `NodeHandleSet`
  Parameters:
    `handle` - the handle to put.
  Returns:
    true if the put succeeded, false otherwise.

### getHandle

    public NodeHandle getHandle(Id id)

  Finds the NodeHandle associated with the Id.

  Specified by:
    `getHandle` in interface `NodeHandleSet`
  Parameters:
    `id` - a node id.
  Returns:
    the handle associated with that id or null if no such handle is found.

### getHandle

    public NodeHandle getHandle(int i)

  Gets the ith element in the set.

  Specified by:
    `getHandle` in interface `NodeHandleSet`
  Parameters:
    `i` - an index.
  Returns:
    the handle associated with that id or null if no such handle is found.

### memberHandle

    public boolean memberHandle(Id id)

  Verifies if the set contains this particular id.

  Specified by:
    `memberHandle` in interface `NodeHandleSet`
  Parameters:
    `id` - a node id.
  Returns:
    true if that node id is in the set, false otherwise.

### removeHandle

    public NodeHandle removeHandle(Id id)

  Removes a node id and its handle from the set.

  Specified by:
    `removeHandle` in interface `NodeHandleSet`
  Parameters:
    `nid` - the node to remove.
  Returns:
    the node handle removed or null if nothing.

### getIndexHandle

    public int getIndexHandle(Id id)
                       throws java.util.NoSuchElementException

  Gets the index of the element with the given node id.

  Specified by:
    `getIndexHandle` in interface `NodeHandleSet`
  Parameters:
    `id` - the id.
  Returns:
    the index or throws a NoSuchElementException.
  Throws:
    `java.util.NoSuchElementException`

### getType

    public short getType()

  Specified by:
    `getType` in interface `NodeHandleSet`

### serialize

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

  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + maxSize + theSize + closest + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + NodeHandle 1st + ... + + + + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + NodeHandle theSize-th + ... + + + + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

  Specified by:
    `serialize` in interface `NodeHandleSet`
  Throws:
    `java.io.IOException`

### destroy

    public void destroy()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.