Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Acknoledge the fact that JniException is a runtime exception now: kill all its occure...
[simgrid.git] / examples / java / ping_pong / Sender.java
1 /*
2  * Sender of basic ping/pong example
3  *
4  * Copyright 2006,2007,2010 The SimGrid Team. All rights reserved. 
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. 
8  */
9
10 import simgrid.msg.*;
11
12 public class Sender extends simgrid.msg.Process {
13   
14     private final double commSizeLat = 1;
15     final double commSizeBw = 100000000;
16    
17     public void main(String[] args) throws NativeException {
18         
19        Msg.info("hello!");
20         
21        int hostCount = args.length;
22         
23        Msg.info("host count: " + hostCount);
24        String mailboxes[] = new String[hostCount]; 
25        double time;
26        double computeDuration = 0;
27        PingPongTask task;
28         
29        for(int pos = 0; pos < args.length ; pos++) {
30           try {
31              mailboxes[pos] = Host.getByName(args[pos]).getName();
32           } catch (HostNotFoundException e) {
33              Msg.info("Invalid deployment file: " + e.toString());           
34              System.exit(1);
35           }
36         }
37         
38         for (int pos = 0; pos < hostCount; pos++) { 
39            time = Msg.getClock(); 
40             
41            Msg.info("sender time: " + time);
42            
43            task = new PingPongTask("no name",computeDuration,commSizeLat);
44            task.setTime(time);
45             
46            task.send(mailboxes[pos]);
47         } 
48         
49         Msg.info("goodbye!");
50     }
51 }