Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / examples / java / cloud / masterworker / Main.java
1 /* Copyright (c) 2012-2019. 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 cloud.masterworker;
7
8 import java.io.File;
9
10 import org.simgrid.msg.Msg;
11 import org.simgrid.msg.Host;
12
13 class Main {
14   public static final double TASK_COMP_SIZE = 10;
15   public static final double TASK_COMM_SIZE = 10;
16   public static final int NHOSTS = 6;
17   public static final int NSTEPS = 50;
18
19   private Main() {
20     throw new IllegalAccessError("Utility class");
21   }
22
23   public static void main(String[] args) {
24     Msg.init(args); 
25
26     String platfFile = "../../examples/platforms/small_platform.xml";
27     if (args.length >= 1)
28         platfFile = args[0];
29     
30     File f = new File(platfFile); 
31     if (!f.exists()) {
32       Msg.error("File " + platfFile + " does not exist in " + System.getProperty("user.dir"));
33       Msg.error("Usage  : Main ../platforms/platform.xml");
34     }
35     
36     Msg.createEnvironment(platfFile);
37     Host[] hosts = Host.all();
38     if (hosts.length < NHOSTS+1) {
39       Msg.info("I need at least "+ (NHOSTS+1) +"  hosts in the platform file, but " + args[0] + " contains only "
40                + hosts.length + " hosts");
41       System.exit(42);
42     }
43     new Master(hosts[0],"Master",hosts).start();
44     
45     /* Execute the simulation */
46     Msg.run();
47   }
48 }