Logo AND Algorithmique Numérique Distribuée

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