Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / examples / deprecated / java / app / pingpong / Receiver.java
1 /* Copyright (c) 2006-2020. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 package app.pingpong;
7 import org.simgrid.msg.HostNotFoundException;
8 import org.simgrid.msg.Msg;
9 import org.simgrid.msg.MsgException;
10 import org.simgrid.msg.Process;
11 import org.simgrid.msg.Task;
12
13 public class Receiver extends Process {
14         private static final double COMM_SIZE_BW = 100000000;
15         public Receiver(String hostname, String name, String[]args) throws HostNotFoundException {
16                 super(hostname, name, args);
17         }
18
19         public void main(String[] args) throws MsgException {
20                 for (int i = 0 ; i < Main.TASK_COUNT; i++) {
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                 }
33                 Msg.info("Done.");
34         }
35 }