2 * simgrid.msg.Msg.java 1.00 07/05/01
4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
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.
16 * MSG was the first distributed programming environment
17 * provided within SimGrid. While almost realistic, it
18 * remains quite simple.
19 * This class contains all the declaration of the natives methods
21 * All of these methods are statics. You can't directly use these methods
22 * but it is recommanded to use the classes Process, Host and Task
23 * of the package to build your application.
25 * @author Abdelmalek Cherier
26 * @author Martin Quinson
29 public final class Msg {
31 * Statically load the library which contains all native functions used in here
35 System.loadLibrary("simgrid");
36 } catch(UnsatisfiedLinkError e) {
37 System.err.println("Cannot load simgrid library : ");
39 System.err.println("Please check your LD_LIBRARY_PATH, " +
40 "or copy the library to the current directory");
45 /** Returns the last error code of the simulation */
46 public final static native int getErrCode();
48 /** Everything is right. Keep on goin the way ! */
49 public static final int SUCCESS = 0;
51 /** Something must be not perfectly clean (but I may be paranoid freak...) */
52 public static final int WARNING = 1;
54 /** There has been a problem during you task treansfer.
55 * Either the network is down or the remote host has been shutdown */
56 public static final int TRANSFERT_FAILURE = 2;
59 * The host on which you are running has just been rebooted.
60 * Free your datastructures and return now ! */
61 public static final int HOST_FAILURE = 3;
63 /** Cancelled task. This task has been cancelled by somebody ! */
64 public static final int TASK_CANCELLLED = 4;
66 /** You've done something wrong. You'd better look at it... */
67 public static final int FATAL_ERROR = 5;
71 /** Retrieve the simulation time */
72 public final static native double getClock();
74 public final static native void pajeOutput(String pajeFile);
77 /** Issue an information logging message */
78 public final static native void info(String s);
80 /*********************************************************************************
81 * Deployment and initialization related functions *
82 *********************************************************************************/
85 * The natively implemented method to initialize a MSG simulation.
87 * @param args The arguments of the command line of the simulation.
91 public final static native void init(String[]args);
94 * Run the MSG simulation, and cleanup everything afterward.
96 * If you want to chain simulations in the same process, you
97 * should call again createEnvironment and deployApplication afterward.
99 * @see MSG_run, MSG_clean
101 public final static native void run() throws NativeException;
104 * The native implemented method to create the environment of the simulation.
106 * @param platformFile The XML file which contains the description of the environment of the simulation
109 public final static native void createEnvironment(String platformFile)
110 throws NativeException;
113 * The method to deploy the simulation.
115 * @param platformFile The XML file which contains the description of the application to deploy.
117 public final static native void deployApplication(String deploymentFile)
118 throws NativeException;
121 static public void main(String[]args) throws MsgException {
122 /* initialize the MSG simulation. Must be done before anything else (even logging). */
125 if (args.length < 2) {
126 Msg.info("Usage: Msg platform_file deployment_file");
130 /* Load the platform and deploy the application */
131 Msg.createEnvironment(args[0]);
132 Msg.deployApplication(args[1]);
134 /* Execute the simulation */