Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
java example simplification and cosmetics
[simgrid.git] / examples / java / app / 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 app.pingpong;
8 import org.simgrid.msg.HostNotFoundException;
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.MsgException;
11 import org.simgrid.msg.Process;
12 import org.simgrid.msg.Task;
13
14 public class Receiver extends Process {
15   private static final double COMM_SIZE_BW = 100000000;
16   public Receiver(String hostname, String name, String[]args) throws HostNotFoundException {
17     super(hostname, name, args);
18   }
19
20   public void main(String[] args) throws MsgException {
21     Msg.info("Wait for a task");
22
23     PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
24     double timeGot = Msg.getClock();
25     double timeSent = task.getTime();
26
27     Msg.info("Got one that was sent at time "+ timeSent);
28
29     double communicationTime = timeGot - timeSent;
30     Msg.info("Communication time : " + communicationTime);
31     Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
32     Msg.info("Done.");
33   }
34 }