Logo AND Algorithmique Numérique Distribuée

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