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.standard
Class StandardRouter

    java.lang.Object
      rice.pastry.client.PastryAppl
          rice.pastry.standard.StandardRouter

All Implemented Interfaces:
  Router

Direct Known Subclasses:
  RapidRerouter

    public class StandardRouter

extends PastryAppl
implements Router

An implementation of the standard Pastry routing algorithm.

Version:
  $Id: StandardRouter.java 4147 2008-03-11 11:08:22Z jeffh $
Author:
  Andrew Ladd, Rongmei Zhang/Y.Charlie Hu

Field Summary
`protected java.util.Map<NodeHandle,java.lang.Long>` | `lastTimeSentRouteTablePatch` We can end up causing a nasty feedback if we blast too many BRRs, so we're going to throttle.
`protected int` | `ROUTE_TABLE_PATCH_THROTTLE`
`protected RouterStrategy` | `routerStrategy`

Fields inherited from class rice.pastry.client.PastryAppl
`address, deserializer, instance, logger, options, receiver, thePastryNode`

Constructor Summary
`StandardRouter(PastryNode thePastryNode, MessageDispatch dispatch)` Constructor.
`StandardRouter(PastryNode thePastryNode, MessageDispatch dispatch, RouterStrategy strategy)`

Method Summary
`void` | `deliverToApplication(RouteMessage msg)`
`boolean` | `deliverWhenNotReady()` Instructs the MessageDispatch how to behave when the PastryNode is not ready.
`java.util.Iterator<NodeHandle>` | `getBestRoutingCandidates(Id target)` Returns an ordered list of the best candidates for the next to the key.
`protected java.util.Iterator<NodeHandle>` | `getBestRoutingCandidates(Id target, int lsPos, boolean leafSetOnly)`
`protected java.util.ArrayList<NodeHandle>` | `getLSCollection(int lsPos)`
`void` | `messageForAppl(Message msg)` Called by pastry when a message arrives for this application.
`void` | `receiveMessage(Message msg)` Receive a message from a remote node.
`void` | `route(RouteMessage rm)` Send the RouteMessage based on the Pastry Algorithm
`boolean` | `routeMessage(RouteMessage rm)` Routes the messages if the next hop has been set up.
`protected void` | `sendTheMessage(RouteMessage rm, NodeHandle handle)`
`void` | `setRouterStrategy(RouterStrategy strategy)`

Methods inherited from class rice.pastry.client.PastryAppl
`accept, canReceiveSocket, connect, destroy, enrouteMessage, finishReceiveSocket, getAddress, getDeserializer, getLeafSet, getNodeHandle, getNodeId, getRoutingTable, isClosest, leafSetChange, notifyReady, receiveMessageInternal, register, routeMsg, routeMsg, routeMsgDirect, routeSetChange, setDeserializer`

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

Field Detail

### routerStrategy

    protected RouterStrategy routerStrategy

### ROUTE_TABLE_PATCH_THROTTLE

    protected int ROUTE_TABLE_PATCH_THROTTLE

### lastTimeSentRouteTablePatch

    protected java.util.Map<NodeHandle,java.lang.Long> lastTimeSentRouteTablePatch

  We can end up causing a nasty feedback if we blast too many BRRs, so we're going to throttle.

Constructor Detail

### StandardRouter

    public StandardRouter(PastryNode thePastryNode,
                          MessageDispatch dispatch)

  Constructor.

  Parameters:
    `rt` - the routing table.
    `ls` - the leaf set.

### StandardRouter

    public StandardRouter(PastryNode thePastryNode,
                          MessageDispatch dispatch,
                          RouterStrategy strategy)

Method Detail

### setRouterStrategy

    public void setRouterStrategy(RouterStrategy strategy)

### receiveMessage

    public void receiveMessage(Message msg)

  Receive a message from a remote node.

  Overrides:
    `receiveMessage` in class `PastryAppl`
  Parameters:
    `msg` - the message.

### route

    public void route(RouteMessage rm)

  Description copied from interface: `Router`
  Send the RouteMessage based on the Pastry Algorithm

  Specified by:
    `route` in interface `Router`

### routeMessage

    public boolean routeMessage(RouteMessage rm)

  Routes the messages if the next hop has been set up. Note, this once lived in the RouteMessaage

  Parameters:
    `localId` - the node id of the local node.
  Returns:
    true if the message got routed, false otherwise.

### sendTheMessage

    protected void sendTheMessage(RouteMessage rm,
                                  NodeHandle handle)

### getBestRoutingCandidates

    public java.util.Iterator<NodeHandle> getBestRoutingCandidates(Id target)

  Description copied from interface: `Router`
  Returns an ordered list of the best candidates for the next to the key. Always starts with a node that matches an additional prefix, if it is available.

  Specified by:
    `getBestRoutingCandidates` in interface `Router`
  Parameters:
    `msg` - the message to setNextHop() on
    `target` - the destination Id
    `lsPos` - the best leafSet candidate
  Returns:

### getBestRoutingCandidates

    protected java.util.Iterator<NodeHandle> getBestRoutingCandidates(Id target,
                                                                      int lsPos,
                                                                      boolean leafSetOnly)

### getLSCollection

    protected java.util.ArrayList<NodeHandle> getLSCollection(int lsPos)

### deliverToApplication

    public void deliverToApplication(RouteMessage msg)

### deliverWhenNotReady

    public boolean deliverWhenNotReady()

  Description copied from class: `PastryAppl`
  Instructs the MessageDispatch how to behave when the PastryNode is not ready. An application can override this method to return true if it wishes to receive messages before Pastry is ready(). Most applications should leave this as false, so that their application does not have inconsistent routing. However Pastry's protocols (such as the join protocol) need to receive messages before pastry is ready(). This is because they are attempting to make pastry ready().

  Overrides:
    `deliverWhenNotReady` in class `PastryAppl`
  Returns:
    false unless the node is a service

### messageForAppl

    public void messageForAppl(Message msg)

  Description copied from class: `PastryAppl`
  Called by pastry when a message arrives for this application.

  Specified by:
    `messageForAppl` in class `PastryAppl`
  Parameters:
    `msg` - the message that is arriving.

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.