Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
complete reorganisation of examples/smpi/NAS
[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         /** Retrieve the simulation time
16          * @return The simulation time.
17          */
18         public final static native double getClock();
19         /**
20          * Issue a debug logging message.
21          * @param s message to log.
22          */
23         public final static native void debug(String s);
24         /**
25          * Issue an verbose logging message.
26          * @param s message to log.
27          */
28         public final static native void verb(String s);
29
30         /** Issue an information logging message
31          * @param s
32          */
33         public final static native void info(String s);
34         /**
35          * Issue an warning logging message.
36          * @param s message to log.
37          */
38         public final static native void warn(String s);
39         /**
40          * Issue an error logging message.
41          * @param s message to log.
42          */
43         public final static native void error(String s);
44         /**
45          * Issue an critical logging message.
46          * @param s message to log.
47          */
48         public final static native void critical(String s);
49
50         /*********************************************************************************
51          * Deployment and initialization related functions                               *
52          *********************************************************************************/
53
54         /**
55          * The natively implemented method to initialize a MSG simulation.
56          *
57          * @param args            The arguments of the command line of the simulation.
58          */
59         public final static native void init(String[]args);
60         
61         /** Tell the kernel that you want to use the energy plugin */
62         public final static native void energyInit();
63
64         /**
65          * Run the MSG simulation.
66          *
67          * The simulation is not cleaned afterward (see  
68          * {@link #clean()} if you really insist on cleaning the C side), so you can freely 
69          * retrieve the informations that you want from the simulation. In particular, retrieving the status 
70          * of a process or the current date is perfectly ok. 
71          */
72         public final static native void run() ;
73
74         /** This function is useless nowadays, just stop calling it. */
75         @Deprecated
76         public final static void clean(){}
77
78         /**
79          * The native implemented method to create the environment of the simulation.
80          *
81          * @param platformFile    The XML file which contains the description of the environment of the simulation
82          *
83          */
84         public final static native void createEnvironment(String platformFile);
85
86         public final static native As environmentGetRoutingRoot();
87
88         /**
89          * The method to deploy the simulation.
90          *
91          *
92          * @param deploymentFile
93          */
94         public final static native void deployApplication(String deploymentFile);
95
96         /** Example launcher. You can use it or provide your own launcher, as you wish
97          * @param args
98          * @throws MsgException
99          */
100         static public void main(String[]args) throws MsgException {
101                 /* initialize the MSG simulation. Must be done before anything else (even logging). */
102                 Msg.init(args);
103
104                 if (args.length < 2) {
105                         Msg.info("Usage: Msg platform_file deployment_file");
106                         System.exit(1);
107                 }
108
109                 /* Load the platform and deploy the application */
110                 Msg.createEnvironment(args[0]);
111                 Msg.deployApplication(args[1]);
112                 /* Execute the simulation */
113                 Msg.run();
114         }
115         
116         /* Class initializer, to initialize various JNI stuff */
117         static {
118                 org.simgrid.NativeLib.nativeInit();
119         }
120 }