2 * JNI interface to C code for MSG.
4 * Copyright 2006,2007,2010,2011 The SimGrid Team.
7 * This program is free software; you can redistribute
8 * it and/or modify it under the terms of the license
9 * (GNU LGPL) which comes with this package.
12 package org.simgrid.msg;
14 public final class Msg {
15 /* Statically load the library which contains all native functions used in here */
18 System.loadLibrary("SG_java");
19 } catch(UnsatisfiedLinkError e) {
20 System.err.println("Cannot load the bindings to the simgrid library: ");
23 "Please check your LD_LIBRARY_PATH, or copy the simgrid and SG_java libraries to the current directory");
27 /** Retrieve the simulation time
30 public final static native double getClock();
32 * Issue a debug logging message.
33 * @param s message to log.
35 public final static native void debug(String s);
37 * Issue an verbose logging message.
38 * @param s message to log.
40 public final static native void verb(String s);
42 /** Issue an information logging message
45 public final static native void info(String s);
47 * Issue an warning logging message.
48 * @param s message to log.
50 public final static native void warn(String s);
52 * Issue an error logging message.
53 * @param s message to log.
55 public final static native void error(String s);
57 * Issue an critical logging message.
58 * @param s message to log.
60 public final static native void critical(String s);
62 /*********************************************************************************
63 * Deployment and initialization related functions *
64 *********************************************************************************/
67 * The natively implemented method to initialize a MSG simulation.
69 * @param args The arguments of the command line of the simulation.
73 public final static native void init(String[]args);
76 * Run the MSG simulation.
78 * The simulation is not cleaned afterward (see
79 * {@link #clean()} if you really insist on cleaning the C side), so you can freely
80 * retrieve the informations that you want from the simulation. In particular, retrieving the status
81 * of a process or the current date is perfectly ok.
85 public final static native void run() ;
88 * Cleanup the MSG simulation.
90 * This function is only useful if you want to chain the simulations within
91 * the same environment. But actually, it's not sure at all that cleaning the
92 * JVM is faster than restarting a new one, so it's probable that using this
93 * function is not a brilliant idea. Do so at own risk.
97 public final static native void clean();
101 * The native implemented method to create the environment of the simulation.
103 * @param platformFile The XML file which contains the description of the environment of the simulation
106 public final static native void createEnvironment(String platformFile);
109 * The method to deploy the simulation.
112 * @param deploymentFile
114 public final static native void deployApplication(String deploymentFile);
116 /** Example launcher. You can use it or provide your own launcher, as you wish
118 * @throws MsgException
120 static public void main(String[]args) throws MsgException {
121 /* initialize the MSG simulation. Must be done before anything else (even logging). */
124 if (args.length < 2) {
125 Msg.info("Usage: Msg platform_file deployment_file");
129 /* Load the platform and deploy the application */
130 Msg.createEnvironment(args[0]);
131 Msg.deployApplication(args[1]);
132 /* Execute the simulation */