Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add migration example
[simgrid.git] / src / jmsg_process.h
1 /* Functions related to the java process instances.                         */
2
3 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7   * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef MSG_JPROCESS_H
10 #define MSG_JPROCESS_H
11
12 #include <jni.h>
13 #include <msg/msg.h>
14 #include <simgrid/simix.h>
15
16 //Cached java fields
17 jfieldID jprocess_field_Process_bind;
18 jfieldID jprocess_field_Process_host;
19 jfieldID jprocess_field_Process_killTime;
20 jfieldID jprocess_field_Process_id;
21 jfieldID jprocess_field_Process_name;
22 jfieldID jprocess_field_Process_pid;
23 jfieldID jprocess_field_Process_ppid;
24
25
26 jobject native_to_java_process(m_process_t process);
27
28 /**
29  * This function returns a global reference to the  java process instance 
30  * specified by the parameter jprocess.
31  *
32  * @param jprocess              The original java process instance.
33  * @param env                   The env of the current thread
34  *
35  * @return                              The global reference to the original java process 
36  *                                              instance.
37  */
38 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
39
40 /**
41  * This function delete a global reference to a java process instance.
42  * If the java process is alive the function joins it and stops it before.
43  *
44  * @param                               The global refernce to delete.
45  * @param env                   The env of the current thread
46  *
47  * @see                                 jprocess_join()
48  * @see                                 jprocess_exit()
49  */
50 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
51
52
53 /**
54  * This function waits for a java process to terminate.
55  *
56  * @param jprocess              The java process ot wait for.
57  * @param env                   The env of the current thread
58  *
59  * @exception                   If the class Process is not found the function throws 
60  *                                              the ClassNotFoundException. If the methos join() of 
61  *                                              this class is not found the function throws the exception 
62  *                                              NotSuchMethodException. 
63  *
64  */
65 void jprocess_join(jobject jprocess, JNIEnv * env);
66 /**
67  * This function associated a native process to a java process instance.
68  *
69  * @param jprocess              The java process instance.
70  * @param process               The native process to bind.
71  * @param env                   The env of the current thread
72  *
73  * @exception                   If the class Process is not found the function throws 
74  *                                              the ClassNotFoundException. If the field bind of 
75  *                                              this class is not found the function throws the exception 
76  *                                              NotSuchFieldException.  
77  */
78 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
79
80 /**
81  * This function returns a native process from a java process instance.
82  *
83  * @param jprocess              The java process object from which get the native process.
84  * @param env                   The env of the current thread
85  *
86  * @return                              The function returns the native process associated to the
87  *                                              java process object.
88  *
89  * @exception                   If the class Process is not found the function throws 
90  *                                              the ClassNotFoundException. If the field bind of 
91  *                                              this class is not found the function throws the exception 
92  *                                              NotSuchFieldException.  
93  */
94 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
95
96 /**
97  * This function gets the id of the specified java process.
98  *
99  * @param jprocess              The java process to get the id.
100  * @param env                   The env of the current thread
101  *
102  * @exception                   If the class Process is not found the function throws 
103  *                                              the ClassNotFoundException. If the field id of 
104  *                                              this class is not found the function throws the exception 
105  *                                              NotSuchFieldException.  
106  *
107  * @return                              The id of the specified java process.
108  */
109 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
110
111 /**
112  * This function tests if a java process instance is valid.
113  * A java process object is valid if it is bind to a native 
114  * process.
115  *
116  * @param jprocess              The java process to test the validity.
117  * @param env                   The env of the current thread
118  *
119  * @return                              If the java process is valid the function returns true.
120  *                                              Otherwise the function returns false.
121  */
122 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
123
124 /**
125  * This function gets the name of the specified java process.
126  *
127  * @param jprocess              The java process to get the name.
128  * @param env                   The env of the current thread
129  *
130  * @exception                   If the class Process is not found the function throws 
131  *                                              the ClassNotFoundException. If the field name of 
132  *                                              this class is not found the function throws the exception 
133  *                                              NotSuchFieldException.  
134  *
135  * @return                              The name of the specified java process.
136  */
137 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
138
139 /*
140  * Class                org_simgrid_msg_Process
141  * Method               nativeInit
142  * Signature    ();
143  */
144 JNIEXPORT void JNICALL
145 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
146
147 /*
148  * Class                org_simgrid_msg_Process
149  * Method               create
150  * Signature    (Lorg/simgrid/msg/Host;)V
151  */
152 JNIEXPORT void JNICALL
153 Java_org_simgrid_msg_Process_create(JNIEnv * env,
154                                     jobject jprocess_arg,
155                                     jobject jhostname);
156
157 /*
158  * Class                org_simgrid_msg_Process
159  * Method               killAll
160  * Signature    (I)I
161  */
162 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
163     (JNIEnv *, jclass, jint);
164
165 /*
166  * Class                org_simgrid_msg_Process
167  * Method               fromPID
168  * Signature    (I)Lorg/simgrid/msg/Process;
169  */
170 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
171     (JNIEnv *, jclass, jint);
172
173 /*
174  * Class                org_simgrid_msg_Process
175  * Method               currentProcess
176  * Signature    ()Lorg/simgrid/msg/Process;
177  */
178 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
179     (JNIEnv *, jclass);
180 /*
181  * Class                org_simgrid_msg_Process
182  * Method               suspend
183  * Signature    (Lorg/simgrid/msg/Process;)V
184  */
185 JNIEXPORT void JNICALL
186 Java_org_simgrid_msg_Process_suspend(JNIEnv * env,
187                                           jobject jprocess);
188 /*
189  * Class                org_simgrid_msg_Process
190  * Method               resume
191  * Signature    (Lorg/simgrid/msg/Process;)V
192  */
193 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume
194     (JNIEnv *, jobject);
195 /*
196  * Class                org_simgrid_msg_Process
197  * Method               isSuspended
198  * Signature    (Lorg/simgrid/msg/Process;)Z
199  */
200 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
201     (JNIEnv *, jobject);
202 /*
203  * Class                org_simgrid_msg_Process
204  * Method               sleep
205  * Signature    (DI)V
206  */
207 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
208     (JNIEnv *, jclass, jlong, jint);
209
210 /*
211  * Class                org_simgrid_msg_Process
212  * Method               waitFor
213  * Signature    (D)V
214  */
215 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
216     (JNIEnv *, jobject, jdouble);
217 /*
218  * Class                org_simgrid_msg_Process
219  * Method               kill
220  * Signature    (Lorg/simgrid/msg/Process;)V
221  */
222 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
223     (JNIEnv *, jobject);
224
225 /*
226  * Class                org_simgrid_msg_Process
227  * Method               migrate
228  * Signature    (Lorg/simgrid/msg/Host;)V
229  */
230 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
231     (JNIEnv *, jobject, jobject);
232 /*
233  * Class                org_simgrid_msg_Process
234  * Method               setKillTime
235  * Signature    (D)V
236  */
237 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime
238     (JNIEnv *, jobject, jdouble);
239
240 #endif                          /* !MSG_JPROCESS_H */