Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1b425851ada201b24f3617d711f3ba63817bd886
[simgrid.git] / examples / java / app / pingpong / Sender.java
1 /* Copyright (c) 2006-2018. 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("Host count: " + args.length);
22
23                 for (int i = 0 ; i<Main.TASK_COUNT; i++) {
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                                 Msg.info("sender time: " + time);
30
31                                 PingPongTask task = new PingPongTask("no name", /* Duration: 0 flops */ 0, COMM_SIZE_LAT, time);
32                                 task.send(hostname);
33                         }
34                 }
35                 Msg.info("Done.");
36         }
37 }