2 * JNI interface to C code for MSG.
4 * Copyright 2006,2007,2010 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.
14 public final class Msg {
15 /* Statically load the library which contains all native functions used in here */
18 System.loadLibrary("simgrid");
19 } catch(UnsatisfiedLinkError e) {
20 System.err.println("Cannot load simgrid library: ");
23 "Please check your LD_LIBRARY_PATH, or copy the library to the current directory");
28 /** Returns the last error code of the simulation */
29 public final static native int getErrCode();
31 /** Everything is right. Keep on going the way ! */
32 public static final int SUCCESS = 0;
34 /** Something must be not perfectly clean (but I may be paranoid freak...) */
35 public static final int WARNING = 1;
37 /** There has been a problem during you task transfer.
38 * Either the network is down or the remote host has been shutdown */
39 public static final int TRANSFERT_FAILURE = 2;
42 * The host on which you are running has just been rebooted.
43 * Free your data structures and return now ! */
44 public static final int HOST_FAILURE = 3;
46 /** Canceled task. This task has been canceled by somebody ! */
47 public static final int TASK_CANCELLLED = 4;
49 /** You've done something wrong. You'd better look at it... */
50 public static final int FATAL_ERROR = 5;
53 /** Retrieve the simulation time */
54 public final static native double getClock();
56 /** Issue an information logging message */
57 public final static native void info(String s);
59 /*********************************************************************************
60 * Deployment and initialization related functions *
61 *********************************************************************************/
64 * The natively implemented method to initialize a MSG simulation.
66 * @param args The arguments of the command line of the simulation.
70 public final static native void init(String[]args);
73 * Run the MSG simulation, and cleanup everything afterward.
75 * If you want to chain simulations in the same process, you
76 * should call again createEnvironment and deployApplication afterward.
78 * @see MSG_run, MSG_clean
80 public final static native void run() throws NativeException;
83 * The native implemented method to create the environment of the simulation.
85 * @param platformFile The XML file which contains the description of the environment of the simulation
88 public final static native void createEnvironment(String platformFile)
89 throws NativeException;
92 * The method to deploy the simulation.
94 * @param platformFile The XML file which contains the description of the application to deploy.
96 public final static native void deployApplication(String deploymentFile)
97 throws NativeException;
99 /** Example launcher. You can use it or provide your own launcher, as you wish */
100 static public void main(String[]args) throws MsgException {
101 /* initialize the MSG simulation. Must be done before anything else (even logging). */
104 if (args.length < 2) {
105 Msg.info("Usage: Msg platform_file deployment_file");
109 /* Load the platform and deploy the application */
110 Msg.createEnvironment(args[0]);
111 Msg.deployApplication(args[1]);
113 /* Execute the simulation */