Rice Pastry API

rice.pastry.direct
Class BasicNetworkSimulator<Identifier,MessageType>

java.lang.Object
  extended by rice.pastry.direct.BasicNetworkSimulator<Identifier,MessageType>
All Implemented Interfaces:
LivenessProvider<Identifier>, GenericNetworkSimulator<Identifier,MessageType>

public class BasicNetworkSimulator<Identifier,MessageType>
extends java.lang.Object
implements GenericNetworkSimulator<Identifier,MessageType>


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, RandomSource random)
           
 
Method Summary
 void addLivenessListener(LivenessListener<Identifier> name)
           
 boolean checkLiveness(Identifier i, java.util.Map<java.lang.String,java.lang.Integer> options)
          Returns wether a new notification will occur.
 void clearState(Identifier i)
          Force layer to clear the existing state related to the Identifier.
 Cancellable deliverMessage(MessageType msg, Identifier node, Identifier from)
          node should always be a local node, because this will be delivered instantly
 Cancellable deliverMessage(MessageType msg, Identifier node, Identifier from, int delay)
          Deliver message.
 Cancellable deliverMessage(MessageType msg, Identifier node, Identifier from, int delay, int period)
           
 Cancellable deliverMessageFixedRate(MessageType msg, Identifier node, Identifier from, int delay, int period)
           
 CancellableTask enqueueDelivery(Delivery d, int delay)
          Deliver message.
 Environment getEnvironment()
           
 int getLiveness(Identifier i, java.util.Map<java.lang.String,java.lang.Integer> options)
           
 NodeRecord getNodeRecord(DirectNodeHandle handle)
           
 RandomSource getRandomSource()
           
 DirectTransportLayer<Identifier,MessageType> getTL(Identifier i)
           
 boolean isAlive(Identifier i)
           
 float networkDelay(Identifier a, Identifier b)
          computes the one-way distance between two NodeIds
 float proximity(Identifier a, Identifier b)
          computes the rtt between two NodeIds
 void registerIdentifier(Identifier i, TransportLayer<Identifier,MessageType> dtl, NodeRecord record)
          set the liveliness of a NodeId
 void remove(Identifier i)
          Kill identifier.
 boolean removeLivenessListener(LivenessListener<Identifier> name)
           
 void setFullSpeed()
          unlimited maxSpeed
 void setMaxSpeed(float speed)
          The max rate of the simulator compared to realtime.
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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,
                             RandomSource random)
Method Detail

start

public void start()
Specified by:
start in interface GenericNetworkSimulator<Identifier,MessageType>

stop

public void stop()
Specified by:
stop in interface GenericNetworkSimulator<Identifier,MessageType>

enqueueDelivery

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

Specified by:
enqueueDelivery in interface GenericNetworkSimulator<Identifier,MessageType>

deliverMessage

public Cancellable deliverMessage(MessageType msg,
                                  Identifier node,
                                  Identifier from)
node should always be a local node, because this will be delivered instantly


deliverMessage

public Cancellable deliverMessage(MessageType msg,
                                  Identifier node,
                                  Identifier from,
                                  int delay)
Description copied from interface: GenericNetworkSimulator
Deliver message.

Specified by:
deliverMessage in interface GenericNetworkSimulator<Identifier,MessageType>
Parameters:
msg - message to deliver.

deliverMessageFixedRate

public Cancellable deliverMessageFixedRate(MessageType msg,
                                           Identifier node,
                                           Identifier from,
                                           int delay,
                                           int period)

deliverMessage

public Cancellable deliverMessage(MessageType msg,
                                  Identifier node,
                                  Identifier from,
                                  int delay,
                                  int period)

setMaxSpeed

public void setMaxSpeed(float speed)
Description copied from interface: GenericNetworkSimulator
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 GenericNetworkSimulator<Identifier,MessageType>

setFullSpeed

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

Specified by:
setFullSpeed in interface GenericNetworkSimulator<Identifier,MessageType>

registerIdentifier

public void registerIdentifier(Identifier i,
                               TransportLayer<Identifier,MessageType> dtl,
                               NodeRecord record)
set the liveliness of a NodeId

Parameters:
nid - the NodeId being set
alive - the value being set

remove

public void remove(Identifier i)
Description copied from interface: GenericNetworkSimulator
Kill identifier.

Specified by:
remove in interface GenericNetworkSimulator<Identifier,MessageType>

getEnvironment

public Environment getEnvironment()
Specified by:
getEnvironment in interface GenericNetworkSimulator<Identifier,MessageType>

getRandomSource

public RandomSource getRandomSource()
Specified by:
getRandomSource in interface GenericNetworkSimulator<Identifier,MessageType>

isAlive

public boolean isAlive(Identifier i)
Specified by:
isAlive in interface GenericNetworkSimulator<Identifier,MessageType>

getTL

public DirectTransportLayer<Identifier,MessageType> getTL(Identifier i)
Specified by:
getTL in interface GenericNetworkSimulator<Identifier,MessageType>

networkDelay

public float networkDelay(Identifier a,
                          Identifier b)
computes the one-way distance between two NodeIds

Specified by:
networkDelay in interface GenericNetworkSimulator<Identifier,MessageType>
Parameters:
a - the first NodeId
b - the second NodeId
Returns:
the proximity between the two input NodeIds

proximity

public float proximity(Identifier a,
                       Identifier b)
computes the rtt between two NodeIds

Parameters:
a - the first NodeId
b - the second NodeId
Returns:
the proximity between the two input NodeIds

getNodeRecord

public NodeRecord getNodeRecord(DirectNodeHandle handle)

addLivenessListener

public void addLivenessListener(LivenessListener<Identifier> name)
Specified by:
addLivenessListener in interface LivenessProvider<Identifier>

removeLivenessListener

public boolean removeLivenessListener(LivenessListener<Identifier> name)
Specified by:
removeLivenessListener in interface LivenessProvider<Identifier>

checkLiveness

public boolean checkLiveness(Identifier i,
                             java.util.Map<java.lang.String,java.lang.Integer> options)
Description copied from interface: LivenessProvider
Returns wether a new notification will occur. Will return false if a liveness check has recently completed. Will return true if a new liveness check starts, or an existing one is in progress.

Specified by:
checkLiveness in interface LivenessProvider<Identifier>
Parameters:
i - the node to check
Returns:
true if there will be an update (either a ping, or a change in liveness) false if there won't be an update due to bandwidth concernts

getLiveness

public int getLiveness(Identifier i,
                       java.util.Map<java.lang.String,java.lang.Integer> options)
Specified by:
getLiveness in interface LivenessProvider<Identifier>

clearState

public void clearState(Identifier i)
Description copied from interface: LivenessProvider
Force layer to clear the existing state related to the Identifier. Usually if there is reason to believe a node has returned.

Specified by:
clearState in interface LivenessProvider<Identifier>

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection