Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Revalidate the tesh file
[simgrid.git] / examples / java / app / pingpong / Sender.java
1         /* Copyright (c) 2006-2014, 2016. 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.Host;
9 import org.simgrid.msg.HostNotFoundException;
10 import org.simgrid.msg.Msg;
11 import org.simgrid.msg.MsgException;
12 import org.simgrid.msg.Process;
13
14 public class Sender extends Process {
15   private static final double COMM_SIZE_LAT = 1;
16
17   public Sender(String hostname, String name, String[] args) throws HostNotFoundException {
18     super(hostname,name,args);
19   }
20
21   public void main(String[] args) throws MsgException {
22     Msg.info("hello!");
23
24     int hostCount = args.length;
25
26     Msg.info("host count: " + hostCount);
27     String[] mailboxes = new String[hostCount]; 
28     double time;
29     double computeDuration = 0;
30     PingPongTask task;
31
32     for(int pos = 0; pos < args.length ; pos++) {
33       try {
34         mailboxes[pos] = Host.getByName(args[pos]).getName();
35       } catch (HostNotFoundException e) {
36         e.printStackTrace();
37         Msg.info("Invalid deployment file: " + e.toString());
38       }
39     }
40
41     for (int pos = 0; pos < hostCount; pos++) { 
42       time = Msg.getClock(); 
43
44       Msg.info("sender time: " + time);
45
46       task = new PingPongTask("no name",computeDuration,COMM_SIZE_LAT);
47       task.setTime(time);
48
49       task.send(mailboxes[pos]);
50     }
51
52     Msg.info("goodbye!");
53   }
54 }