Rice Pastry API

rice.pastry.direct
Class BasicNetworkSimulator

java.lang.Object
  extended by rice.pastry.direct.BasicNetworkSimulator
All Implemented Interfaces:
NetworkSimulator
Direct Known Subclasses:
EuclideanNetwork, GenericNetwork, SphereNetwork

public abstract class BasicNetworkSimulator
extends java.lang.Object
implements NetworkSimulator


Field Summary
protected  Logger logger
           
protected  SelectorManager manager
           
protected  int maxDiameter
           
protected  int MIN_DELAY
           
protected  int minDelay
           
protected  RandomSource random
           
 
Constructor Summary
BasicNetworkSimulator(Environment env)
           
 
Method Summary
 boolean addSimulatorListener(SimulatorListener sl)
           
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node)
          node should always be a local node, because this will be delivered instantly
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node, DirectNodeHandle from, int delay)
          Deliver message.
 ScheduledMessage deliverMessage(Message msg, DirectPastryNode node, DirectNodeHandle from, int delay, int period)
          Deliver message.
 ScheduledMessage deliverMessageFixedRate(Message msg, DirectPastryNode node, DirectNodeHandle from, int delay, int period)
          Deliver message.
 void destroy(DirectPastryNode node)
          set the liveliness of a NodeId
 CancellableTask enqueueDelivery(Delivery d, int delay)
          Deliver message.
 DirectNodeHandle getClosest(DirectNodeHandle nh)
          find the closest NodeId to an input NodeId out of all NodeIds in the network
 Environment getEnvironment()
           
 TestRecord getTestRecord()
          get TestRecord
 boolean isAlive(DirectNodeHandle nh)
          testing if a NodeId is alive
 float networkDelay(DirectNodeHandle a, DirectNodeHandle b)
          computes the proximity between two NodeIds
 void notifySimulatorListenersReceived(Message m, NodeHandle from, NodeHandle to)
          Call this when a message is received.
 void notifySimulatorListenersSent(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 speed)
          The max rate of the simulator compared to realtime.
 void setTestRecord(TestRecord tr)
          set TestRecord
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface rice.pastry.direct.NetworkSimulator
generateNodeRecord
 

Field Detail

logger

protected Logger logger

random

protected RandomSource random

MIN_DELAY

protected int MIN_DELAY

manager

protected SelectorManager manager

maxDiameter

protected final int maxDiameter

minDelay

protected final int minDelay
Constructor Detail

BasicNetworkSimulator

public BasicNetworkSimulator(Environment env)
Method Detail

start

public void start()
Specified by:
start in interface NetworkSimulator

stop

public void stop()
Specified by:
stop in interface NetworkSimulator

getTestRecord

public TestRecord getTestRecord()
get TestRecord

Specified by:
getTestRecord in interface NetworkSimulator
Returns:
the returned TestRecord

setTestRecord

public void setTestRecord(TestRecord tr)
set TestRecord

Specified by:
setTestRecord in interface NetworkSimulator
Parameters:
tr - input TestRecord

enqueueDelivery

public CancellableTask enqueueDelivery(Delivery d,
                                       int delay)
Description copied from interface: NetworkSimulator
Deliver message.

Specified by:
enqueueDelivery in interface NetworkSimulator

deliverMessage

public ScheduledMessage deliverMessage(Message msg,
                                       DirectPastryNode node)
node should always be a local node, because this will be delivered instantly

Specified by:
deliverMessage in interface NetworkSimulator
Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.

deliverMessage

public ScheduledMessage deliverMessage(Message msg,
                                       DirectPastryNode node,
                                       DirectNodeHandle from,
                                       int delay)
Description copied from interface: NetworkSimulator
Deliver message.

Specified by:
deliverMessage in interface NetworkSimulator
Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.

deliverMessage

public ScheduledMessage deliverMessage(Message msg,
                                       DirectPastryNode node,
                                       DirectNodeHandle from,
                                       int delay,
                                       int period)
