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 an "debug" logging message.
33 * @param s message to log.
35 public final static native void debug(String s);
36 /** Issue an information logging message
39 public final static native void info(String s);
41 /*********************************************************************************
42 * Deployment and initialization related functions *
43 *********************************************************************************/
46 * The natively implemented method to initialize a MSG simulation.
48 * @param args The arguments of the command line of the simulation.
52 public final static native void init(String[]args);
55 * Run the MSG simulation.
57 * The simulation is not cleaned afterward (see
58 * {@link #clean()} if you really insist on cleaning the C side), so you can freely
59 * retrieve the informations that you want from the simulation. In particular, retrieving the status
60 * of a process or the current date is perfectly ok.
64 public final static native void run() ;
67 * Cleanup the MSG simulation.
69 * This function is only useful if you want to chain the simulations within
70 * the same environment. But actually, it's not sure at all that cleaning the
71 * JVM is faster than restarting a new one, so it's probable that using this
72 * function is not a brilliant idea. Do so at own risk.
76 public final static native void clean();
80 * The native implemented method to create the environment of the simulation.
82 * @param platformFile The XML file which contains the description of the environment of the simulation
85 public final static native void createEnvironment(String platformFile);
88 * The method to deploy the simulation.
91 * @param deploymentFile
93 public final static native void deployApplication(String deploymentFile);
95 /** Example launcher. You can use it or provide your own launcher, as you wish
97 * @throws MsgException
99 static public void main(String[]args) throws MsgException {
100 /* initialize the MSG simulation. Must be done before anything else (even logging). */
103 if (args.length < 2) {
104 Msg.info("Usage: Msg platform_file deployment_file");
108 /* Load the platform and deploy the application */
109 Msg.createEnvironment(args[0]);
110 Msg.deployApplication(args[1]);
111 /* Execute the simulation */