Logo AND Algorithmique Numérique Distribuée

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