Logo AND Algorithmique Numérique Distribuée

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