|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.simulate.Simulator
The simulator is the main class. It controls the events to execute them at the opportune moment, controls the nodes, while they join, go away, they fail, and handles to the messages and the message queues
Constructor Summary | |
Simulator(IScheduler timer)
Constructor, create a new simulation with a determinate event scheduler |
|
Simulator(IScheduler timer,
boolean load)
Constructor, create a new simulation with a determinate event scheduler and with indicated argument, will load a old state of simulation |
Method Summary | |
Node |
addNode(Id id,
Id bootstrap)
Create and joins a new node to the simulated network. |
void |
addNode(Node node,
Id bootstrap)
Joins a new node to the simulated network. |
java.util.HashMap |
getNodes()
Returns the HashMap structure of the all nodes |
Node |
getRandomNode(java.util.Random r)
Selects a node by a random number |
int |
getSizeRing()
Return the size of the network |
void |
parseEvents(java.util.Vector events)
Prepares all events to simulate from a events vector |
void |
parseFail(IEvent aEvent)
Prepares the fail event to simulate from a event interface |
void |
parseJoin(IEvent aEvent)
Prepares the join event to simulate from a event interface |
void |
parseLeave(IEvent aEvent)
Prepares the leave event to simulate from a event interface |
void |
parseLookup(IEvent aEvent)
Prepares the lookup event to simulate from a event interface |
void |
printNodes()
|
void |
removeNodes()
Removes the ready nodes to delete |
void |
run(int steps)
Executes the events at the opportune moment, controls the nodes, while they join, go away, they fail,and handles to the messages and the message queues |
void |
saveState()
Serialize the actual state. |
void |
send(Queue messages)
Takes all messages of queue and send to all destination nodes |
boolean |
simulate()
Executes step by step the events at the opportune moment, controls the nodes, while they join, go away, they fail,and handles to the messages and the message queues. |
void |
stop()
do nothing. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Simulator(IScheduler timer) throws InitializationException
timer
- Scheduler with the all events to simulateIScheduler
public Simulator(IScheduler timer, boolean load) throws java.io.IOException, java.io.FileNotFoundException, java.lang.ClassNotFoundException, InitializationException
timer
- Scheduler with the all events to simulateload
- if true, load a old stateIScheduler
Method Detail |
public void run(int steps) throws InitializationException
run
in interface ISimulator
steps
- number of steps that the simulation lasts
InitializationException
public void saveState()
public boolean simulate() throws InitializationException
InitializationException
public void addNode(Node node, Id bootstrap)
node
- New node to add to the network.bootstrap
- Id of the any node in the networkpublic void printNodes()
public Node addNode(Id id, Id bootstrap) throws InitializationException
id
- Id of the new nodebootstrap
- Id of the any node in the network
InitializationException
public void removeNodes()
public void parseEvents(java.util.Vector events) throws InitializationException
events
- Vector of events
InitializationException
public void parseJoin(IEvent aEvent) throws InitializationException
aEvent
- IEvent
InitializationException
IEvent
public void parseLeave(IEvent aEvent) throws InitializationException
aEvent
- IEvent
InitializationException
IEvent
public void parseLookup(IEvent aEvent) throws InitializationException
aEvent
- IEvent
InitializationException
IEvent
public void parseFail(IEvent aEvent) throws InitializationException
aEvent
- IEvent
InitializationException
IEvent
public void stop()
stop
in interface ISimulator
ISimulator.stop()
public void send(Queue messages)
messages
- Queue with messages to sendQueue
public Node getRandomNode(java.util.Random r)
r
- Random number
public int getSizeRing()
public java.util.HashMap getNodes()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |