Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Indeed, the sax.helpers and java.lang importation are not useful, i have removed...
[simgrid.git] / src / java / simgrid / msg / Msg.java
1 /*
2  * simgrid.msg.Msg.java    1.00 07/05/01
3  *
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier           
5  * All right reserved. 
6  *
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. 
10  */
11  
12 package simgrid.msg;
13 import org.xml.sax.*;
14
15 /** 
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
20  * of the MSG API.
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, Task and ParallelTask
23  * of the package to build your application.
24  *
25  * @author  Abdelmalek Cherier
26  * @author  Martin Quinson
27  * @version 1.00, 07/05/01
28  * @see Host
29  * @see Process
30  * @see Task
31  * @see ParallelTask
32  * @since SimGrid 3.3
33  * @since JDK1.5011 
34  */
35 public final class Msg {
36     /**
37      * The natively implemented method to get the last error code of the simulation.
38      *
39      * @return     The last error code of the simulation.
40      */
41     final static native int getErrCode();
42     
43     /**
44      * Errors returned by the method Msg.getErrCode().
45      */
46     
47     /* Everything is right. Keep on goin the way !                                
48      *
49      */
50     public static final int SUCCESS                = 0;
51     
52     /* Something must be not perfectly clean. But I 
53      * may be paranoid freak... !    
54      */
55     public static final int WARNING                = 1;
56     
57     /* There has been a problem during you task treansfer.
58      * Either the network is  down or the remote host has 
59      * been shutdown.
60      */
61     public static final int TRANSFERT_FAILURE    = 2;
62     
63     /**
64      * System shutdown. The host on which you are running
65      * has just been rebooted. Free your datastructures and
66      * return now !
67      */
68     public static final int HOST_FAILURE        = 3;
69     
70     /**
71      * Cancelled task. This task has been cancelled by somebody !
72      */
73     public static final int TASK_CANCELLLED        = 4;
74     
75     /**
76      * You've done something wrong. You'd better look at it...
77      */
78     public static final int FATAL_ERROR            = 5;
79     
80     /**
81      * Staticaly load the SIMGRID4JAVA library
82      *  which contains all native functions used in here
83      */
84     static {
85         try {
86             System.loadLibrary("simgrid4java");
87         } catch(UnsatisfiedLinkError e){
88             System.err.println("Cannot load simgrid4java library : ");
89             e.printStackTrace();
90             System.err.println("Please check your LD_LIBRARY_PATH, "+
91                                "or copy the library to the current directory");
92             System.exit(1);
93         }
94     }
95     
96     /******************************************************************
97      * The natively implemented methods connected to the MSG Process  *
98      ******************************************************************/
99      
100     /**
101      * The natively implemented method to create an MSG process.
102      *
103      * @param process The java process object to bind with the MSG native process.
104      * @param host    A valid (binded) host where create the process.
105      *
106      * @exception  simgrid.msg.JniException if JNI stuff goes wrong.
107      *
108      * @see  Process constructors.
109      */
110     final static native 
111         void processCreate(Process process, Host host) throws JniException;
112      
113     /**
114      * The natively implemented method to kill all the process of the simulation.
115      *
116      * @param resetPID        Should we reset the PID numbers. A negative number means no reset
117      *                        and a positive number will be used to set the PID of the next newly
118      *                        created process.
119      *
120      * @return                The function returns the PID of the next created process.
121      */
122     final static native int processKillAll(int resetPID);
123        
124     /**
125      * The natively implemented method to suspend an MSG process.
126      *
127      * @param process        The valid (binded with a native process) java process to suspend.
128      *
129      * @exception            JniException if something goes wrong with JNI
130      *                       NativeException if the SimGrid native code failed.
131      *
132      * @see                 Process.pause()
133      */
134     final static native void processSuspend(Process process) 
135         throws JniException, NativeException;
136      
137     /**
138      * The natively implemented method to kill a MSG process.
139      *
140      * @param process        The valid (binded with a native process) java process to kill.
141      *
142      * @see                 Process.kill()
143      */
144     final static native void processKill(Process process)
145         throws JniException;
146      
147     /**
148      * The natively implemented method to resume a suspended MSG process.
149      *
150      * @param process        The valid (binded with a native process) java process to resume.
151      *
152      * @exception            JniException if something goes wrong with JNI
153      *                       NativeException if the SimGrid native code failed.
154      *
155      * @see                 Process.restart()
156      */
157     final static native void processResume(Process process)
158         throws JniException, NativeException;
159      
160     /**
161      * The natively implemented method to test if MSG process is suspended.
162      *
163      * @param process        The valid (binded with a native process) java process to test.
164      *
165      * @return                If the process is suspended the method retuns true. Otherwise the
166      *                        method returns false.
167      *
168      * @exception            JniException if something goes wrong with JNI
169      *
170      * @see                 Process.isSuspended()
171      */
172     final static native boolean processIsSuspended(Process process) throws JniException;
173      
174     /**
175      * The natively implemented method to get the host of a MSG process.
176      *
177      * @param process        The valid (binded with a native process) java process to get the host.
178      *
179      * @return                The method returns the host where the process is running.
180      *
181      * @exception            JniException if something goes wrong with JNI
182      *                       NativeException if the SimGrid native code failed.
183      *
184      * @see                 Process.getHost()
185      */
186     final static native Host processGetHost(Process process)
187         throws JniException, NativeException;
188      
189     /**
190      * The natively implemented method to get a MSG process from his PID.
191      *
192      * @param PID            The PID of the process to get.
193      *
194      * @return                The process with the specified PID.
195      *
196      * @exception            NativeException if the SimGrid native code failed.
197      *
198      * @see                 Process.getFromPID()
199      */
200     final static native Process processFromPID(int PID) throws NativeException;
201      
202     /**
203      * The natively implemented method to get the PID of a MSG process.
204      *
205      * @param process        The valid (binded with a native process) java process to get the PID.
206      *
207      * @return                The PID of the specified process.
208      *
209      * @exception            NativeException if the SimGrid native code failed.
210      *
211      * @see                 Process.getPID()
212      */
213     final static native int processGetPID(Process process) throws NativeException;
214      
215     /**
216      * The natively implemented method to get the PPID of a MSG process.
217      *
218      * @param process        The valid (binded with a native process) java process to get the PID.
219      *
220      * @return                The PPID of the specified process.
221      *
222      * @exception            NativeException if the SimGrid native code failed.
223      *
224      * @see                 Process.getPPID()
225      */
226     final static native int processGetPPID(Process process) throws NativeException;
227      
228     /**
229      * The natively implemented method to get the current running process.
230      *
231      * @return             The current process.
232      *
233      * @exception            NativeException if the SimGrid native code failed.
234
235      * @see                Process.currentProcess()
236      */
237     final static native Process processSelf() throws NativeException;
238      
239     /**
240      * The natively implemented method to get the current running process PID.
241      *
242      * @return                The PID of the current process.
243      *
244      * @see                Process.currentProcessPID()
245      */
246     final static native int processSelfPID();
247      
248     /**
249      * The natively implemented method to get the current running process PPID.
250      *
251      * @return                The PPID of the current process.
252      *
253      * @see                Process.currentProcessPPID()
254      */
255     final static native int processSelfPPID();
256      
257     /**
258      * The natively implemented method to migrate a process from his currnet host to a new host.
259      *
260      * @param process        The (valid) process to migrate.
261      * @param host            A (valid) host where move the process.
262      *
263      * @exception            JniException if something goes wrong with JNI
264      *                       NativeException if the SimGrid native code failed.
265      *
266      * @see                Process.migrate()
267      * @see                Host.getByName()
268      */
269     final static native void processChangeHost(Process process,Host host) 
270         throws JniException, NativeException;
271      
272     /**
273      * Process synchronization. The process wait the signal of the simulator to start.
274      * 
275      * @exception            JniException if something goes wrong with JNI
276      */
277     final static native void waitSignal(Process process) throws JniException;
278      
279     /**
280      * The natively implemented native to request the current process to sleep 
281      * until time seconds have elapsed.
282      *
283      * @param seconds        The time the current process must sleep.
284      *
285      * @exception            NativeException if the SimGrid native code failed.
286      *
287      * @see                 Process.waitFor()
288      */
289     final static native void processWaitFor(double seconds) throws NativeException;
290      
291     /**
292      * The natively implemented native method to exit a process.
293      *
294      * @exception            JniException if something goes wrong with JNI
295      *
296      * @see                Process.exit()
297      */
298     final static native void processExit(Process process) throws JniException;
299       
300      
301     /******************************************************************
302      * The natively implemented methods connected to the MSG host     *
303      ******************************************************************/
304      
305     /**
306      * The natively implemented method to get an host from his name.
307      *
308      * @param name            The name of the host to get.
309      *
310      * @return                The host having the specified name.
311      *
312      * @exception            JniException if something goes wrong with JNI
313      *                       HostNotFoundException if there is no such host
314      *                       NativeException if the SimGrid native code failed.
315      *
316      * @see                Host.getByName()
317      */
318     final static native Host hostGetByName(String name) 
319         throws JniException, HostNotFoundException, NativeException;
320      
321     /**
322      * The natively implemented method to get the name of an MSG host.
323      *
324      * @param host            The host (valid) to get the name.
325      *
326      * @return                The name of the specified host.
327      *
328      * @exception            JniException if something goes wrong with JNI
329      *
330      * @see                Host.getName()
331      */
332     final static native String hostGetName(Host host) throws JniException;
333      
334     /**
335      * The natively implemented method to get the number of hosts of the simulation.
336      *
337      * @return                The number of hosts of the simulation.
338      *
339      * @see                Host.getNumber()
340      */
341     final static native int hostGetNumber();
342      
343     /**
344      * The natively implemented method to get the host of the current runing process.
345      *
346      * @return                The host of the current running process.
347      *
348      * @exception            JniException if something goes wrong with JNI
349      *
350      * @see                Host.currentHost()
351      */
352     final static native Host hostSelf() throws JniException;
353      
354     /**
355      * The natively implemented method to get the speed of a MSG host.
356      *
357      * @param host            The host to get the host.
358      *
359      * @return                The speed of the specified host.
360      *
361      * @exception            JniException if something goes wrong with JNI
362      *
363      * @see                Host.getSpeed()
364      */
365       
366     final static native double hostGetSpeed(Host host) throws JniException;
367      
368     /**
369      * The natively implemented native method to test if an host is avail.
370      *
371      * @param host            The host to test.
372      *
373      * @return                If the host is avail the method returns true. 
374      *                        Otherwise the method returns false.
375      *
376      * @exception            JniException if something goes wrong with JNI
377      *
378      * @see                Host.isAvail()
379      */
380     final static native boolean hostIsAvail(Host host) throws JniException;
381      
382     /**
383      * The natively implemented native method to get all the hosts of the simulation.
384      *
385      * @exception            JniException if something goes wrong with JNI
386      *
387      * @return                A array which contains all the hosts of simulation.
388      */
389      
390     final static native Host[] allHosts() throws JniException;
391      
392     /**
393      * The natively implemented native method to get the number of running tasks on a host.
394      *
395      * @param                The host concerned by the operation.
396      *
397      * @return                The number of running tasks.
398      *
399      * @exception            JniException if something goes wrong with JNI
400      *
401      */
402     final static native int hostGetLoad(Host host) throws JniException;
403      
404     /******************************************************************
405      * The natively implemented methods connected to the MSG task     *
406      ******************************************************************/
407       
408     /**
409      * The natively implemented method to create a MSG task.
410      *
411      * @param name            The name of th task.
412      * @param computeDuration    A value of the processing amount (in flop) needed 
413      *                        to process the task. If 0, then it cannot be executed
414      *                        with the execute() method. This value has to be >= 0.
415      * @param messageSize        A value of amount of data (in bytes) needed to transfert 
416      *                        this task. If 0, then it cannot be transfered this task. 
417      *                        If 0, then it cannot be transfered with the get() and put() 
418      *                        methods. This value has to be >= 0.
419      * @param task            The java task object to bind with the native task to create.
420      *
421      * @exception             JniException if something goes wrong with JNI
422      *                        NullPointerException if the specified name is null.
423      *                        IllegalArgumentException if compute duration <0 or message size <0
424      *
425      * @see                    Task.create()
426      */
427     final static native void taskCreate(Task task,String name,double computeDuration, double messageSize)
428         throws JniException, NullPointerException, IllegalArgumentException;
429       
430     /**
431      * The natively implemented method to get the sender of a task.
432      *
433      * @param    task            The task (valid) to get the sender.
434      *
435      * @return                The sender of the task.
436      *
437      * @exception                InvalidTaskException is the specified task is not valid. A task
438      *                        is invalid if it is not binded with a native task.
439      *
440      * @see                    Task.getSender()
441      */
442     final static native Process taskGetSender(Task task) throws JniException;
443       
444     /**
445      * The natively implementd method to get the source of a task.
446      *
447      * @param task            The task to get the source.
448      *
449      * @return                The source of the task.
450      *
451      * @exception                InvalidTaskException is the specified task is not valid. A task
452      *                        is invalid if it is not binded with a native task.
453      *
454      * @see                    Task.getSource()
455      */
456     final static native Host taskGetSource(Task task) throws JniException, NativeException;
457       
458     /**
459      * The natively implemented method to get the name of the task.
460      *
461      * @param task            The task to get the name.
462      *
463      * @return                 The name of the specified task.
464      *
465      * @exception                InvalidTaskException is the specified task is not valid. A task
466      *                        is invalid if it is not binded with a native task.
467      *
468      * @see                    Task.getName()
469      */
470     final static native String taskGetName(Task task) throws JniException;
471       
472     /**
473      * The natively implemented method to cancel a task.
474      *
475      * @param task            The task to cancel.
476      *
477      * @exception                InvalidTaskException if the specified task is not valid. A task
478      *                        is invalid if it is not binded with a native task.
479      *                        MsgException if the cancelation failed.
480      *
481      * @see                    Task.cancel().
482      */
483     final static native void taskCancel(Task task) throws JniException, NativeException;
484       
485     /**
486      * The natively implemented method to get the computing amount of the task.
487      *
488      * @param task            The task to get the computing amount.
489      *
490      * @return                The computing amount of the specified task.
491      *
492      * @exception                InvalidTaskException if the specified task is not valid. A task
493      *                        is invalid if it is not binded with a native task.
494      *                        MsgException if the cancelation failed.
495      *
496      * @see                    Task.getComputeDuration()
497      */
498     final static native double taskGetComputeDuration(Task task) throws JniException;
499       
500     /**
501      * The natively implemented method to get the remaining computation
502      *
503      * @param task            The task to get the remaining computation.
504      *
505      * @return                The remaining computation of the specified task.
506      *
507      * @exception                InvalidTaskException if the specified task is not valid. A task
508      *                        is invalid if it is not binded with a native task.
509      *                        MsgException if the cancelation failed.
510      *
511      * @see                    Task.getRemainingDuration()
512      */
513     final static native double taskGetRemainingDuration(Task task) throws JniException;
514       
515     /**
516      * The natively implemented method to set the priority of a task.
517      *
518      * @param task            The task to set the prirotity
519      *
520      * @param priority        The new priority of the specified task.
521      *
522      * @exception                InvalidTaskException if the specified task is not valid. A task
523      *                        is invalid if it is not binded with a native task.
524      *                        MsgException if the cancelation failed.
525      *
526      * @see                    Task.setPriority()
527      */
528     final static native void taskSetPriority(Task task,double priority) throws JniException;
529       
530     /**
531      * The natively implemented method to destroy a MSG task.
532      *
533      * @param                    The task to destroy.
534      *
535      * @exception                InvalidTaskException is the specified task is not valid. A task
536      *                        is invalid if it is not binded with a native task.
537      *                        MsgException if the destruction failed.
538      *
539      * @see                    Task.destroy()
540      */
541     final static native void taskDestroy(Task task) throws JniException, NativeException;
542       
543     /**
544      * The natively implemented method to execute a MSG task.
545      *
546      * @param task            The task to execute.
547      *
548      * @exception                InvalidTaskException is the specified task is not valid. A task
549      *                        is invalid if it is not binded with a native task.
550      *                        MsgException if the destruction failed.
551      *
552      * @see                    Task.execute()
553      */
554     final static native void taskExecute(Task task) throws JniException, NativeException;
555       
556       
557      
558     /**************************************************************************
559      * The natively implemented methods connected to the MSG parallel task     *
560      ***************************************************************************/
561       
562     /**
563      * The natively implemented method to create a MSG parallel task.
564      *
565      * @param name                The name of the parallel task.
566      * @param hosts                The list of hosts implied by the parallel task.
567      * @param computeDurations    The total number of operations that have to be performed
568      *                            on the hosts.
569      * @param messageSizes        An array of doubles
570      *
571      * @see                        ParallelTask.create()
572      */
573     final static native void parallelTaskCreate(ParallelTask parallelTask, String name, 
574                                                        Host[] hosts, double[] computeDurations, double[] messageSizes)
575         throws JniException, NullPointerException, IllegalArgumentException;
576       
577     /**
578      * The natively implemented method to get the sender of a parallel task.
579      *
580      * @param    parallelTask    The parallel task (valid) to get the sender.
581      *
582      * @return                The sender of the parallel task.
583      *
584      * @see                    ParallelTask.getSender()
585      */
586     final static native Process parallelTaskGetSender(ParallelTask parallelTask) throws JniException;
587       
588     /**
589      * The natively implementd method to get the source of a parallel task.
590      *
591      * @param parallelTask    The parallel task to get the source.
592      *
593      * @return                The source of the parallel task.
594      *
595      * @see                    ParallelTask.getSource()
596      */
597     final static native Host parallelTaskGetSource(ParallelTask parallelTask) throws JniException;
598       
599     /**
600      * The natively implemented method to get the name of the parallel task.
601      *
602      * @param parallelTask    The parallel task to get the name.
603      *
604      * @return                 The name of the specified parallel task.
605      *
606      * @see                    ParallelTask.getName()
607      */
608     final static native String parallelTaskGetName(ParallelTask parallelTask) throws JniException;
609       
610     /**
611      * The natively implemented method to cancel a parallel task.
612      *
613      * @param parallelTask    The parallel task to cancel.
614      *
615      * @see                    ParallelTask.cancel().
616      */
617     final static native void parallelTaskCancel(ParallelTask parallelTask) throws JniException,NativeException;
618       
619     /**
620      * The natively implemented method to get the computing amount of the task.
621      *
622      * @param parallelTask    The parallel task to get the computing amount.
623      *
624      * @return                The computing amount of the specified parallel task.
625      *
626      * @see                    ParallelTask.getComputeDuration()
627      */
628     final static native double parallelTaskGetComputeDuration(ParallelTask parallelTask) throws JniException;
629       
630     /**
631      * The natively implemented method to get the remaining computation
632      *
633      * @param parallelTask    The parallel task to get the remaining computation.
634      *
635      * @return                The remaining computation of the specified parallel task.
636      *
637      * @see                    ParallelTask.getRemainingDuration()
638      */
639     final static native double parallelTaskGetRemainingDuration(ParallelTask parallelTask) throws JniException;
640       
641     /**
642      * The natively implemented method to set the priority of a parallel task.
643      *
644      * @param parallelTask    The parallel task to set the prirotity
645      *
646      * @param priority        The new priority of the specified parallel task.
647      *
648      * @see                    ParallelTask.setPriority()
649      */
650     final static native void parallelTaskSetPriority(ParallelTask parallelTask,double priority) throws JniException;
651       
652     /**
653      * The natively implemented method to destroy a MSG parallel task.
654      *
655      * @param parallelTask    The parallel task to destroy.
656      *
657      * @see                    ParallelTask.destroy()
658      */
659     final static native void parallelTaskDestroy(ParallelTask parallelTask) throws JniException,NativeException;
660       
661     /**
662      * The natively implemented method to execute a MSG parallel task.
663      *
664      * @param parallelTask    The parallel task to execute.
665      *
666      * @see                    ParallelTask.execute()
667      */
668     final static native void parallelTaskExecute(ParallelTask parallelTask) throws JniException, NativeException;
669       
670     /******************************************************************
671      * The natively implemented methods connected to the MSG channel  *
672      ******************************************************************/
673       
674     /**
675      * The natively implemented method to listen on the channel and wait for receiving a task.
676      *
677      * @param channel            The channel to listen            
678      *
679      * @return                The task readed from the channel.
680      *
681      * @exception                MsgException if the listening operation failed.
682      *
683      * @see                    Channel.get()
684      */
685     final static native Task channelGet(Channel channel) throws JniException,NativeException;
686       
687     /**
688      * The natively implemented method to listen on the channel and wait for receiving a task with a timeout.
689      *
690      * @param channel            The channel to listen.
691      * @param timeout            The timeout of the listening.
692      *
693      * @return                The task readed from the channel.
694      *
695      * @exception                MsgException if the listening operation failed.
696      *
697      * @see                    Channel.getWithTimeout()
698      *
699      */ 
700     final static native Task channelGetWithTimeout(Channel channel,double timeout) throws JniException,NativeException;
701       
702       
703     /**
704      * The natively implemented method to listen on the channel of a specific host.
705      *
706      * @param    channel            The channel to listen.
707      *
708      * @param host            The specific host.
709      *
710      * @return                The task readed from the channel of the specific host.
711      *
712      * @exception                InvalidHostException if the specified host is not valid.
713      *                        MsgException if the listening operation failed.
714      *
715      * @see                    Channel.getFromHost()
716      */    
717     final static native Task channelGetFromHost(Channel channel,Host host) throws JniException,NativeException;
718       
719     /**
720      * The natively implemented method to test whether there is a pending communication on the channel.
721      *
722      * @param channel            The channel concerned by the operation.
723      *
724      * @return                The method returns true if there is a pending communication on the specified
725      *                        channel. Otherwise the method returns false.
726      *
727      * @see                    Channel.hasPendingCommunication()
728      */                
729     final static native boolean channelHasPendingCommunication(Channel channel) throws JniException;
730       
731     /**
732      * The natively implemented method to test whether there is a pending communication on a 
733      * channel, and who sent it.
734      *
735      * @param                    The channel concerned by the operation.
736      *
737      * @return                The method returns -1 if there is no pending communication and 
738      *                        the PID of the process who sent it otherwise.
739      *
740      * @see                    Channel.getCummunicatingProcess()
741      */
742     final static native int channelGetCommunicatingProcess(Channel channel) throws JniException;
743       
744     /**
745      * The natively implemented method to get the number of tasks waiting to be received on a
746      * channel and sent by a host.
747      *
748      * @param channel            The channel concerned by the operation.
749      *
750      * @param host            The sender of the tasks.
751      *
752      * @return                The number of tasks waiting to be received on a channel
753      *                         and sent by the specified host.
754      *
755      * @exception                InvalidHostException if the specified host is not valid.
756      *
757      * @see                    Channel.getHostWaiting()
758      */
759     final static native int channelGetHostWaitingTasks(Channel channel,Host host) throws JniException;
760       
761     /**
762      * The natively implemented method to put a task on the channel of an host.
763      *
764      * @param channel            The channel where to put the task.
765      * @param task            The task to put.
766      * @param host            The host of the specified channel.
767      *
768      * @exception                InvalidTaskException if the task is not valid.
769      *                        InvalidHostException if the host is not valid.
770      *                        MsgException if the operation failed.
771      *
772      * @see                    Channel.put()
773      */                
774     final static native void channelPut(Channel channel,Task task,Host host) throws JniException,NativeException;
775       
776     /**
777      * The natively implemented method to put a task on a channel of an  host (with a timeout 
778      * on the waiting of the destination host) and waits for the end of the transmission.
779      *
780      * @param channel            The channel where to put the task.
781      * @param task            The task to put.
782      * @param host            The host containing the channel.
783      * @param timeout            The timeout of the transmission.
784      *
785      * @exception                InvalidTaskException if the task is not valid.
786      *                        InvalidHostException if the host is not valid.
787      *                        MsgException if the operation failed.
788      *
789      * @see                    Channel.putWithTimeout()
790      */
791     final static native void channelPutWithTimeout(Channel channel,Task task,Host host,double timeout) throws JniException,NativeException;
792       
793     /**
794      * The natively implemented method to put a task on channel with a bounded transmition
795      * rate.
796      * 
797      * @param channel            The channel where to put the task.
798      * @param task            The task to put.
799      * @param host            The host containing the channel.
800      * @param max_rate        The bounded transmition rate.
801      *
802      * @exception                InvalidTaskException if the task is not valid.
803      *                        InvalidHostException if the host is not valid.
804      *                        MsgException if the operation failed.
805      *
806      * @see                    Channel.putBounded()
807      */
808     final static native void channelPutBounded(Channel channel,Task task,Host host,double max_rate) throws JniException,NativeException;
809       
810     /**
811      * The natively implemented method to wait for at most timeout seconds for a task reception
812      * on channel. The PID is updated with the PID of the first process.
813      *
814      * @param channel            The channel concerned by the operation.
815      * @param timeout            The maximum time to wait for a task before
816      *                         giving up.
817      *
818      * @exception                MsgException if the reception operation failed.
819      *
820      * @see                    Channel.wait()
821      */
822     final static native int channelWait(Channel channel, double timeout) throws JniException,NativeException;
823       
824     /**
825      * The natively implemented method to set the number of channel used by all the process
826      * of the simulation.
827      *
828      * @param channelNumber    The channel number of the process.
829      *
830      * @see                    Channel.setNumber()
831      */
832     final static native void channelSetNumber(int channelNumber);
833       
834     /**
835      * The natively implemented method to get the number of channel of the process of the simulation.
836      *
837      * @return                The number of channel per process.
838      *
839      * @see                    Channel.getNumber()
840      */
841     final static native int channelGetNumber();
842              
843     /*********************************************************************************
844      * Additional native methods                                                      *
845      **********************************************************************************/
846       
847     /**
848      * The natively implemented method to get the simulation time.
849      *
850      * @param                    The simulation time.
851      */
852     public final static native double getClock();
853       
854     public final static native void pajeOutput(String pajeFile);
855       
856        
857     public final static native void info(String s);
858                         
859     /*********************************************************************
860      * The natively implemented methods connected to the MSG simulation  *
861      *********************************************************************/
862        
863     /**
864      * The natively implemented method to initialize a MSG simulation.
865      *
866      * @param args            The arguments of the command line of the simulation.
867      *
868      * @see                    Msg.init()
869      */
870     public final static native void init(String[] args);
871        
872     /**
873      * Run the MSG simulation, and cleanup everything afterward.
874      *
875      * If you want to chain simulations in the same process, you
876      * should call again createEnvironment and deployApplication afterward.
877      *
878      * @see                    MSG_run, MSG_clean
879      */
880     public final static native void run() throws NativeException;
881        
882     /**
883      * The native implemented method to create the environment of the simulation.
884      *
885      * @param platformFile    The XML file which contains the description of the environment of the simulation
886      *
887      */
888     public final static native void createEnvironment(String platformFile) throws NativeException;
889        
890        
891     /**
892      * The method to deploy the simulation.
893      *
894      * @param appFile        The XML file which contains the description of the application to deploy.
895      */
896        
897         
898     public static void deployApplication(String platformFile) {
899         try {
900             Class c = Class.forName("com.sun.org.apache.xerces.internal.parsers.SAXParser");
901             XMLReader reader = (XMLReader)c.newInstance();
902             reader.setEntityResolver(new DTDResolver());
903             ApplicationHandler handler = new ApplicationHandler();
904             reader.setContentHandler(handler);
905             reader.setFeature("http://xml.org/sax/features/validation", false);
906             reader.parse(platformFile);
907
908         } catch(Exception e) {
909             /* FIXME: do not swallow exception ! */
910             System.out.println("Exception in Msg.launchApplication()");
911             System.out.println(e);
912             e.printStackTrace();
913         }        
914     }                    
915
916     /* The launcher */
917     static public void main(String[]args) throws MsgException {
918         /* initialize the MSG simulation. Must be done before anything else (even logging). */
919         Msg.init(args);
920
921         if(args.length < 2) {
922                 
923             Msg.info("Usage: Msg platform_file deployment_file");
924             System.exit(1);
925         }
926                 
927         /* specify the number of channel for the process of the simulation. */
928         Channel.setNumber(1);
929                 
930         /* Load the platform and deploy the application */
931         Msg.createEnvironment(args[0]);
932         Msg.deployApplication(args[1]);
933                 
934         /* Execute the simulation */
935         Msg.run();
936     }
937 }