Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce Java debt (endless wip)
[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.Msg;
9 import org.simgrid.msg.Task;
10 import org.simgrid.msg.Process;
11 import org.simgrid.msg.MsgException;
12 import org.simgrid.msg.NativeException;
13 import org.simgrid.msg.HostNotFoundException;
14
15 public class Receiver extends Process {
16   private static final double COMM_SIZE_BW = 100000000;
17   public Receiver(String hostname, String name, String[]args) throws HostNotFoundException, NativeException{
18     super(hostname,name,args);
19   }
20
21   public void main(String[] args) throws MsgException {
22     Msg.info("hello!");
23
24     Msg.info("try to get a task");
25
26     PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
27     double timeGot = Msg.getClock();
28     double timeSent = task.getTime();
29
30     Msg.info("Got at time "+ timeGot);
31     Msg.info("Was sent at time "+timeSent);
32     double time = timeSent;
33
34     double communicationTime = timeGot - time;
35     Msg.info("Communication time : " + communicationTime);
36     Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
37     Msg.info("goodbye!");
38   }
39 }