Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7943ed40cd98f1c58441dfbbccb32f7ef92170fd
[simgrid.git] / src / bindings / java / org / simgrid / trace / Trace.java
1 /*
2  * JNI interface to C code for the TRACES part of SimGrid.
3  * 
4  * Copyright 2012 The SimGrid Team.           
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 package org.simgrid.trace;
12
13 import org.simgrid.msg.Msg;
14
15 public final class Trace {
16         /* Statically load the library which contains all native functions used in here */
17         static {
18                 Msg.nativeInit();
19                 try {
20                         System.loadLibrary("SG_java_tracing");
21                 } catch(UnsatisfiedLinkError e) {
22                         System.err.println("Cannot load the bindings to the simgrid library: ");
23                         e.printStackTrace();
24                         System.err.println(
25                                         "Please check your LD_LIBRARY_PATH, or copy the simgrid and SG_java_tracing libraries to the current directory");
26                         System.exit(1);
27                 }
28         }
29
30         // TODO complete the binding of the tracing API 
31         
32
33         /**
34          * Declare a new user variable associated to hosts with a color. 
35          *  
36          * @param variable
37          * @param color
38          */
39         public final static native      void hostVariableDeclareWithColor (String variable, String color);
40         
41         
42         /**
43          *  Add a value to a variable of a host. 
44          *  
45          * @param host
46          * @param variable
47          * @param value
48          */
49         public final static native      void hostVariableAdd (String host, String variable, double value);
50
51         /**
52          * Subtract a value from a variable of a host. 
53          *  
54          * @param host
55          * @param variable
56          * @param value
57          */
58         public final static native      void hostVariableSub (String host, String variable, double value);
59
60         /**
61          * Set the value of a variable of a host at a given timestamp. 
62          * 
63          * @param time
64          * @param host
65          * @param variable
66          * @param value
67          */
68         public final static native      void hostVariableSetWithTime (double time, String host, String variable, double value);
69
70         /**
71          *      Add a value to a variable of a host at a given timestamp. 
72          * 
73          * @param time
74          * @param host
75          * @param variable
76          * @param value
77          */
78         public final static native      void hostVariableAddWithTime (double time, String host, String variable, double value);
79  
80         /**
81          * Subtract a value from a variable of a host at a given timestamp.  
82          * 
83          * @param time
84          * @param host
85          * @param variable
86          * @param value
87          */
88         public final static native      void hostVariableSubWithTime (double time, String host, String variable, double value);
89
90         /**
91          *  Get declared user host variables. 
92          * 
93          */
94         public final static native String[]  getHostVariablesName ();
95
96         /**
97          *  Declare a new user variable associated to links. 
98          *  
99          * @param variable
100          */
101         public final static native      void linkVariableDeclare (String variable);
102
103         /**
104          * Declare a new user variable associated to links with a color. 
105          * @param variable
106          * @param color
107          */
108         public final static native      void linkVariableDeclareWithColor (String variable, String color);
109
110         /**
111          *  Set the value of a variable of a link. 
112          *   
113          * @param link
114          * @param variable
115          * @param value
116          */
117         public final static native      void linkVariableSet (String link, String variable, double value);
118
119         /**
120          * Add a value to a variable of a link. 
121          * 
122          * @param link
123          * @param variable
124          * @param value
125          */
126         public final static native      void linkVariableAdd (String link, String variable, double value);
127  
128         /**
129          * Subtract a value from a variable of a link. 
130          * 
131          * @param link
132          * @param variable
133          * @param value
134          */
135         public final static native      void linkVariableSub (String link, String variable, double value);
136
137         /**
138          *  Set the value of a variable of a link at a given timestamp. 
139          *  
140          * @param time
141          * @param link
142          * @param variable
143          * @param value
144          */
145         public final static native      void linkVariableSetWithTime (double time, String link, String variable, double value);
146
147         /**
148          * Add a value to a variable of a link at a given timestamp.
149          * 
150          * @param time
151          * @param link
152          * @param variable
153          * @param value
154          */
155         public final static native      void linkVariableAddWithTime (double time, String link, String variable, double value);
156  
157
158         /**
159          * Subtract a value from a variable of a link at a given timestamp. 
160          *   
161          * @param time
162          * @param link
163          * @param variable
164          * @param value
165          */
166         public final static native      void linkVariableSubWithTime (double time, String link, String variable, double value);
167
168         /**
169          * Set the value of the variable present in the links connecting source and destination. 
170          * 
171          * @param src
172          * @param dst
173          * @param variable
174          * @param value
175          */
176         public final static native      void linkSrcDstVariableSet (String src, String dst, String variable, double value);
177  
178         /**
179          * Add a value to the variable present in the links connecting source and destination. 
180          *  
181          * @param src
182          * @param dst
183          * @param variable
184          * @param value
185          */
186         public final static native      void linkSrcDstVariableAdd (String src, String dst, String variable, double value);
187
188         /**
189          * Subtract a value from the variable present in the links connecting source and destination. 
190          *   
191          * @param src
192          * @param dst
193          * @param variable
194          * @param value
195          */
196         public final static native      void linkSrcDstVariableSub (String src, String dst, String variable, double value);
197
198         /**
199          *  Set the value of the variable present in the links connecting source and destination at a given timestamp. 
200          *   
201          * @param time
202          * @param src
203          * @param dst
204          * @param variable
205          * @param value
206          */
207         public final static native      void linkSrcDstVariableSetWithTime (double time, String src, String dst, String variable, double value);
208
209         /**
210          * Add a value to the variable present in the links connecting source and destination at a given timestamp. 
211          * 
212          * @param time
213          * @param src
214          * @param dst
215          * @param variable
216          * @param value
217          */
218         public final static native      void linkSrcdstVariableAddWithTime (double time, String src, String dst, String variable, double value);
219  
220         /**
221          * Subtract a value from the variable present in the links connecting source and destination at a given timestamp. 
222          *  
223          * @param time
224          * @param src
225          * @param dst
226          * @param variable
227          * @param value
228          */
229         public final static native      void linkSrcDstVariableSubWithTime (double time, String src, String dst, String variable, double value);
230
231         /**
232          *  Get declared user link variables.  
233          */
234         public final static native String[] getLinkVariablesName ();
235
236         
237                         /* **** ******** WARNINGS ************** ***** */       
238                         /* Only the following routines have been       */
239                         /* JNI implemented - Adrien May, 22nd          */
240                         /* **** ******************************** ***** */       
241                 
242     /**
243      * Declare a user state that will be associated to hosts. 
244      * A user host state can be used to trace application states.
245      * 
246      * @param name The name of the new state to be declared.
247      */
248         public final static native void hostStateDeclare(String name);
249         
250         /**
251          * Declare a new value for a user state associated to hosts.
252          * The color needs to be a string with three numbers separated by spaces in the range [0,1]. 
253          * A light-gray color can be specified using "0.7 0.7 0.7" as color. 
254          * 
255          * @param state The name of the new state to be declared.
256          * @param value The name of the value
257          * @param color The color of the value
258          */
259         public final static native void hostStateDeclareValue (String state, String value, String color);
260
261         /**
262          *      Set the user state to the given value.
263          *  (the queue is totally flushed and reinitialized with the given state).
264          *  
265          * @param host The name of the host to be considered.
266          * @param state The name of the state previously declared.
267          * @param value The new value of the state.
268          */
269         public final static native void hostSetState (String host, String state, String value);
270  
271         /**
272          * Push a new value for a state of a given host. 
273          * 
274          * @param host The name of the host to be considered.
275          * @param state The name of the state previously declared.
276          * @param value The value to be pushed.
277          */
278         public final static native void hostPushState (String host, String state, String value);
279         
280         /**
281          *  Pop the last value of a state of a given host. 
282          *   
283          * @param host The name of the host to be considered.
284          * @param state The name of the state to be popped.
285          */
286         public final static native void hostPopState (String host, String state);
287
288         /**
289          * Declare a new user variable associated to hosts. 
290          * 
291          * @param variable
292          */
293         public final static native      void hostVariableDeclare (String variable);
294  
295
296         /**
297          * Set the value of a variable of a host. 
298          * 
299          * @param host
300          * @param variable
301          * @param value
302          */
303         public final static native      void hostVariableSet (String host, String variable, double value);
304
305         /**
306          * Declare a new user variable associated to VMs. 
307          * 
308          * @param variable
309          */
310         public final static native      void vmVariableDeclare (String variable);
311  
312
313         /**
314          * Set the value of a variable of a VM. 
315          * 
316          * @param host
317          * @param variable
318          * @param value
319          */
320         public final static native      void vmVariableSet (String vm, String variable, double value);
321 }