Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
specify the bindir for some tesh files
[simgrid.git] / src / bindings / java / jmsg_process.h
1 /* Functions related to the java process instances.                         */
2
3 /* Copyright (c) 2007-2015. 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 <simgrid/msg.h>
14 #include <simgrid/simix.h>
15
16 SG_BEGIN_DECL();
17
18 //Cached java fields
19 extern jfieldID jprocess_field_Process_bind;
20 extern jfieldID jprocess_field_Process_host;
21 extern jfieldID jprocess_field_Process_killTime;
22 extern jfieldID jprocess_field_Process_id;
23 extern jfieldID jprocess_field_Process_name;
24 extern jfieldID jprocess_field_Process_pid;
25 extern jfieldID jprocess_field_Process_ppid;
26
27 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject);
28
29 jobject native_to_java_process(msg_process_t process);
30
31 /**
32  * This function returns a global reference to the  java process instance specified by the parameter jprocess.
33  *
34  * @param jprocess  The original java process instance.
35  * @param env       The env of the current thread
36  *
37  * @return          The global reference to the original java process instance.
38  */
39 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
40
41 /**
42  * This function delete a global reference to a java process instance.
43  * If the java process is alive the function joins it and stops it before.
44  *
45  * @param jprocess The global refernce to delete.
46  * @param env      The env of the current thread
47  *
48  * @see          jprocess_join()
49  * @see          jprocess_exit()
50  */
51 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
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 the ClassNotFoundException. If the method
60                     join() of this class is not found the function throws the exception NotSuchMethodException.
61  */
62 void jprocess_join(jobject jprocess, JNIEnv * env);
63
64 /**
65  * This function associated a native process to a java process instance.
66  *
67  * @param jprocess   The java process instance.
68  * @param process    The native process to bind.
69  * @param env        The env of the current thread
70  *
71  * @exception        If the class Process is not found the function throws the ClassNotFoundException. If the field
72  *                   bind of this class is not found the function throws the exception NotSuchFieldException.
73  */
74 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env);
75
76 /**
77  * This function returns a native process from a java process instance.
78  *
79  * @param jprocess   The java process object from which get the native process.
80  * @param env        The env of the current thread
81  *
82  * @return           The function returns the native process associated to the java process object.
83  *
84  * @exception        If the class Process is not found the function throws the ClassNotFoundException. If the field
85  *                   bind of this class is not found the function throws the exception NotSuchFieldException.
86  */
87 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
88
89 /**
90  * This function gets the id of the specified java process.
91  *
92  * @param jprocess   The java process to get the id.
93  * @param env        The env of the current thread
94  *
95  * @exception        If the class Process is not found the function throws the ClassNotFoundException. If the field id
96  *                   of this class is not found the function throws the exception NotSuchFieldException.
97  *
98  * @return        The id of the specified java process.
99  */
100 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
101
102 /**
103  * This function tests if a java process instance is valid.
104  * A java process object is valid if it is bind to a native process.
105  *
106  * @param jprocess   The java process to test the validity.
107  * @param env        The env of the current thread
108  *
109  * @return           If the java process is valid the function returns true. Otherwise the function returns false.
110  */
111 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
112
113 /**
114  * This function gets the name of the specified java process.
115  *
116  * @param jprocess  The java process to get the name.
117  * @param env       The env of the current thread
118  *
119  * @exception       If the class Process is not found the function throws the ClassNotFoundException. If the field name
120  *                  of this class is not found the function throws the exception NotSuchFieldException.
121  *
122  * @return        The name of the specified java process.
123  */
124 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
125
126 /*
127  * Class    org_simgrid_msg_Process
128  * Method    nativeInit
129  * Signature  ();
130  */
131 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
132
133 /*
134  * Class    org_simgrid_msg_Process
135  * Method    create
136  * Signature  (Lorg/simgrid/msg/Host;)V
137  */
138 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject jprocess_arg, jobject jhostname);
139
140 /*
141  * Class    org_simgrid_msg_Process
142  * Method    killAll
143  * Signature  (I)I
144  */
145 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll (JNIEnv *, jclass, jint);
146
147 /*
148  * Class    org_simgrid_msg_Process
149  * Method    fromPID
150  * Signature  (I)Lorg/simgrid/msg/Process;
151  */
152 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID (JNIEnv *, jclass, jint);
153
154 /*
155  * Class        org_simgrid_msg_Process
156  * Method       getProperty
157  * Signature    (D)V
158  */
159 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname);
160
161 /*
162  * Class    org_simgrid_msg_Process
163  * Method    currentProcess
164  * Signature  ()Lorg/simgrid/msg/Process;
165  */
166 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess (JNIEnv *, jclass);
167
168 /*
169  * Class    org_simgrid_msg_Process
170  * Method    suspend
171  * Signature  (Lorg/simgrid/msg/Process;)V
172  */
173 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobject jprocess);
174
175 /*
176  * Class    org_simgrid_msg_Process
177  * Method    resume
178  * Signature  (Lorg/simgrid/msg/Process;)V
179  */
180 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume (JNIEnv *, jobject);
181
182 /*
183  * Class        org_simgrid_msg_Process
184  * Method       setAutoRestart
185  * Signature    (Lorg/simgrid/msg/Process;Z)V
186  */
187 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *, jobject, jboolean);
188
189 /*
190  * Class        org_simgrid_msg_Process
191  * Method       restart
192  * Signature    (Lorg/simgrid/msg/Process;)V
193  */
194 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *, jobject);
195
196 /*
197  * Class    org_simgrid_msg_Process
198  * Method    isSuspended
199  * Signature  (Lorg/simgrid/msg/Process;)Z
200  */
201 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended (JNIEnv *, jobject);
202
203 /*
204  * Class    org_simgrid_msg_Process
205  * Method    sleep
206  * Signature  (DI)V
207  */
208 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep (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 (JNIEnv *, jobject, jdouble);
216
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 (JNIEnv *, jobject);
223
224 /*
225  * Class    org_simgrid_msg_Process
226  * Method    migrate
227  * Signature  (Lorg/simgrid/msg/Host;)V
228  */
229 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate (JNIEnv *, jobject, jobject);
230
231 /*
232  * Class    org_simgrid_msg_Process
233  * Method    setKillTime
234  * Signature  (D)V
235  */
236 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime (JNIEnv *, jobject, jdouble);
237
238 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
239
240 SG_END_DECL();
241 #endif                          /* !MSG_JPROCESS_H */