Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
inline another useless function
[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("hello!");
22
23     Msg.info("try to get a task");
24
25     PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
26     double timeGot = Msg.getClock();
27     double timeSent = task.getTime();
28
29     Msg.info("Got at time "+ timeGot);
30     Msg.info("Was sent at time "+timeSent);
31     double time = timeSent;
32
33     double communicationTime = timeGot - time;
34     Msg.info("Communication time : " + communicationTime);
35     Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
36     Msg.info("goodbye!");
37   }
38 }