Logo AND Algorithmique Numérique Distribuée

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