Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reindent, no change at all
[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     /**
29      * Construct an new parallel task with the specified processing amount and amount for each host
30      * implied.
31      *
32      * @param name                              The name of the parallel task.
33      * @param hosts                             The list of hosts implied by the parallel task.
34      * @param computeDurations  The total number of operations that have to be performed
35      *                                                  on the hosts.
36      * @param messageSizes              An array of doubles
37      * @exception                               InvalidTaskNameException if the specified name is null.
38      *                                                  InvalidComputeDuration if the parameter computeDurations is null.
39      *                                                  InvalidMessageSize if the parameter messageSizes is null.
40      */
41   public ParallelTask(String name, Host[]hosts, double[]computeDurations,
42                       double[]messageSizes)
43   throws JniException {
44     create(name, hosts, computeDurations, messageSizes);
45   }
46     /**
47      * This method creates a parallel task (if not already created).
48      *
49      * @param name                              The name of the parallel task.
50      * @param hosts                             The list of hosts implied by the parallel task.
51      * @param computeDurations  The total number of operations that have to be performed
52      *                                                  on the hosts.
53      * @param messageSizes              An array of doubles
54      * @exception                               InvalidTaskNameException if the specified name is null.
55      *                                                  InvalidComputeDuration if the parameter computeDurations is null.
56      *                                                  InvalidMessageSize if the parameter messageSizes is null.
57      */
58     public void create(String name, Host[]hosts, double[]computeDurations,
59                          double[]messageSizes)
60   throws JniException {
61
62     if (bind != 0)
63       Msg.parallelTaskCreate(this, name, hosts, computeDurations,
64                              messageSizes);
65   }
66     /**
67      * This method gets the sender of the parallel task.
68      *
69      * @return                          The sender of the parallel task.
70      *
71      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
72      *                                          is invalid if it is not binded with a native parallel task.
73      *
74      */ Process getSender() throws JniException {
75     return Msg.parallelTaskGetSender(this);
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      */ public Host getSource() throws JniException {
85     return Msg.parallelTaskGetSource(this);
86   }
87     /**
88      * This method gets the name of a parallel task.
89      *
90      * @return                          The name of the parallel task.
91      *
92      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
93      *                                          is invalid if it is not binded with a native parallel task.
94      */ public String getName() throws JniException {
95     return Msg.parallelTaskGetName(this);
96   }
97     /**
98      * This method cancels a task.
99      *
100      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
101      *                                          is invalid if it is not binded with a native parallel task.
102      *                                          MsgException if the cancelation failed.
103      */ public void cancel() throws JniException, NativeException {
104     Msg.parallelTaskCancel(this);
105   }
106     /**
107      * This method gets the computing amount of the parallel task.
108      *
109      * @return                          The computing amount of the parallel task.
110      *
111      * @exception                       InvalidTaskException is the specified task is not valid. A task
112      *                                          is invalid if it is not binded with a native task.
113      */ public double getComputeDuration() throws JniException {
114     return Msg.parallelTaskGetComputeDuration(this);
115   }
116     /**
117      * This method gets the remaining computation.
118      *
119      * @return                          The remaining duration. 
120      *
121      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
122      *                                          is invalid if it is not binded with a native parallel task.
123      */ public double getRemainingDuration() throws JniException {
124     return Msg.parallelTaskGetRemainingDuration(this);
125   }
126     /**
127      * This method sets the priority of the computation of the parallel task.
128      * The priority doesn't affect the transfert rate. For example a
129      * priority of 2 will make the task receive two times more cpu than
130      * the other ones.
131      *
132      * @param                           The new priority of the parallel task.
133      *
134      * @exception                       InvalidTaskException is the specified task is not valid. A task
135      *                                          is invalid if it is not binded with a native task.
136      */ public void setPrirority(double priority) throws JniException {
137     Msg.parallelTaskSetPriority(this, priority);
138   }
139     /**
140      * This method destroies a parallel task.
141      *
142      * @exception                       InvalidTaskException is the specified task is not valid. A parallel task
143      *                                          is invalid if it is not binded with a native task.
144      *                                          MsgException if the destruction failed.
145      */ public void destroy() throws JniException, NativeException {
146     Msg.parallelTaskDestroy(this);
147   }
148     /**
149      * This method deletes a parallel task.
150      *
151      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
152      *                                          is invalid if it is not binded with a native parallel task.
153      *                                          MsgException if the destruction failed.
154      */ protected void finalize() throws JniException, NativeException {
155     if (this.bind != 0)
156       Msg.parallelTaskDestroy(this);
157   }
158     /**
159      * This method execute a task on the location on which the
160      * process is running.
161      *
162      * @exception                       InvalidTaskException is the specified parallel task is not valid. A parallel task
163      *                                          is invalid if it is not binded with a native parallel task.
164      *                                          MsgException if the destruction failed.
165      */ public void execute() throws JniException, NativeException {
166     Msg.parallelTaskExecute(this);
167 }}