Logo AND Algorithmique Numérique Distribuée

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