1 /* JNI interface to C code for MSG. */
3 /* Copyright (c) 2006-2014. The SimGrid Team.
4 * All rights reserved. */
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. */
9 package org.simgrid.msg;
10 import org.simgrid.NativeLib;
13 public final class Msg {
14 /* Statically load the library which contains all native functions used in here */
15 static private boolean isNativeInited = false;
16 public static void nativeInit() {
20 if (System.getProperty("os.name").toLowerCase().startsWith("win"))
21 NativeLib.nativeInit("winpthread-1");
23 NativeLib.nativeInit("simgrid");
24 NativeLib.nativeInit("simgrid-java");
25 isNativeInited = true;
32 /** Retrieve the simulation time
33 * @return The simulation time.
35 public final static native double getClock();
37 * Issue a debug logging message.
38 * @param s message to log.
40 public final static native void debug(String s);
42 * Issue an verbose logging message.
43 * @param s message to log.
45 public final static native void verb(String s);
47 /** Issue an information logging message
50 public final static native void info(String s);
52 * Issue an warning logging message.
53 * @param s message to log.
55 public final static native void warn(String s);
57 * Issue an error logging message.
58 * @param s message to log.
60 public final static native void error(String s);
62 * Issue an critical logging message.
63 * @param s message to log.
65 public final static native void critical(String s);
67 /*********************************************************************************
68 * Deployment and initialization related functions *
69 *********************************************************************************/
72 * The natively implemented method to initialize a MSG simulation.
74 * @param args The arguments of the command line of the simulation.
76 public final static native void init(String[]args);
79 * Run the MSG simulation.
81 * The simulation is not cleaned afterward (see
82 * {@link #clean()} if you really insist on cleaning the C side), so you can freely
83 * retrieve the informations that you want from the simulation. In particular, retrieving the status
84 * of a process or the current date is perfectly ok.
86 public final static native void run() ;
88 /** This function is useless nowadays, just stop calling it. */
90 public final static void clean(){}
93 * The native implemented method to create the environment of the simulation.
95 * @param platformFile The XML file which contains the description of the environment of the simulation
98 public final static native void createEnvironment(String platformFile);
100 public final static native As environmentGetRoutingRoot();
103 * The method to deploy the simulation.
106 * @param deploymentFile
108 public final static native void deployApplication(String deploymentFile);
110 /** Example launcher. You can use it or provide your own launcher, as you wish
112 * @throws MsgException
114 static public void main(String[]args) throws MsgException {
115 /* initialize the MSG simulation. Must be done before anything else (even logging). */
118 if (args.length < 2) {
119 Msg.info("Usage: Msg platform_file deployment_file");
123 /* Load the platform and deploy the application */
124 Msg.createEnvironment(args[0]);
125 Msg.deployApplication(args[1]);
126 /* Execute the simulation */