Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://github.com/mpoquet/simgrid
[simgrid.git] / src / bindings / java / org / simgrid / msg / Msg.java
1 /* JNI interface to C code for MSG. */
2
3 /* Copyright (c) 2006-2014. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 package org.simgrid.msg;
10
11 public final class Msg {
12
13         /** Retrieves the simulation time */
14         public static final native double getClock();
15         /** Issue a debug logging message. */
16         public static final native void debug(String msg);
17         /** Issue a verbose logging message. */
18         public static final native void verb(String msg);
19         /** Issue an information logging message */
20         public static final native void info(String msg);
21         /** Issue a warning logging message. */
22         public static final native void warn(String msg);
23         /** Issue an error logging message. */
24         public static final native void error(String msg);
25         /** Issue a critical logging message. */
26         public static final native void critical(String s);
27
28         private Msg() {
29                 throw new IllegalAccessError("Utility class");
30         }
31
32         /*********************************************************************************
33          * Deployment and initialization related functions                               *
34          *********************************************************************************/
35
36         /** Initialize a MSG simulation.
37          *
38          * @param args            The arguments of the command line of the simulation.
39          */
40         public static final native void init(String[]args);
41         
42         /** Tell the kernel that you want to use the energy plugin */
43         public static final native void energyInit();
44
45         /** Run the MSG simulation.
46          *
47          * After the simulation, you can freely retrieve the information that you want.. 
48          * In particular, retrieving the status of a process or the current date is perfectly ok. 
49          */
50         public static final native void run() ;
51
52         /** Create the simulation environment by parsing a platform file. */
53         public static final native void createEnvironment(String platformFile);
54
55         public static final native As environmentGetRoutingRoot();
56
57         /** Starts your processes by parsing a deployment file. */
58         public static final native void deployApplication(String deploymentFile);
59
60         /** Example launcher. You can use it or provide your own launcher, as you wish
61          * @param args
62          * @throws MsgException
63          */
64         public static void main(String[]args) throws MsgException {
65                 /* initialize the MSG simulation. Must be done before anything else (even logging). */
66                 Msg.init(args);
67
68                 if (args.length < 2) {
69                         Msg.info("Usage: Msg platform_file deployment_file");
70                         System.exit(1);
71                 }
72
73                 /* Load the platform and deploy the application */
74                 Msg.createEnvironment(args[0]);
75                 Msg.deployApplication(args[1]);
76                 /* Execute the simulation */
77                 Msg.run();
78         }
79         
80         /* Class initializer, to initialize various JNI stuff */
81         static {
82                 org.simgrid.NativeLib.nativeInit();
83         }
84 }