Logo AND Algorithmique Numérique Distribuée

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