Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
(kinda) working java wrappers by Malek and me
[simgrid.git] / src / java / simgrid / msg / ParallelTask.java
1 /*
2  * simgrid.msg.Task.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 class ParallelTask {
15         
16     /**
17      * This attribute represents a bind between a java task object and
18      * a native task. Even if this attribute is public you must never
19      * access to it. It is set automaticatly during the build of the object.
20      */
21     public long bind = 0;
22         
23                         
24     /* Default constructor (disabled) */
25     protected ParallelTask() {};
26         
27     /**
28      * Construct an new parallel task with the specified processing amount and amount for each host
29      * implied.
30      *
31      * @param name                              The name of the parallel task.
32      * @param hosts                             The list of hosts implied by the parallel task.
33      * @param computeDurations  The total number of operations that have to be performed
34      *                                                  on the hosts.
35      * @param messageSizes              An array of doubles
36      * @exception                               InvalidTaskNameException if the specified name is null.
37      *                                                  InvalidComputeDuration if the parameter computeDurations is null.
38      *                                                  InvalidMessageSize if the parameter messageSizes is null.
39      */
40     public ParallelTask(String name, Host[] hosts,double[] computeDurations, double[] messageSizes) 
41         throws JniException {
42         create(name,hosts,computeDurations,messageSizes); 
43     }
44         
45     /**
46      * This method creates a parallel task (if not already created).
47      *
48      * @param name                              The name of the parallel task.
49      * @param hosts                             The list of hosts implied by the parallel task.
50      * @param computeDurations  The total number of operations that have to be performed
51      *                                                  on the hosts.
52      * @param messageSizes              An array of doubles
53      * @exception                               InvalidTaskNameException if the specified name is null.
54      *                                                  InvalidComputeDuration if the parameter computeDurations is null.
55      *                                                  InvalidMessageSize if the parameter messageSizes is null.
56      */
57     public void create(String name, Host[] hosts,double[] computeDurations, double[] messageSizes) 
58         throws JniException {
59                 
60         if(bind != 0)
61             Msg.parallelTaskCreate(this,name,hosts,computeDurations,messageSizes); 
62     }
63         
64     /**
65      * This method gets the sender of the parallel task.
66      *
67      * @return                          The sender of the parallel task.
68      *
69      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
70      *                                          is invalid if it is not binded with a native parallel task.
71      *
72      */
73     Process getSender() throws JniException {
74         return Msg.parallelTaskGetSender(this);
75     }
76         
77     /**
78      * This method gets the source of the parallel task.
79      *
80      * @return                          The source of the task. 
81      *
82      * @exception                       InvalidTaskException is the specified parallel task is not valid. A task
83      *                                          is invalid if it is not binded with a native parallel task.
84      */
85     public Host getSource() throws JniException {
86         return Msg.parallelTaskGetSource(this);
87     }
88         
89     /**
90      * This method gets the name of a parallel task.
91      *
92      * @return                          The name of the parallel task.
93      *
94      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
95      *                                          is invalid if it is not binded with a native parallel task.
96      */
97     public String getName() throws JniException {
98         return Msg.parallelTaskGetName(this);
99     }
100         
101     /**
102      * This method cancels a task.
103      *
104      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
105      *                                          is invalid if it is not binded with a native parallel task.
106      *                                          MsgException if the cancelation failed.
107      */
108     public void cancel() throws JniException, NativeException {
109         Msg.parallelTaskCancel(this);
110     }
111         
112     /**
113      * This method gets the computing amount of the parallel task.
114      *
115      * @return                          The computing amount of the parallel task.
116      *
117      * @exception                       InvalidTaskException is the specified task is not valid. A task
118      *                                          is invalid if it is not binded with a native task.
119      */
120     public double getComputeDuration() throws JniException {
121         return Msg.parallelTaskGetComputeDuration(this);
122     }
123         
124     /**
125      * This method gets the remaining computation.
126      *
127      * @return                          The remaining duration. 
128      *
129      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
130      *                                          is invalid if it is not binded with a native parallel task.
131      */ 
132     public double getRemainingDuration() throws JniException {
133         return Msg.parallelTaskGetRemainingDuration(this);
134     }
135         
136     /**
137      * This method sets the priority of the computation of the parallel task.
138      * The priority doesn't affect the transfert rate. For example a
139      * priority of 2 will make the task receive two times more cpu than
140      * the other ones.
141      *
142      * @param                           The new priority of the parallel task.
143      *
144      * @exception                       InvalidTaskException is the specified task is not valid. A task
145      *                                          is invalid if it is not binded with a native task.
146      */
147     public void setPrirority(double priority) throws JniException { 
148         Msg.parallelTaskSetPriority(this,priority);
149     }
150         
151     /**
152      * This method destroies a parallel task.
153      *
154      * @exception                       InvalidTaskException is the specified task is not valid. A parallel task
155      *                                          is invalid if it is not binded with a native task.
156      *                                          MsgException if the destruction failed.
157      */
158     public void destroy() throws JniException, NativeException {
159         Msg.parallelTaskDestroy(this);
160     }                   
161         
162     /**
163      * This method deletes a parallel task.
164      *
165      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
166      *                                          is invalid if it is not binded with a native parallel task.
167      *                                          MsgException if the destruction failed.
168      */
169     protected void finalize() throws JniException, NativeException {
170         if(this.bind != 0)
171             Msg.parallelTaskDestroy(this);
172     }
173         
174     /**
175      * This method execute a task on the location on which the
176      * process is running.
177      *
178      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
179      *                                          is invalid if it is not binded with a native parallel task.
180      *                                          MsgException if the destruction failed.
181      */
182     public void execute() throws JniException, NativeException {
183         Msg.parallelTaskExecute(this);
184     }                                   
185 }