rice.pastry.direct
Interface NetworkSimulator<Identifier,MessageType>
- All Known Implementing Classes:
- EuclideanNetwork, GenericNetwork, NetworkSimulatorImpl, SphereNetwork
public interface NetworkSimulator<Identifier,MessageType>
Interface to an object which is simulating the network.
- Version:
- $Id: NetworkSimulator.java 3926 2007-10-24 15:44:09Z jeffh $
- Author:
- Andrew Ladd
Method Summary |
boolean |
addSimulatorListener(SimulatorListener sl)
|
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()
|
GenericNetworkSimulator<Identifier,MessageType> |
getGenericSimulator()
|
LivenessProvider<Identifier> |
getLivenessProvider()
|
NodeRecord |
getNodeRecord(DirectNodeHandle handle)
|
TestRecord |
getTestRecord()
|
boolean |
isAlive(Identifier nh)
Checks to see if a node id is alive. |
float |
networkDelay(Identifier a,
Identifier b)
Determines delivery time from a to b. |
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(Identifier a,
Identifier b)
Determines rtt between two nodes. |
void |
registerNode(Identifier i,
DirectTransportLayer<Identifier,MessageType> dtl,
NodeRecord nr)
|
void |
removeNode(TLPastryNode node)
Registers a node handle with the simulator. |
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()
|
getEnvironment
Environment getEnvironment()
isAlive
boolean isAlive(Identifier nh)
- Checks to see if a node id is alive.
- Parameters:
nid
- a node id.
- Returns:
- true if alive, false otherwise.
proximity
float proximity(Identifier a,
Identifier b)
- Determines rtt between two nodes.
- Parameters:
a
- a node id.b
- another node id.
- Returns:
- proximity of b to a.
networkDelay
float networkDelay(Identifier a,
Identifier b)
- Determines delivery time from a to b.
- Parameters:
a
- a node id.b
- another node id.
- Returns:
- proximity of b to a.
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(TLPastryNode node)
- Registers a node handle with the simulator.
- Parameters:
nh
- the node handle to register.
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 messageperiod
- 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
notifySimulatorListenersSent
void notifySimulatorListenersSent(Message m,
NodeHandle from,
NodeHandle to,
int delay)
- Call this when a message is sent.
- Parameters:
m
- the messagefrom
- the sourceto
- the destinationdelay
- the network proximity (when the message will be received)
notifySimulatorListenersReceived
void notifySimulatorListenersReceived(Message m,
NodeHandle from,
NodeHandle to)
- Call this when a message is received.
- Parameters:
m
- the messagefrom
- the sourceto
- the destination
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
getNodeRecord
NodeRecord getNodeRecord(DirectNodeHandle handle)
getLivenessProvider
LivenessProvider<Identifier> getLivenessProvider()
getGenericSimulator
GenericNetworkSimulator<Identifier,MessageType> getGenericSimulator()
registerNode
void registerNode(Identifier i,
DirectTransportLayer<Identifier,MessageType> dtl,
NodeRecord nr)
Copyright © 2001-2005 - Rice Pastry.