}
/* try to suspend the process */
- if (MSG_OK != MSG_process_suspend(process))
- jxbt_throw_native(env, xbt_strdup("MSG_process_suspend() failed"));
+ MSG_error_t rv = MSG_process_suspend(process);
+
+ jxbt_check_res("MSG_process_suspend()",rv,MSG_OK,
+ bprintf("unexpected error , please report this bug"));
+
}
JNIEXPORT void JNICALL
}
/* try to resume the process */
- if (MSG_OK != MSG_process_resume(process))
- jxbt_throw_native(env, xbt_strdup("MSG_process_resume() failed"));
+ MSG_error_t rv = MSG_process_resume(process);
+
+ jxbt_check_res("MSG_process_resume()",rv,MSG_OK,
+ bprintf("unexpected error , please report this bug"));
}
JNIEXPORT jboolean JNICALL
Java_simgrid_msg_MsgNative_processWaitFor(JNIEnv * env, jclass cls,
jdouble seconds)
{
- if (MSG_OK != MSG_process_sleep((double) seconds))
- jxbt_throw_native(env,
- bprintf("MSG_process_change_host(%f) failed",
- (double) seconds));
+ MSG_error_t rv= MSG_process_sleep((double) seconds);
+
+ jxbt_check_res("MSG_process_sleep()",rv, MSG_HOST_FAILURE,
+ bprintf("while process was waiting for %f seconds",(double)seconds));
+
}
host = MSG_task_get_source(task);
if (!host->data) {
- jxbt_throw_native(env, xbt_strdup("MSG_task_get_source() failed"));
+ jxbt_throw_jni(env, "MSG_task_get_source() failed");
return NULL;
}
return;
}
- if (MSG_OK != MSG_task_cancel(ptask))
- jxbt_throw_native(env, xbt_strdup("MSG_task_cancel() failed"));
+ MSG_error_t rv = MSG_task_cancel(ptask);
+
+ jxbt_check_res("MSG_task_cancel()",rv,MSG_OK,
+ bprintf("unexpected error , please report this bug"));
}
JNIEXPORT jdouble JNICALL
return;
}
jtask = (jobject) task->data;
+
+ MSG_error_t rv = MSG_task_destroy(task);
+
+ jxbt_check_res("MSG_task_destroy()",rv,MSG_OK,
+ bprintf("unexpected error , please report this bug"));
- if (MSG_OK != MSG_task_destroy(task))
- jxbt_throw_native(env, xbt_strdup("MSG_task_destroy() failed"));
/* delete the global reference to the java task object */
jtask_delete_global_ref(jtask, env);
return;
}
- if (MSG_OK != MSG_task_execute(task))
- jxbt_throw_native(env, xbt_strdup("MSG_task_execute() failed"));
+ MSG_error_t rv = MSG_task_execute(task);
+
+ jxbt_check_res("MSG_task_execute()",rv,MSG_HOST_FAILURE|MSG_TASK_CANCELLED,
+ bprintf("while executing task %s", MSG_task_get_name(task)));
}
/***************************************************************************************
(*env)->ReleaseStringUTFChars(env, jalias, alias);
- if (MSG_OK != rv)
- jxbt_throw_native(env, xbt_strdup("MSG_task_send_bounded() failed"));
+ jxbt_check_res("MSG_task_send_bounded()",rv, MSG_HOST_FAILURE|MSG_TRANSFER_FAILURE|MSG_TIMEOUT_FAILURE,
+ bprintf("while sending task %s to mailbox %s with max rate %f", MSG_task_get_name(task),alias,(double)jmaxRate));
+
}
JNIEXPORT jobject JNICALL
(*env)->ReleaseStringUTFChars(env, jalias, alias);
- if (MSG_OK != rv) {
- jxbt_throw_native(env, xbt_strdup("MSG_task_receive_ext() failed"));
- return NULL;
- }
+ jxbt_check_res("MSG_task_receive_ext()",rv, MSG_HOST_FAILURE|MSG_TRANSFER_FAILURE|MSG_TIMEOUT_FAILURE,
+ bprintf("while receiving from mailbox %s",alias));
return (jobject) task->data;
}
details);
}
+
+// task Cancelled exception
+void jxbt_throw_task_cancelled(JNIEnv *env,char *details)
+{
+
+ jxbt_throw_by_name(env,
+ "simgrid/msg/TaskCancelledException",
+ details);
+
+}
\ No newline at end of file
jxbt_throw_transfer_failure(env,detail); \
} else if (res == MSG_TIMEOUT_FAILURE) { \
jxbt_throw_time_out_failure(env,detail); \
+ } else if (res == MSG_TASK_CANCELLED){ \
+ jxbt_throw_task_cancelled(env,detail); \
} } while (0)
/** Thrown on internal error of this layer, or on problem with JNI */
void jxbt_throw_host_failure(JNIEnv *env,char *details);
/** Thrown when a time out accures While Sending task */
void jxbt_throw_time_out_failure(JNIEnv *env,char *details);
+/**Thrown when a task is canceled */
+void jxbt_throw_task_cancelled(JNIEnv *env,char *details);
#endif /* ! JXBT_UTILITY_H */
process.properties = properties;
properties = new Hashtable();
- } catch(NativeException e) {
- System.out.println(e.toString());
- e.printStackTrace();
-
} catch(HostNotFoundException e) {
System.out.println(e.toString());
e.printStackTrace();
* NativeException if the native version of this method failed.
*/
public static Host getByName(String name)
- throws HostNotFoundException, NativeException {
+ throws HostNotFoundException {
if (name==null)
throw new NullPointerException("No host can have a null name");
return MsgNative.hostGetByName(name);
* @return The count of the installed hosts.
*
*/
- public static int getCount() throws NativeException {
+ public static int getCount() {
return MsgNative.hostGetCount();
}
*
* @return An array containing all the hosts installed.
*
- * @exception NativeException if the native version of this method failed.
*/
- public static Host[] all() throws NativeException {
+ public static Host[] all() {
return MsgNative.allHosts();
}
*
* @return The name of the host.
*
- * @exception NativeException FIXME: check when
*/
- public String getName() throws NativeException {
+ public String getName() {
return MsgNative.hostGetName(this);
}
*
* @param process The valid (binded with a native process) java process to resume.
*
- * @exception NativeException if the SimGrid native code failed.
*
* @see Process.restart()
*/
- final static native void processResume(Process process) throws NativeException;
+ final static native void processResume(Process process);
/**
* The natively implemented method to test if MSG process is suspended.
* @param process The (valid) process to migrate.
* @param host A (valid) host where move the process.
*
- * @exception NativeException if the SimGrid native code failed.
*
* @see Process.migrate()
* @see Host.getByName()
*/
- final static native void processChangeHost(Process process, Host host) throws NativeException;
+ final static native void processChangeHost(Process process, Host host) ;
/**
* The natively implemented native to request the current process to sleep
*
* @param seconds The time the current process must sleep.
*
- * @exception NativeException if the SimGrid native code failed.
+ * @exception HostFailureException if the SimGrid native code failed.
*
* @see Process.waitFor()
*/
- final static native void processWaitFor(double seconds) throws NativeException;
+ final static native void processWaitFor(double seconds) throws HostFailureException;
/**
* The natively implemented native method to exit a process.
* @return The host having the specified name.
*
* @exception HostNotFoundException if there is no such host
- * NativeException if the SimGrid native code failed.
+ *
*
* @see Host.getByName()
*/
- final static native Host hostGetByName(String name) throws HostNotFoundException, NativeException;
+ final static native Host hostGetByName(String name) throws HostNotFoundException;
/**
* The natively implemented method to get the name of an MSG host.
*
* @return The source of the task.
*
- * @exception NativeException if the SimGrid native code failed.
*
* @see Task.getSource()
*/
- final static native Host taskGetSource(Task task) throws NativeException;
+ final static native Host taskGetSource(Task task);
/**
* The natively implemented method to get the name of the task.
*
* @param task The task to cancel.
*
- * @exception NativeException if the cancellation failed.
*
* @see Task.cancel().
*/
- final static native void taskCancel(Task task) throws NativeException;
+ final static native void taskCancel(Task task);
/**
* The natively implemented method to create a MSG parallel task.
*
* @param The task to destroy.
*
- * @exception NativeException on error in the C world
*
* @see Task.destroy()
*/
- final static native void taskDestroy(Task task) throws NativeException;
+ final static native void taskDestroy(Task task) ;
/**
* The natively implemented method to execute a MSG task.
*
* @param task The task to execute.
*
- * @exception NativeException on error in the C world
+ * @exception HostFailureException,TaskCancelledException on error in the C world
*
* @see Task.execute()
*/
- final static native void taskExecute(Task task) throws NativeException;
+ final static native void taskExecute(Task task) throws HostFailureException,TaskCancelledException;
/* ****************************************************************
* Communication methods thru mailboxes *
**************************************************************** */
- final static native void taskSend(String alias, Task task, double timeout) throws NativeException,TransferFailureException,HostFailureException,TimeoutException;
- final static native Task taskReceive(String alias, double timeout, Host host) throws NativeException;
- final static native int taskListenFrom(String alias) throws NativeException;
+ final static native void taskSend(String alias, Task task, double timeout) throws TransferFailureException,HostFailureException,TimeoutException;
+ final static native Task taskReceive(String alias, double timeout, Host host) throws TransferFailureException,HostFailureException,TimeoutException;
+ final static native int taskListenFrom(String alias);
final static native boolean taskListen(String alias);
final static native int taskListenFromHost(String alias, Host host);
*
* @exception NativeException on error in the C world
*/
- final static native void taskSendBounded(String alias, Task task, double maxrate) throws NativeException;
+ final static native void taskSendBounded(String alias, Task task, double maxrate) throws TransferFailureException,HostFailureException,TimeoutException;
}
\ No newline at end of file
* @param name The name of the process.
*
* @exception HostNotFoundException if no host with this name exists.
- * NativeException
+ *
*
*/
- public Process(String hostname, String name) throws HostNotFoundException, NativeException {
+ public Process(String hostname, String name) throws HostNotFoundException {
this(Host.getByName(hostname), name, null);
}
/**
* Suspends the process by suspending the task on which it was
* waiting for the completion.
*
- * @exception NativeException on error in the native SimGrid code
*/
- public void pause() throws NativeException {
+ public void pause() {
MsgNative.processSuspend(this);
}
/**
* Resumes a suspended process by resuming the task on which it was
* waiting for the completion.
*
- * @exception NativeException on error in the native SimGrid code
*
*/
- public void restart() throws NativeException {
+ public void restart() {
MsgNative.processResume(this);
}
/**
*
* @return The PID of the process.
*
- * @exception NativeException on error in the native SimGrid code
*/
- public int getPID() throws NativeException {
+ public int getPID() {
return MsgNative.processGetPID(this);
}
/**
*
* @return The PID of the parent of the process.
*
- * @exception NativeException on error in the native SimGrid code
*/
- public int getPPID() throws NativeException {
+ public int getPPID() {
return MsgNative.processGetPPID(this);
}
/**
*
* @return The current process.
*
- * @exception NativeException on error in the native SimGrid code
*/
- public static Process currentProcess() throws NativeException {
+ public static Process currentProcess() {
return MsgNative.processSelf();
}
/**
*
* @param host The host where to migrate the process.
*
- * @exception NativeException on error in the native SimGrid code
*/
- public void migrate(Host host) throws NativeException {
+ public void migrate(Host host) {
MsgNative.processChangeHost(this, host);
}
/**
*
* @param seconds The time the current process must sleep.
*
- * @exception NativeException on error in the native SimGrid code
+ * @exception HostFailureException on error in the native SimGrid code
*/
- public static void waitFor(double seconds) throws NativeException {
+ public static void waitFor(double seconds) throws HostFailureException {
MsgNative.processWaitFor(seconds);
}
public void showArgs() {
* @throws TimeoutException
* @throws HostFailureException
* @throws TransferFailureException */
- public void taskSend(String mailbox, Task task, double timeout) throws NativeException, TransferFailureException, HostFailureException, TimeoutException {
+ public void taskSend(String mailbox, Task task, double timeout) throws TransferFailureException, HostFailureException, TimeoutException {
MsgNative.taskSend(mailbox, task, timeout);
}
* @throws TimeoutException
* @throws HostFailureException
* @throws TransferFailureException */
- public void taskSend(String mailbox, Task task) throws NativeException, TransferFailureException, HostFailureException, TimeoutException {
+ public void taskSend(String mailbox, Task task) throws TransferFailureException, HostFailureException, TimeoutException {
MsgNative.taskSend(mailbox, task, -1);
}
/** Receive a task on mailbox associated with the specified mailbox */
- public Task taskReceive(String mailbox) throws NativeException {
+ public Task taskReceive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
return MsgNative.taskReceive(mailbox, -1.0, null);
}
/** Receive a task on mailbox associated with the specified alias (waiting at most given time) */
- public Task taskReceive(String mailbox, double timeout) throws NativeException {
+ public Task taskReceive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException {
return MsgNative.taskReceive(mailbox, timeout, null);
}
/** Receive a task on mailbox associated with the specified alias from given sender */
- public Task taskReceive(String mailbox, double timeout, Host host) throws NativeException {
+ public Task taskReceive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
return MsgNative.taskReceive(mailbox, timeout, host);
}
/** Receive a task on mailbox associated with the specified alias from given sender*/
- public Task taskReceive(String mailbox, Host host) throws NativeException {
+ public Task taskReceive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
return MsgNative.taskReceive(mailbox, -1.0, host);
}
}
return MsgNative.taskGetSender(this);
}
/** Gets the source of the task */
- public Host getSource() throws NativeException {
+ public Host getSource() {
return MsgNative.taskGetSource(this);
}
/** Gets the computing amount of the task */
/**
* Executes a task on the location on which the process is running.
*
- * @exception NativeException if the execution failed.
+ * @exception HostFailureException,TaskCancelledException
*/
- public void execute() throws NativeException {
+ public void execute() throws HostFailureException,TaskCancelledException {
MsgNative.taskExecute(this);
}
/**
*
* @exception NativeException if the cancellation failed.
*/
- public void cancel() throws NativeException {
+ public void cancel() {
MsgNative.taskCancel(this);
}
/** Deletes a task.
/**
* Sends the task on the mailbox identified by the specified name
*
- * @exception NativeException if the retrieval fails.
* @throws TimeoutException
* @throws HostFailureException
* @throws TransferFailureException
*/
- public void send(String mailbox) throws NativeException, TransferFailureException, HostFailureException, TimeoutException {
+ public void send(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
MsgNative.taskSend(mailbox, this, -1);
}
/**
* Sends the task on the mailbox identified by the specified alias (capping the sending rate to \a maxrate)
*
- * @exception NativeException if the retrieval fails.
+ * @exception TransferFailureException, HostFailureException, TimeoutException.
*/
- public void sendBounded(String alias, double maxrate) throws NativeException {
+ public void sendBounded(String alias, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException {
MsgNative.taskSendBounded(alias, this, maxrate);
}
/**
* Retrieves next task from the mailbox identified by the specified name
*
- * @exception NativeException if the retrieval fails.
+ * @exception TransferFailureException, HostFailureException, TimeoutException if the retrieval fails.
*/
- public static Task receive(String mailbox) throws NativeException {
+ public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
return MsgNative.taskReceive(mailbox, -1.0, null);
}
/**
* Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds)
*
- * @exception NativeException if the retrieval fails.
+ * @exception TransferFailureException, HostFailureException, TimeoutException if the retrieval fails.
*/
- public static Task receive(String mailbox, double timeout) throws NativeException {
+ public static Task receive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException {
return MsgNative.taskReceive(mailbox, timeout, null);
}
/**
* Retrieves next task sent by a given host on the mailbox identified by the specified alias
*
- * @exception NativeException if the retrieval fails.
+ * @exception TransferFailureException, HostFailureException, TimeoutException if the retrieval fails.
*/
- public static Task receive(String mailbox, Host host) throws NativeException {
+ public static Task receive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
return MsgNative.taskReceive(mailbox, -1.0, host);
}
/**
* Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds)
*
- * @exception NativeException if the retrieval fails.
+ * @exception TransferFailureException, HostFailureException, TimeoutException if the retrieval fails.
*/
- public static Task receive(String mailbox, double timeout, Host host) throws NativeException {
+ public static Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
return MsgNative.taskReceive(mailbox, timeout, host);
}
/**
* Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it
*
- * @exception NativeException if the retrieval fails.
*/
- public static int listenFrom(String mailbox) throws NativeException {
+ public static int listenFrom(String mailbox) {
return MsgNative.taskListenFrom(mailbox);
}
/**
* Listen whether there is a waiting task on the mailbox identified by the specified alias
*
- * @exception NativeException if the retrieval fails.
*/
- public static boolean listen(String mailbox) throws NativeException {
+ public static boolean listen(String mailbox) {
return MsgNative.taskListen(mailbox);
}
/**
* Counts the number of tasks waiting to be received on the \a mailbox identified by the specified alia and sended by the specified \a host.
*
- * @exception NativeException if the retrieval fails.
*/
- public static int listenFromHost(String alias, Host host) throws NativeException {
+ public static int listenFromHost(String alias, Host host) {
return MsgNative.taskListenFromHost(alias, host);
}
}