Rice Pastry API

rice.pastry.direct
Interface NetworkSimulator

All Known Implementing Classes:
BasicNetworkSimulator, EuclideanNetwork, GenericNetwork, SphereNetwork

public interface NetworkSimulator

Interface to an object which is simulating the network.

Version:
$Id: NetworkSimulator.java 3524 2007-01-09 14:09:27Z jeffh $
Author:
Andrew Ladd

Method Summary
 boolean addSimulatorListener(SimulatorListener sl)
           
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node)
          Deliver message ASAP.
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node, int delay)
          Deliver message.
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node, int delay, int period)
          Deliver message.
 ScheduledMessage deliverMessageFixedRate(Message msg, DirectPastryNode node, int delay, int period)
          Deliver message.
 void destroy(DirectPastryNode dpn)
           
 CancellableTask enqueueDelivery(Delivery del, int delay)
          Deliver message.
 NodeRecord generateNodeRecord()
          Generates a random node record
 DirectNodeHandle getClosest(DirectNodeHandle nh)
          Returns the closest Node in proximity.
 Environment getEnvironment()
           
 TestRecord getTestRecord()
           
 boolean isAlive(DirectNodeHandle nh)
          Checks to see if a node id is alive.
 float networkDelay(DirectNodeHandle a, DirectNodeHandle b)
          Determines delivery time from a to b.
 void notifySimulatorListeners(Message m, NodeHandle from, NodeHandle to, int delay)
          Call this when a message is sent.
 float proximity(DirectNodeHandle a, DirectNodeHandle b)
          Determines rtt between two nodes.
 void registerNode(DirectPastryNode dpn)
          Registers a node handle with the simulator.
 void removeNode(DirectPastryNode node)
           
 boolean removeSimulatorListener(SimulatorListener sl)
           
 void setFullSpeed()
          unlimited maxSpeed
 void setMaxSpeed(float rate)
          The max rate of the simulator compared to realtime.
 void setTestRecord(TestRecord tr)
           
 void start()
           
 void stop()
           
 

Method Detail

getEnvironment

Environment getEnvironment()

registerNode

void registerNode(DirectPastryNode dpn)
Registers a node handle with the simulator.

Parameters:
nh - the node handle to register.

isAlive

boolean isAlive(DirectNodeHandle nh)
Checks to see if a node id is alive.

Parameters:
nid - a node id.
Returns:
true if alive, false otherwise.

proximity

float proximity(DirectNodeHandle a,
                DirectNodeHandle b)
Determines rtt between two nodes.

Parameters:
a - a node id.
b - another node id.
Returns:
proximity of b to a.

networkDelay

float networkDelay(DirectNodeHandle a,
                   DirectNodeHandle b)
Determines delivery time from a to b.

Parameters:
a - a node id.
b - another node id.
Returns:
proximity of b to a.

deliverMessage

ScheduledMessage deliverMessage(Message msg,
                                DirectPastryNode node,
                                int delay)
Deliver message.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
how - long to delay to deliver the message

deliverMessage

ScheduledMessage deliverMessage(Message msg,
                                DirectPastryNode node,
                                int delay,
                                int period)
Deliver message.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
how - long to delay to deliver the message
period - to deliver the message after the delay

deliverMessageFixedRate

ScheduledMessage deliverMessageFixedRate(Message msg,
                                         DirectPastryNode node,
                                         int delay,
                                         int period)
Deliver message.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
how - long to delay to deliver the message
period - to deliver the message after the delay

deliverMessage

ScheduledMessage deliverMessage(Message msg,
                                DirectPastryNode node)
Deliver message ASAP.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.

setTestRecord

void setTestRecord(TestRecord tr)

getTestRecord

TestRecord getTestRecord()

getClosest

DirectNodeHandle getClosest(DirectNodeHandle nh)
Returns the closest Node in proximity.

Parameters:
nid -
Returns:

destroy

void destroy(DirectPastryNode dpn)

generateNodeRecord

NodeRecord generateNodeRecord()
Generates a random node record

Returns:

removeNode

void removeNode(DirectPastryNode node)

start

void start()

stop

void stop()

enqueueDelivery

CancellableTask enqueueDelivery(Delivery del,
                                int delay)
Deliver message.

Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
how - long to delay to deliver the message
period - to deliver the message after the delay

setMaxSpeed

void setMaxSpeed(float rate)
The max rate of the simulator compared to realtime. The rule is that the simulated clock will not be set to a value greater than the factor from system-time that the call was made. Thus if 1 hour ago, you said the simulator should run at 10x realtime the simulated clock will only have advanced 10 hours. Note that if the simulator cannot keep up with the system clock in the early part, it may move faster than the value you set to "catch up" To prevent this speed-up from becoming unbounded, you may wish to call setMaxSpeed() periodically or immediately after periods of expensive calculations. Setting the simulation speed to zero will not pause the simulation, you must call stop() to do that.

Parameters:
the - multiple on realtime that the simulator is allowed to run at, zero or less will cause no bound on the simulation speed

setFullSpeed

void setFullSpeed()
unlimited maxSpeed


notifySimulatorListeners

void notifySimulatorListeners(Message m,
                              NodeHandle from,
                              NodeHandle to,
                              int delay)
Call this when a message is sent.

Parameters:
m - the message
from - the source
to - the destination
delay - the network proximity (when the message will be received)

addSimulatorListener

boolean addSimulatorListener(SimulatorListener sl)
Parameters:
sl -
Returns:
true if added, false if already a listener

removeSimulatorListener

boolean removeSimulatorListener(SimulatorListener sl)
Parameters:
sl -
Returns:
true if removed, false if not already a listener

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection