rice.pastry.direct
Class NetworkSimulatorImpl<Identifier,MessageType>
java.lang.Object
rice.pastry.direct.NetworkSimulatorImpl<Identifier,MessageType>
- All Implemented Interfaces:
- NetworkSimulator<Identifier,MessageType>
- Direct Known Subclasses:
- EuclideanNetwork, GenericNetwork, SphereNetwork
public class NetworkSimulatorImpl<Identifier,MessageType>
- extends java.lang.Object
- implements NetworkSimulator<Identifier,MessageType>
|
Method Summary |
boolean |
addSimulatorListener(GenericSimulatorListener<Identifier,MessageType> 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()
get TestRecord |
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(MessageType m,
Identifier from,
Identifier to)
Call this when a message is received. |
void |
notifySimulatorListenersSent(MessageType m,
Identifier from,
Identifier 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(PastryNode node)
Registers a node handle with the simulator. |
boolean |
removeSimulatorListener(GenericSimulatorListener<Identifier,MessageType> sl)
|
void |
setFullSpeed()
unlimited maxSpeed |
void |
setMaxSpeed(float rate)
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 |
simulator
protected BasicNetworkSimulator<Identifier,MessageType> simulator
random
protected RandomSource random
generator
protected ProximityGenerator generator
livenessProvider
protected LivenessProvider<Identifier> livenessProvider
NetworkSimulatorImpl
public NetworkSimulatorImpl(Environment env,
ProximityGenerator generator)
getEnvironment
public Environment getEnvironment()
- Specified by:
getEnvironment in interface NetworkSimulator<Identifier,MessageType>
setFullSpeed
public void setFullSpeed()
- Description copied from interface:
NetworkSimulator
- unlimited maxSpeed
- Specified by:
setFullSpeed in interface NetworkSimulator<Identifier,MessageType>
setMaxSpeed
public void setMaxSpeed(float rate)
- 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<Identifier,MessageType>
start
public void start()
- Specified by:
start in interface NetworkSimulator<Identifier,MessageType>
stop
public void stop()
- Specified by:
stop in interface NetworkSimulator<Identifier,MessageType>
getTestRecord
public TestRecord getTestRecord()
- get TestRecord
- Specified by:
getTestRecord in interface NetworkSimulator<Identifier,MessageType>
- Returns:
- the returned TestRecord
setTestRecord
public void setTestRecord(TestRecord tr)
- set TestRecord
- Specified by:
setTestRecord in interface NetworkSimulator<Identifier,MessageType>
- Parameters:
tr - input TestRecord
addSimulatorListener
public boolean addSimulatorListener(GenericSimulatorListener<Identifier,MessageType> sl)
- Specified by:
addSimulatorListener in interface NetworkSimulator<Identifier,MessageType>
- Returns:
- true if added, false if already a listener
removeSimulatorListener
public boolean removeSimulatorListener(GenericSimulatorListener<Identifier,MessageType> sl)
- Specified by:
removeSimulatorListener in interface NetworkSimulator<Identifier,MessageType>
- Returns:
- true if removed, false if not already a listener
notifySimulatorListenersSent
public void notifySimulatorListenersSent(MessageType m,
Identifier from,
Identifier to,
int delay)
- Description copied from interface:
NetworkSimulator
- Call this when a message is sent.
- Specified by:
notifySimulatorListenersSent in interface NetworkSimulator<Identifier,MessageType>
- Parameters:
m - the messagefrom - the sourceto - the destinationdelay - the network proximity (when the message will be received)
notifySimulatorListenersReceived
public void notifySimulatorListenersReceived(MessageType m,
Identifier from,
Identifier to)
- Description copied from interface:
NetworkSimulator
- Call this when a message is received.
- Specified by:
notifySimulatorListenersReceived in interface NetworkSimulator<Identifier,MessageType>
- Parameters:
m - the messagefrom - the sourceto - the destination
destroy
public void destroy(DirectPastryNode dpn)
- Specified by:
destroy in interface NetworkSimulator<Identifier,MessageType>
enqueueDelivery
public CancellableTask enqueueDelivery(Delivery del,
int delay)
- Description copied from interface:
NetworkSimulator
- Deliver message.
- Specified by:
enqueueDelivery in interface NetworkSimulator<Identifier,MessageType>
generateNodeRecord
public NodeRecord generateNodeRecord()
- Description copied from interface:
NetworkSimulator
- Generates a random node record
- Specified by:
generateNodeRecord in interface NetworkSimulator<Identifier,MessageType>
- Returns:
getClosest
public DirectNodeHandle getClosest(DirectNodeHandle nh)
- Description copied from interface:
NetworkSimulator
- Returns the closest Node in proximity.
- Specified by:
getClosest in interface NetworkSimulator<Identifier,MessageType>
- Returns:
isAlive
public boolean isAlive(Identifier nh)
- Description copied from interface:
NetworkSimulator
- Checks to see if a node id is alive.
- Specified by:
isAlive in interface NetworkSimulator<Identifier,MessageType>
- Returns:
- true if alive, false otherwise.
networkDelay
public float networkDelay(Identifier a,
Identifier b)
- Description copied from interface:
NetworkSimulator
- Determines delivery time from a to b.
- Specified by:
networkDelay in interface NetworkSimulator<Identifier,MessageType>
- Parameters:
a - a node id.b - another node id.
- Returns:
- proximity of b to a.
proximity
public float proximity(Identifier a,
Identifier b)
- Description copied from interface:
NetworkSimulator
- Determines rtt between two nodes.
- Specified by:
proximity in interface NetworkSimulator<Identifier,MessageType>
- Parameters:
a - a node id.b - another node id.
- Returns:
- proximity of b to a.
removeNode
public void removeNode(PastryNode node)
- Description copied from interface:
NetworkSimulator
- Registers a node handle with the simulator.
- Specified by:
removeNode in interface NetworkSimulator<Identifier,MessageType>
getNodeRecord
public NodeRecord getNodeRecord(DirectNodeHandle handle)
- Specified by:
getNodeRecord in interface NetworkSimulator<Identifier,MessageType>
getLivenessProvider
public LivenessProvider<Identifier> getLivenessProvider()
- Specified by:
getLivenessProvider in interface NetworkSimulator<Identifier,MessageType>
getGenericSimulator
public GenericNetworkSimulator<Identifier,MessageType> getGenericSimulator()
- Specified by:
getGenericSimulator in interface NetworkSimulator<Identifier,MessageType>
registerNode
public void registerNode(Identifier i,
DirectTransportLayer<Identifier,MessageType> dtl,
NodeRecord nr)
- Specified by:
registerNode in interface NetworkSimulator<Identifier,MessageType>
Copyright © 2001-2005 - Rice Pastry.