Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
754dad0c8017d0e079111b0ecf38bdd4ac8869ca
[simgrid.git] / examples / java / app / tokenring / Main.java
1 /* Copyright (c) 2016. 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.tokenring;
7 import org.simgrid.msg.Host;
8 import org.simgrid.msg.HostNotFoundException;
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.Process;
11
12 class Main {
13         private Main() {
14                 /* This is just to prevent anyone from creating an instance of this singleton */
15                 throw new IllegalAccessError("Utility class");
16         }
17
18         public static void main(String[] args) throws HostNotFoundException {
19                 Msg.init(args);
20                 
21                 String platform = "../platforms/small_platform.xml";
22                 if(args.length >= 1) 
23                         platform = args[0];
24                 Msg.createEnvironment(platform);
25                 
26                 Host[] hosts = Host.all();
27                 for (int rank = 0; rank < hosts.length; rank++) {
28                         Process proc = new RelayRunner(hosts[rank], Integer.toString(rank),  null);
29                         proc.start();
30                 }
31                 Msg.info("Number of hosts '"+hosts.length+"'");
32                 Msg.run();
33                 
34                 Msg.info("Simulation time "+Msg.getClock());
35         }
36 }