Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d16eb99b1baed6cc423a6609ae1e36bc1eabb4e3
[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 import org.simgrid.NativeLib;
11
12
13 public final class Msg {
14
15         /** Retrieves the simulation time */
16         public final static native double getClock();
17         /** Issue a debug logging message. */
18         public final static native void debug(String msg);
19         /** Issue a verbose logging message. */
20         public final static native void verb(String msg);
21         /** Issue an information logging message */
22         public final static native void info(String msg);
23         /** Issue a warning logging message. */
24         public final static native void warn(String msg);
25         /** Issue an error logging message. */
26         public final static native void error(String msg);
27         /** Issue a critical logging message. */
28         public final static native void critical(String s);
29
30         /*********************************************************************************
31          * Deployment and initialization related functions                               *
32          *********************************************************************************/
33
34         /** Initialize a MSG simulation.
35          *
36          * @param args            The arguments of the command line of the simulation.
37          */
38         public final static native void init(String[]args);
39         
40         /** Tell the kernel that you want to use the energy plugin */
41         public final static native void energyInit();
42
43         /** Run the MSG simulation.
44          *
45          * The simulation is not cleaned afterward (see  
46          * {@link #clean()} if you really insist on cleaning the C side), so you can freely 
47          * retrieve the informations that you want from the simulation. In particular, retrieving the status 
48          * of a process or the current date is perfectly ok. 
49          */
50         public final static native void run() ;
51
52         /** This function is useless nowadays, just stop calling it. */
53         @Deprecated
54         public final static void clean(){}
55
56         /** Create the simulation environment by parsing a platform file. */
57         public final static native void createEnvironment(String platformFile);
58
59         public final static native As environmentGetRoutingRoot();
60
61         /** Starts your processes by parsing a deployment file. */
62         public final static native void deployApplication(String deploymentFile);
63
64         /** Example launcher. You can use it or provide your own launcher, as you wish
65          * @param args
66          * @throws MsgException
67          */
68         static public void main(String[]args) throws MsgException {
69                 /* initialize the MSG simulation. Must be done before anything else (even logging). */
70                 Msg.init(args);
71
72                 if (args.length < 2) {
73                         Msg.info("Usage: Msg platform_file deployment_file");
74                         System.exit(1);
75                 }
76
77                 /* Load the platform and deploy the application */
78                 Msg.createEnvironment(args[0]);
79                 Msg.deployApplication(args[1]);
80                 /* Execute the simulation */
81                 Msg.run();
82         }
83         
84         /* Class initializer, to initialize various JNI stuff */
85         static {
86                 org.simgrid.NativeLib.nativeInit();
87         }
88 }