* it and/or modify it under the terms of the license
*(GNU LGPL) which comes with this package.
*/
-
+
package simgrid.msg;
import org.xml.sax.*;
*
* @return The last error code of the simulation.
*/
- final static native int getErrCode();
-
+ final static native int getErrCode();
+
/**
* Errors returned by the method Msg.getErrCode().
*/
-
- /* Everything is right. Keep on goin the way !
- *
- */
- public static final int SUCCESS = 0;
-
- /* Something must be not perfectly clean. But I
- * may be paranoid freak... !
- */
- public static final int WARNING = 1;
-
- /* There has been a problem during you task treansfer.
- * Either the network is down or the remote host has
- * been shutdown.
- */
- public static final int TRANSFERT_FAILURE = 2;
-
+
+ /* Everything is right. Keep on goin the way !
+ *
+ */
+ public static final int SUCCESS = 0;
+
+ /* Something must be not perfectly clean. But I
+ * may be paranoid freak... !
+ */
+ public static final int WARNING = 1;
+
+ /* There has been a problem during you task treansfer.
+ * Either the network is down or the remote host has
+ * been shutdown.
+ */
+ public static final int TRANSFERT_FAILURE = 2;
+
/**
* System shutdown. The host on which you are running
* has just been rebooted. Free your datastructures and
* return now !
*/
- public static final int HOST_FAILURE = 3;
-
+ public static final int HOST_FAILURE = 3;
+
/**
* Cancelled task. This task has been cancelled by somebody !
*/
- public static final int TASK_CANCELLLED = 4;
-
+ public static final int TASK_CANCELLLED = 4;
+
/**
* You've done something wrong. You'd better look at it...
*/
- public static final int FATAL_ERROR = 5;
-
+ public static final int FATAL_ERROR = 5;
+
/**
* Staticaly load the SIMGRID4JAVA library
* which contains all native functions used in here
*/
- static {
- try {
- System.loadLibrary("simgrid");
- Msg.selectContextFactory("jcontext_factory");
- } catch(NativeException e)
- {
- System.err.println(e.toString());
- e.printStackTrace();
- System.exit(1);
- } catch(UnsatisfiedLinkError e){
- System.err.println("Cannot load simgrid library : ");
- e.printStackTrace();
- System.err.println("Please check your LD_LIBRARY_PATH, "+
- "or copy the library to the current directory");
- System.exit(1);
- }
+ static {
+ try {
+ System.loadLibrary("simgrid");
+ Msg.selectContextFactory("jcontext_factory");
+ } catch(NativeException e) {
+ System.err.println(e.toString());
+ e.printStackTrace();
+ System.exit(1);
+ } catch(UnsatisfiedLinkError e) {
+ System.err.println("Cannot load simgrid library : ");
+ e.printStackTrace();
+ System.err.println("Please check your LD_LIBRARY_PATH, " +
+ "or copy the library to the current directory");
+ System.exit(1);
}
-
- final static native
+ }
+
+ final static native
void selectContextFactory(String name) throws NativeException;
-
+
/******************************************************************
* The natively implemented methods connected to the MSG Process *
******************************************************************/
-
+
/**
* The natively implemented method to create an MSG process.
*
*
* @see Process constructors.
*/
- final static native
- void processCreate(Process process, Host host) throws JniException;
-
+ final static native
+ void processCreate(Process process, Host host) throws JniException;
+
/**
* The natively implemented method to kill all the process of the simulation.
*
*
* @return The function returns the PID of the next created process.
*/
- final static native int processKillAll(int resetPID);
-
+ final static native int processKillAll(int resetPID);
+
/**
* The natively implemented method to suspend an MSG process.
*
*
* @see Process.pause()
*/
- final static native void processSuspend(Process process)
- throws JniException, NativeException;
-
+ final static native void processSuspend(Process process)
+ throws JniException, NativeException;
+
/**
* The natively implemented method to kill a MSG process.
*
*
* @see Process.kill()
*/
- final static native void processKill(Process process)
- throws JniException;
-
+ final static native void processKill(Process process)
+ throws JniException;
+
/**
* The natively implemented method to resume a suspended MSG process.
*
*
* @see Process.restart()
*/
- final static native void processResume(Process process)
- throws JniException, NativeException;
-
+ final static native void processResume(Process process)
+ throws JniException, NativeException;
+
/**
* The natively implemented method to test if MSG process is suspended.
*
*
* @see Process.isSuspended()
*/
- final static native boolean processIsSuspended(Process process) throws JniException;
-
+ final static native boolean processIsSuspended(Process process) throws
+ JniException;
+
/**
* The natively implemented method to get the host of a MSG process.
*
*
* @see Process.getHost()
*/
- final static native Host processGetHost(Process process)
- throws JniException, NativeException;
-
+ final static native Host processGetHost(Process process)
+ throws JniException, NativeException;
+
/**
* The natively implemented method to get a MSG process from his PID.
*
*
* @see Process.getFromPID()
*/
- final static native Process processFromPID(int PID) throws NativeException;
-
+ final static native Process processFromPID(int PID) throws NativeException;
+
/**
* The natively implemented method to get the PID of a MSG process.
*
*
* @see Process.getPID()
*/
- final static native int processGetPID(Process process) throws NativeException;
-
+ final static native int processGetPID(Process process) throws
+ NativeException;
+
/**
* The natively implemented method to get the PPID of a MSG process.
*
*
* @see Process.getPPID()
*/
- final static native int processGetPPID(Process process) throws NativeException;
-
+ final static native int processGetPPID(Process process) throws
+ NativeException;
+
/**
* The natively implemented method to get the current running process.
*
* @see Process.currentProcess()
*/
- final static native Process processSelf() throws NativeException;
-
+ final static native Process processSelf() throws NativeException;
+
/**
* The natively implemented method to get the current running process PID.
*
*
* @see Process.currentProcessPID()
*/
- final static native int processSelfPID();
-
+ final static native int processSelfPID();
+
/**
* The natively implemented method to get the current running process PPID.
*
*
* @see Process.currentProcessPPID()
*/
- final static native int processSelfPPID();
-
+ final static native int processSelfPPID();
+
/**
* The natively implemented method to migrate a process from his currnet host to a new host.
*
* @see Process.migrate()
* @see Host.getByName()
*/
- final static native void processChangeHost(Process process,Host host)
- throws JniException, NativeException;
-
+ final static native void processChangeHost(Process process, Host host)
+ throws JniException, NativeException;
+
/**
* Process synchronization. The process wait the signal of the simulator to start.
*
* @exception JniException if something goes wrong with JNI
*/
- final static native void waitSignal(Process process) throws JniException;
-
+ final static native void waitSignal(Process process) throws JniException;
+
/**
* The natively implemented native to request the current process to sleep
* until time seconds have elapsed.
*
* @see Process.waitFor()
*/
- final static native void processWaitFor(double seconds) throws NativeException;
-
+ final static native void processWaitFor(double seconds) throws
+ NativeException;
+
/**
* The natively implemented native method to exit a process.
*
*
* @see Process.exit()
*/
- final static native void processExit(Process process) throws JniException;
-
-
+ final static native void processExit(Process process) throws JniException;
+
+
/******************************************************************
* The natively implemented methods connected to the MSG host *
******************************************************************/
-
+
/**
* The natively implemented method to get an host from his name.
*
*
* @see Host.getByName()
*/
- final static native Host hostGetByName(String name)
- throws JniException, HostNotFoundException, NativeException;
-
+ final static native Host hostGetByName(String name)
+ throws JniException, HostNotFoundException, NativeException;
+
/**
* The natively implemented method to get the name of an MSG host.
*
*
* @see Host.getName()
*/
- final static native String hostGetName(Host host) throws JniException;
-
+ final static native String hostGetName(Host host) throws JniException;
+
/**
* The natively implemented method to get the number of hosts of the simulation.
*
*
* @see Host.getNumber()
*/
- final static native int hostGetNumber();
-
+ final static native int hostGetNumber();
+
/**
* The natively implemented method to get the host of the current runing process.
*
*
* @see Host.currentHost()
*/
- final static native Host hostSelf() throws JniException;
-
+ final static native Host hostSelf() throws JniException;
+
/**
* The natively implemented method to get the speed of a MSG host.
*
*
* @see Host.getSpeed()
*/
-
- final static native double hostGetSpeed(Host host) throws JniException;
-
+
+ final static native double hostGetSpeed(Host host) throws JniException;
+
/**
* The natively implemented native method to test if an host is avail.
*
*
* @see Host.isAvail()
*/
- final static native boolean hostIsAvail(Host host) throws JniException;
-
+ final static native boolean hostIsAvail(Host host) throws JniException;
+
/**
* The natively implemented native method to get all the hosts of the simulation.
*
*
* @return A array which contains all the hosts of simulation.
*/
-
- final static native Host[] allHosts() throws JniException;
-
+
+ final static native Host[] allHosts() throws JniException;
+
/**
* The natively implemented native method to get the number of running tasks on a host.
*
* @exception JniException if something goes wrong with JNI
*
*/
- final static native int hostGetLoad(Host host) throws JniException;
-
+ final static native int hostGetLoad(Host host) throws JniException;
+
/******************************************************************
* The natively implemented methods connected to the MSG task *
******************************************************************/
-
+
/**
* The natively implemented method to create a MSG task.
*
*
* @see Task.create()
*/
- final static native void taskCreate(Task task,String name,double computeDuration, double messageSize)
- throws JniException, NullPointerException, IllegalArgumentException;
-
+ final static native void taskCreate(Task task, String name,
+ double computeDuration,
+ double messageSize)
+ throws JniException, NullPointerException, IllegalArgumentException;
+
/**
* The natively implemented method to get the sender of a task.
*
*
* @see Task.getSender()
*/
- final static native Process taskGetSender(Task task) throws JniException;
-
+ final static native Process taskGetSender(Task task) throws JniException;
+
/**
* The natively implementd method to get the source of a task.
*
*
* @see Task.getSource()
*/
- final static native Host taskGetSource(Task task) throws JniException, NativeException;
-
+ final static native Host taskGetSource(Task task) throws JniException,
+ NativeException;
+
/**
* The natively implemented method to get the name of the task.
*
*
* @see Task.getName()
*/
- final static native String taskGetName(Task task) throws JniException;
-
+ final static native String taskGetName(Task task) throws JniException;
+
/**
* The natively implemented method to cancel a task.
*
*
* @see Task.cancel().
*/
- final static native void taskCancel(Task task) throws JniException, NativeException;
-
+ final static native void taskCancel(Task task) throws JniException,
+ NativeException;
+
/**
* The natively implemented method to get the computing amount of the task.
*
*
* @see Task.getComputeDuration()
*/
- final static native double taskGetComputeDuration(Task task) throws JniException;
-
+ final static native double taskGetComputeDuration(Task task) throws
+ JniException;
+
/**
* The natively implemented method to get the remaining computation
*
*
* @see Task.getRemainingDuration()
*/
- final static native double taskGetRemainingDuration(Task task) throws JniException;
-
+ final static native double taskGetRemainingDuration(Task task) throws
+ JniException;
+
/**
* The natively implemented method to set the priority of a task.
*
*
* @see Task.setPriority()
*/
- final static native void taskSetPriority(Task task,double priority) throws JniException;
-
+ final static native void taskSetPriority(Task task,
+ double priority) throws
+ JniException;
+
/**
* The natively implemented method to destroy a MSG task.
*
*
* @see Task.destroy()
*/
- final static native void taskDestroy(Task task) throws JniException, NativeException;
-
+ final static native void taskDestroy(Task task) throws JniException,
+ NativeException;
+
/**
* The natively implemented method to execute a MSG task.
*
*
* @see Task.execute()
*/
- final static native void taskExecute(Task task) throws JniException, NativeException;
-
-
-
+ final static native void taskExecute(Task task) throws JniException,
+ NativeException;
+
+
+
/**************************************************************************
* The natively implemented methods connected to the MSG parallel task *
***************************************************************************/
-
+
/**
* The natively implemented method to create a MSG parallel task.
*
*
* @see ParallelTask.create()
*/
- final static native void parallelTaskCreate(ParallelTask parallelTask, String name,
- Host[] hosts, double[] computeDurations, double[] messageSizes)
- throws JniException, NullPointerException, IllegalArgumentException;
-
+ final static native void parallelTaskCreate(ParallelTask parallelTask,
+ String name, Host[]hosts,
+ double[]computeDurations,
+ double[]messageSizes)
+ throws JniException, NullPointerException, IllegalArgumentException;
+
/**
* The natively implemented method to get the sender of a parallel task.
*
*
* @see ParallelTask.getSender()
*/
- final static native Process parallelTaskGetSender(ParallelTask parallelTask) throws JniException;
-
+ final static native Process parallelTaskGetSender(ParallelTask parallelTask)
+ throws JniException;
+
/**
* The natively implementd method to get the source of a parallel task.
*
*
* @see ParallelTask.getSource()
*/
- final static native Host parallelTaskGetSource(ParallelTask parallelTask) throws JniException;
-
+ final static native Host parallelTaskGetSource(ParallelTask parallelTask)
+ throws JniException;
+
/**
* The natively implemented method to get the name of the parallel task.
*
*
* @see ParallelTask.getName()
*/
- final static native String parallelTaskGetName(ParallelTask parallelTask) throws JniException;
-
+ final static native String parallelTaskGetName(ParallelTask parallelTask)
+ throws JniException;
+
/**
* The natively implemented method to cancel a parallel task.
*
*
* @see ParallelTask.cancel().
*/
- final static native void parallelTaskCancel(ParallelTask parallelTask) throws JniException,NativeException;
-
+ final static native void parallelTaskCancel(ParallelTask parallelTask)
+ throws JniException, NativeException;
+
/**
* The natively implemented method to get the computing amount of the task.
*
*
* @see ParallelTask.getComputeDuration()
*/
- final static native double parallelTaskGetComputeDuration(ParallelTask parallelTask) throws JniException;
-
+ final static native double parallelTaskGetComputeDuration(ParallelTask
+ parallelTask)
+ throws JniException;
+
/**
* The natively implemented method to get the remaining computation
*
*
* @see ParallelTask.getRemainingDuration()
*/
- final static native double parallelTaskGetRemainingDuration(ParallelTask parallelTask) throws JniException;
-
+ final static native double parallelTaskGetRemainingDuration(ParallelTask
+ parallelTask)
+ throws JniException;
+
/**
* The natively implemented method to set the priority of a parallel task.
*
*
* @see ParallelTask.setPriority()
*/
- final static native void parallelTaskSetPriority(ParallelTask parallelTask,double priority) throws JniException;
-
+ final static native void parallelTaskSetPriority(ParallelTask parallelTask,
+ double priority) throws
+ JniException;
+
/**
* The natively implemented method to destroy a MSG parallel task.
*
*
* @see ParallelTask.destroy()
*/
- final static native void parallelTaskDestroy(ParallelTask parallelTask) throws JniException,NativeException;
-
+ final static native void parallelTaskDestroy(ParallelTask parallelTask)
+ throws JniException, NativeException;
+
/**
* The natively implemented method to execute a MSG parallel task.
*
*
* @see ParallelTask.execute()
*/
- final static native void parallelTaskExecute(ParallelTask parallelTask) throws JniException, NativeException;
-
+ final static native void parallelTaskExecute(ParallelTask parallelTask)
+ throws JniException, NativeException;
+
/******************************************************************
* The natively implemented methods connected to the MSG channel *
******************************************************************/
-
+
/**
* The natively implemented method to listen on the channel and wait for receiving a task.
*
*
* @see Channel.get()
*/
- final static native Task channelGet(Channel channel) throws JniException,NativeException;
-
+ final static native Task channelGet(Channel channel) throws JniException,
+ NativeException;
+
/**
* The natively implemented method to listen on the channel and wait for receiving a task with a timeout.
*
*
* @see Channel.getWithTimeout()
*
- */
- final static native Task channelGetWithTimeout(Channel channel,double timeout) throws JniException,NativeException;
-
-
+ */
+ final static native Task channelGetWithTimeout(Channel channel,
+ double timeout) throws
+ JniException, NativeException;
+
+
/**
* The natively implemented method to listen on the channel of a specific host.
*
* MsgException if the listening operation failed.
*
* @see Channel.getFromHost()
- */
- final static native Task channelGetFromHost(Channel channel,Host host) throws JniException,NativeException;
-
+ */
+ final static native Task channelGetFromHost(Channel channel,
+ Host host) throws JniException,
+ NativeException;
+
/**
* The natively implemented method to test whether there is a pending communication on the channel.
*
* channel. Otherwise the method returns false.
*
* @see Channel.hasPendingCommunication()
- */
- final static native boolean channelHasPendingCommunication(Channel channel) throws JniException;
-
+ */
+ final static native boolean channelHasPendingCommunication(Channel channel)
+ throws JniException;
+
/**
* The natively implemented method to test whether there is a pending communication on a
* channel, and who sent it.
*
* @see Channel.getCummunicatingProcess()
*/
- final static native int channelGetCommunicatingProcess(Channel channel) throws JniException;
-
+ final static native int channelGetCommunicatingProcess(Channel channel)
+ throws JniException;
+
/**
* The natively implemented method to get the number of tasks waiting to be received on a
* channel and sent by a host.
*
* @see Channel.getHostWaiting()
*/
- final static native int channelGetHostWaitingTasks(Channel channel,Host host) throws JniException;
-
+ final static native int channelGetHostWaitingTasks(Channel channel,
+ Host host) throws
+ JniException;
+
/**
* The natively implemented method to put a task on the channel of an host.
*
* MsgException if the operation failed.
*
* @see Channel.put()
- */
- final static native void channelPut(Channel channel,Task task,Host host) throws JniException,NativeException;
-
+ */
+ final static native void channelPut(Channel channel, Task task,
+ Host host) throws JniException,
+ NativeException;
+
/**
* The natively implemented method to put a task on a channel of an host (with a timeout
* on the waiting of the destination host) and waits for the end of the transmission.
*
* @see Channel.putWithTimeout()
*/
- final static native void channelPutWithTimeout(Channel channel,Task task,Host host,double timeout) throws JniException,NativeException;
-
+ final static native void channelPutWithTimeout(Channel channel, Task task,
+ Host host,
+ double timeout) throws
+ JniException, NativeException;
+
/**
* The natively implemented method to put a task on channel with a bounded transmition
* rate.
*
* @see Channel.putBounded()
*/
- final static native void channelPutBounded(Channel channel,Task task,Host host,double max_rate) throws JniException,NativeException;
-
+ final static native void channelPutBounded(Channel channel, Task task,
+ Host host,
+ double max_rate) throws
+ JniException, NativeException;
+
/**
* The natively implemented method to wait for at most timeout seconds for a task reception
* on channel. The PID is updated with the PID of the first process.
*
* @see Channel.wait()
*/
- final static native int channelWait(Channel channel, double timeout) throws JniException,NativeException;
-
+ final static native int channelWait(Channel channel,
+ double timeout) throws JniException,
+ NativeException;
+
/**
* The natively implemented method to set the number of channel used by all the process
* of the simulation.
*
* @see Channel.setNumber()
*/
- final static native void channelSetNumber(int channelNumber);
-
+ final static native void channelSetNumber(int channelNumber);
+
/**
* The natively implemented method to get the number of channel of the process of the simulation.
*
*
* @see Channel.getNumber()
*/
- final static native int channelGetNumber();
-
+ final static native int channelGetNumber();
+
/*********************************************************************************
* Additional native methods *
**********************************************************************************/
-
+
/**
* The natively implemented method to get the simulation time.
*
* @param The simulation time.
*/
- public final static native double getClock();
-
- public final static native void pajeOutput(String pajeFile);
-
-
- public final static native void info(String s);
-
+ public final static native double getClock();
+
+ public final static native void pajeOutput(String pajeFile);
+
+
+ public final static native void info(String s);
+
/*********************************************************************
* The natively implemented methods connected to the MSG simulation *
*********************************************************************/
-
+
/**
* The natively implemented method to initialize a MSG simulation.
*
*
* @see Msg.init()
*/
- public final static native void init(String[] args);
-
+ public final static native void init(String[]args);
+
/**
* Run the MSG simulation, and cleanup everything afterward.
*
*
* @see MSG_run, MSG_clean
*/
- public final static native void run() throws NativeException;
-
+ public final static native void run() throws NativeException;
+
/**
* The native implemented method to create the environment of the simulation.
*
* @param platformFile The XML file which contains the description of the environment of the simulation
*
*/
- public final static native void createEnvironment(String platformFile) throws NativeException;
-
-
+ public final static native void createEnvironment(String platformFile)
+ throws NativeException;
+
+
/**
* The method to deploy the simulation.
*
* @param appFile The XML file which contains the description of the application to deploy.
*/
-
-
- public static void deployApplication(String platformFile) {
- try {
- Class c = Class.forName("com.sun.org.apache.xerces.internal.parsers.SAXParser");
- XMLReader reader = (XMLReader)c.newInstance();
- reader.setEntityResolver(new DTDResolver());
- ApplicationHandler handler = new ApplicationHandler();
- reader.setContentHandler(handler);
- reader.setFeature("http://xml.org/sax/features/validation", false);
- reader.parse(platformFile);
-
- } catch(Exception e) {
- /* FIXME: do not swallow exception ! */
- System.out.println("Exception in Msg.launchApplication()");
- System.out.println(e);
- e.printStackTrace();
- }
- }
-
- /* The launcher */
- static public void main(String[]args) throws MsgException {
- /* initialize the MSG simulation. Must be done before anything else (even logging). */
- Msg.init(args);
-
- if(args.length < 2) {
-
- Msg.info("Usage: Msg platform_file deployment_file");
- System.exit(1);
- }
-
- /* specify the number of channel for the process of the simulation. */
- Channel.setNumber(1);
-
- /* Load the platform and deploy the application */
- Msg.createEnvironment(args[0]);
- Msg.deployApplication(args[1]);
-
- /* Execute the simulation */
- Msg.run();
+
+
+ public static void deployApplication(String platformFile) {
+ try {
+ Class c =
+ Class.forName("com.sun.org.apache.xerces.internal.parsers.SAXParser");
+ XMLReader reader = (XMLReader) c.newInstance();
+
+ reader.setEntityResolver(new DTDResolver());
+ ApplicationHandler handler = new ApplicationHandler();
+
+ reader.setContentHandler(handler);
+ reader.setFeature("http://xml.org/sax/features/validation", false);
+ reader.parse(platformFile);
+
+ } catch(Exception e) {
+ /* FIXME: do not swallow exception ! */
+ System.out.println("Exception in Msg.launchApplication()");
+ System.out.println(e);
+ e.printStackTrace();
}
+ }
+
+ /* The launcher */
+ static public void main(String[]args) throws MsgException {
+ /* initialize the MSG simulation. Must be done before anything else (even logging). */
+ Msg.init(args);
+
+ if (args.length < 2) {
+
+ Msg.info("Usage: Msg platform_file deployment_file");
+ System.exit(1);
+ }
+
+ /* specify the number of channel for the process of the simulation. */
+ Channel.setNumber(1);
+
+ /* Load the platform and deploy the application */
+ Msg.createEnvironment(args[0]);
+ Msg.deployApplication(args[1]);
+
+ /* Execute the simulation */
+ Msg.run();
+ }
}