Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
java example simplification + reindent + cosmetics
[simgrid.git] / examples / java / app / pingpong / Sender.java
1 /* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 package app.pingpong;
7 import org.simgrid.msg.Host;
8 import org.simgrid.msg.HostNotFoundException;
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.MsgException;
11 import org.simgrid.msg.Process;
12
13 public class Sender extends Process {
14         private static final double COMM_SIZE_LAT = 1;
15
16         public Sender(String hostname, String name, String[] args) throws HostNotFoundException {
17                 super(hostname,name,args);
18         }
19
20         public void main(String[] args) throws MsgException {
21                 Msg.info("hello!");
22
23                 Msg.info("host count: " + args.length);
24
25                 for(int pos = 0; pos < args.length ; pos++) {
26                         String hostname = Host.getByName(args[pos]).getName(); // Make sure that this host exists
27                         
28                         double time = Msg.getClock(); 
29
30                         Msg.info("sender time: " + time);
31
32                         PingPongTask task = new PingPongTask("no name", /* Duration: 0 flops */ 0, COMM_SIZE_LAT, time);
33
34                         task.send(hostname);
35                 }
36
37                 Msg.info("goodbye!");
38         }
39 }