3 import org.simgrid.msg.Host;
4 import org.simgrid.msg.MsgException;
6 import peersim.core.Node;
7 import peersim.edsim.EDProtocol;
10 * This class extends {@link org.simgrid.msg.Process} which creates a process
11 * for each host (corresponding to node in peersim) in the system.
13 * The main method of this class is to handle events received, by calling the
14 * processEvent method on the corresponding node and pid.
16 * See {@link peersim.edsim.EDProtocol#processEvent}
18 * @author Khaled Baati 28/10/2014
19 * @version version 1.1
21 public class PSGProcessEvent extends org.simgrid.msg.Process {
22 /** The delivered event **/
24 /** The current protocol **/
25 private EDProtocol prot;
26 /** The identifier of the current protocol **/
30 * Constructs a new process from the name of a host.
33 * the local host to create according to the active node in
38 * The arguments of main method of the process.
40 public PSGProcessEvent(Host host, String name, String[] args) {
41 super(host, name, args);
45 public void main(String[] args) throws MsgException {
46 Node node = NodeHost.getNode(getHost());
47 Host.setAsyncMailbox(getHost().getName());
48 while (PSGPlatform.getTime() < PSGPlatform.getDuration()) {
50 task = (PSGTask) PSGTask.receive(Host.currentHost().getName(),
51 PSGPlatform.psToSgTime(PSGPlatform.getDuration() - PSGPlatform.getTime()-1));
52 if (task != null && PSGPlatform.getTime() < PSGPlatform.getDuration()) {
54 prot = (EDProtocol) node.getProtocol(pid);
55 prot.processEvent(node, pid, task.getEvent());