Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / examples / java / async / dsend / Sender.java
1 /* Copyright (c) 2006-2019. The SimGrid Team.
2  * 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 async.dsend;
8
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.Host;
11 import org.simgrid.msg.Task;
12 import org.simgrid.msg.Process;
13 import org.simgrid.msg.MsgException;
14
15 public class Sender extends Process {
16   public Sender (Host host, String name){
17     super(host,name);
18   }
19
20   @Override
21   public void main(String[] args) throws MsgException {
22     double taskComputeSize =0;
23     double taskCommunicateSize = 5000000;
24     Host[] hosts = Host.all();
25     int receiverCount = hosts.length - 1;
26
27     Msg.info("Hello! Got "+ receiverCount + " receivers to contact");
28
29     for (int i = 1; i <= receiverCount; i++) {
30       Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize); 
31       Msg.info("Sending \"" + task.getName()+ "\" to \"" + hosts[i].getName() + "\"");
32       task.dsend(hosts[i].getName());
33     }
34
35     Msg.info("All tasks have been (asynchronously) dispatched."+
36              " Let's sleep for 20s so that nobody gets a message from a terminated process.");
37
38     waitFor(20);
39
40     Msg.info("Done sleeping. Goodbye now!");
41   }
42 }