Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add an example for the cloud API (doesn't work yet).
[simgrid.git] / examples / cloud / Cloud.java
1 /*
2  * Copyright 2012. The SimGrid Team. 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;
8
9 import org.simgrid.msg.Host;
10 import org.simgrid.msg.Msg;
11 import org.simgrid.msg.MsgException;
12
13 /**
14  * Example showing the use of the new experimental Cloud API.
15  */
16 public class Cloud {
17         public static final double task_comp_size = 10000000;
18         public static final double task_comm_size = 10000000;
19
20         public static void main(String[] args) throws MsgException {       
21             Msg.init(args); 
22             
23             if (args.length < 1) {
24                 Msg.info("Usage  : Cloud platform_file");
25                 Msg.info("Usage  : Cloud platform.xml");
26                 System.exit(1);
27             }
28             /* Construct the platform */
29                 Msg.createEnvironment(args[0]);
30                   /* Retrieve the 10 first hosts of the platform file */
31                 Host[] hosts = Host.all();
32                 if (hosts.length < 10) {
33                         Msg.info("I need at least 10 hosts in the platform file, but " + args[0] + " contains only " + hosts.length + " hosts");
34                         System.exit(42);
35                 }
36                 new Master(hosts[0],"Master",hosts).start();
37                 /* Execute the simulation */
38                 Msg.run();
39                 
40                 Msg.clean();
41     }
42 }