Description copied from interface: NetworkSimulator
Deliver message.

Specified by:
deliverMessage in interface NetworkSimulator
Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
period - to deliver the message after the delay

deliverMessageFixedRate

public ScheduledMessage deliverMessageFixedRate(Message msg,
                                                DirectPastryNode node,
                                                DirectNodeHandle from,
                                                int delay,
                                                int period)
Description copied from interface: NetworkSimulator
Deliver message.

Specified by:
deliverMessageFixedRate in interface NetworkSimulator
Parameters:
msg - message to deliver.
node - the Pastry node to deliver it to.
period - to deliver the message after the delay

setMaxSpeed

public void setMaxSpeed(float speed)
Description copied from interface: NetworkSimulator
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.

Specified by:
setMaxSpeed in interface NetworkSimulator

setFullSpeed

public void setFullSpeed()
Description copied from interface: NetworkSimulator
unlimited maxSpeed

Specified by:
setFullSpeed in interface NetworkSimulator

isAlive

public boolean isAlive(DirectNodeHandle nh)
testing if a NodeId is alive

Specified by:
isAlive in interface NetworkSimulator
Parameters:
nid - the NodeId being tested
Returns:
true if nid is alive false otherwise

destroy

public void destroy(DirectPastryNode node)
set the liveliness of a NodeId

Specified by:
destroy in interface NetworkSimulator
Parameters:
nid - the NodeId being set
alive - the value being set

networkDelay

public float networkDelay(DirectNodeHandle a,
                          DirectNodeHandle b)
computes the proximity between two NodeIds

Specified by:
networkDelay in interface NetworkSimulator
Parameters:
a - the first NodeId
b - the second NodeId
Returns:
the proximity between the two input NodeIds

proximity

public float proximity(DirectNodeHandle a,
                       DirectNodeHandle b)
Description copied from interface: NetworkSimulator
Determines rtt between two nodes.

Specified by:
proximity in interface NetworkSimulator
Parameters:
a - a node id.
b - another node id.
Returns:
proximity of b to a.

getClosest

public DirectNodeHandle getClosest(DirectNodeHandle nh)
find the closest NodeId to an input NodeId out of all NodeIds in the network

Specified by:
getClosest in interface NetworkSimulator
Parameters:
nid - the input NodeId
Returns:
the NodeId closest to the input NodeId in the network

registerNode

public void registerNode(DirectPastryNode dpn)
Description copied from interface: NetworkSimulator
Registers a node handle with the simulator.

Specified by:
registerNode in interface NetworkSimulator

removeNode

public void removeNode(DirectPastryNode node)
Specified by:
removeNode in interface NetworkSimulator

getEnvironment

public Environment getEnvironment()
Specified by:
getEnvironment in interface NetworkSimulator

addSimulatorListener

public boolean addSimulatorListener(SimulatorListener sl)
Specified by:
addSimulatorListener in interface NetworkSimulator
Returns:
true if added, false if already a listener

removeSimulatorListener

public boolean removeSimulatorListener(SimulatorListener sl)
Specified by:
removeSimulatorListener in interface NetworkSimulator
Returns:
true if removed, false if not already a listener

notifySimulatorListenersSent

public void notifySimulatorListenersSent(Message m,
                                         NodeHandle from,
                                         NodeHandle to,
                                         int delay)
Description copied from interface: NetworkSimulator
Call this when a message is sent.

Specified by:
notifySimulatorListenersSent in interface NetworkSimulator
Parameters:
m - the message
from - the source
to - the destination
delay - the network proximity (when the message will be received)

notifySimulatorListenersReceived

public void notifySimulatorListenersReceived(Message m,
                                             NodeHandle from,
                                             NodeHandle to)
Description copied from interface: NetworkSimulator
Call this when a message is received.

Specified by:
notifySimulatorListenersReceived in interface NetworkSimulator
Parameters:
m - the message
from - the source
to - the destination

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection