Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Incorporate simgrid-java in simgrid-java/.
[simgrid.git] / simgrid-java / examples / pingPong / Receiver.java
1 /*
2  * Copyright 2006-2012. The SimGrid Team. All rights reserved. 
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. 
6  */
7 package pingPong;
8 import org.simgrid.msg.Host;
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.MsgException;
11 import org.simgrid.msg.Task;
12 import org.simgrid.msg.Process;
13
14 public class Receiver extends Process {
15    public Receiver(Host host, String name, String[]args) {
16                 super(host,name,args);
17    } 
18    final double commSizeLat = 1;
19    final double commSizeBw = 100000000;
20     
21    public void main(String[] args) throws MsgException {
22         
23       Msg.info("hello!");
24       double communicationTime=0;
25
26       double time = Msg.getClock();
27     
28       Msg.info("try to get a task");
29         
30       PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
31       double timeGot = Msg.getClock();
32       double timeSent = task.getTime();
33             
34       Msg.info("Got at time "+ timeGot);
35       Msg.info("Was sent at time "+timeSent);
36       time=timeSent;
37             
38       communicationTime=timeGot - time;
39       Msg.info("Communication time : " + communicationTime);
40             
41       Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
42             
43       Msg.info("goodbye!");
44     }
45 }