Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add (empty) ChangeLog entry for release 3.10.
[simgrid.git] / examples / pingPong / Sender.java
1 /*
2  * Copyright 2006-2012. The SimGrid Team. 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.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         public Sender(Host host, String name, String[] args) {
16                 super(host,name,args);
17         }
18     private final double commSizeLat = 1;
19     final double commSizeBw = 100000000;
20    
21     public void main(String[] args) throws MsgException {
22         
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 }