Logo AND Algorithmique Numérique Distribuée

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