Logo AND Algorithmique Numérique Distribuée

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