Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove some smells in Java
[simgrid.git] / examples / java / cloud / masterworker / Main.java
1 /* Copyright (c) 2012-2014, 2016. 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 cloud.masterworker;
8
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.Host;
11 import org.simgrid.msg.MsgException;
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 = 2 ; 
17
18   private Main() {
19     throw new IllegalAccessError("Utility class");
20   }
21
22   public static void main(String[] args) throws MsgException {
23     Msg.init(args); 
24
25     if (args.length < 1) {
26       Msg.info("Usage   : Main platform_file");
27       Msg.info("Usage  : Main ../platforms/platform.xml");
28       System.exit(1);
29     }
30
31     /* Construct the platform */
32     Msg.createEnvironment(args[0]);
33     Host[] hosts = Host.all();
34     if (hosts.length < NHOSTS+1) {
35       Msg.info("I need at least "+ (NHOSTS+1) +"  hosts in the platform file, but " + args[0] + " contains only "
36                + hosts.length + " hosts");
37       System.exit(42);
38     }
39     Msg.info("Start "+ NHOSTS +" hosts");
40     new Master(hosts[0],"Master",hosts).start();
41     /* Execute the simulation */
42     Msg.run();
43   }
44 }