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.
12 package org.simgrid.msg;
18 public final class Msg {
19 /* Statically load the library which contains all native functions used in here */
22 System.loadLibrary("SG_java");
23 } catch(UnsatisfiedLinkError e) {
24 System.err.println("Cannot load the bindings to the simgrid library: ");
27 "Please check your LD_LIBRARY_PATH, or copy the simgrid and SG_java libraries to the current directory");
32 /* FIXME: kill these C crufts */
33 /** Returns the last error code of the simulation
36 public final static native int getErrCode();
38 /** Everything is right. Keep on going the way ! */
39 public static final int SUCCESS = 0;
41 /** Something must be not perfectly clean (but I may be paranoid freak...) */
42 public static final int WARNING = 1;
44 /** There has been a problem during your task transfer.
45 * Either the network is down or the remote host has been shutdown */
46 public static final int TRANSFERT_FAILURE = 2;
49 * The host on which you are running has just been rebooted.
50 * Free your data structures and return now ! */
51 public static final int HOST_FAILURE = 3;
53 /** Canceled task. This task has been canceled by somebody ! */
54 public static final int TASK_CANCELLLED = 4;
56 /** You've done something wrong. You'd better look at it... */
57 public static final int FATAL_ERROR = 5;
59 /** Retrieve the simulation time
62 public final static native double getClock();
64 /** Issue an information logging message
67 public final static native void info(String s);
69 /*********************************************************************************
70 * Deployment and initialization related functions *
71 *********************************************************************************/
74 * The natively implemented method to initialize a MSG simulation.
76 * @param args The arguments of the command line of the simulation.
80 public final static native void init(String[]args);
83 * Run the MSG simulation, and cleanup everything afterward.
85 * If you want to chain simulations in the same process, you
86 * should call again createEnvironment and deployApplication afterward.
88 * @see MSG_run, MSG_clean
90 public final static native void run() ;
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);
101 * The method to deploy the simulation.
104 * @param deploymentFile
106 public final static native void deployApplication(String deploymentFile);
108 /** Example launcher. You can use it or provide your own launcher, as you wish
110 * @throws MsgException
112 static public void main(String[]args) throws MsgException {
113 /* initialize the MSG simulation. Must be done before anything else (even logging). */
116 if (args.length < 2) {
117 Msg.info("Usage: Msg platform_file deployment_file");
121 /* Load the platform and deploy the application */
122 Msg.createEnvironment(args[0]);
123 Msg.deployApplication(args[1]);
124 /* Execute the simulation */