Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #2 from mquinson/master
[simgrid.git] / examples / java / pingPong / Receiver.java
1 /* Copyright (c) 2006-2014. The SimGrid Team.
2  * 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.Msg;
9 import org.simgrid.msg.Host;
10 import org.simgrid.msg.Task;
11 import org.simgrid.msg.Process;
12 import org.simgrid.msg.MsgException;
13
14 public class Receiver extends Process {
15   final double commSizeLat = 1;
16   final double commSizeBw = 100000000;
17   public Receiver(Host host, String name, String[]args) {
18     super(host,name,args);
19   }
20
21   public void main(String[] args) throws MsgException {
22     Msg.info("hello!");
23     double communicationTime=0;
24
25     double time = Msg.getClock();
26
27     Msg.info("try to get a task");
28
29     PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
30     double timeGot = Msg.getClock();
31     double timeSent = task.getTime();
32
33     Msg.info("Got at time "+ timeGot);
34     Msg.info("Was sent at time "+timeSent);
35     time=timeSent;
36
37     communicationTime=timeGot - time;
38     Msg.info("Communication time : " + communicationTime);
39     Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
40     Msg.info("goodbye!");
41   }
42 }