From: coldpeace Date: Mon, 15 Mar 2010 10:04:41 +0000 (+0000) Subject: throw the right exception corresponding to HostFailureException, TransferFailureException X-Git-Tag: SVN~491 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6d640ca2a6ebe67c9b800e4ac1395862c807d844 throw the right exception corresponding to HostFailureException, TransferFailureException git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7248 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/java/jmsg.c b/src/java/jmsg.c index 24d141360a..e86c09f8b4 100644 --- a/src/java/jmsg.c +++ b/src/java/jmsg.c @@ -20,14 +20,10 @@ #include "jmsg_application_handler.h" #include "jxbt_utilities.h" - #include "jmsg.h" - #include "msg/mailbox.h" - #include "surf/surfxml_parse.h" - XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(jmsg); static JavaVM *__java_vm = NULL; @@ -986,14 +982,24 @@ Java_simgrid_msg_MsgNative_taskSend(JNIEnv * env, jclass cls, (*env)->ReleaseStringUTFChars(env, jalias, alias); - /* FIXME throw the right exception corresponding to HostFailureException, TransferFailureException, TimeoutFailureException + /* throw the right exception corresponding to HostFailureException, TransferFailureException, TimeoutFailureException * Note: these exceptions must be created beforehand * then, you want to create some functions like jxbt_throw_notbound() * then, you must declare in the MsgNative stuff that these native functions can throw these exceptions */ if (MSG_OK != rv) - jxbt_throw_native(env, xbt_strdup("MSG_task_send_with_timeout() failed")); - + { + + if ( rv == MSG_TRANSFER_FAILURE ) + jxbt_throw_transfer_failure(env,MSG_task_get_name(task),alias); + + else if ( rv == MSG_HOST_FAILURE ) + jxbt_throw_host_failure(env,MSG_task_get_name(task),alias); + + else + jxbt_throw_native(env, xbt_strdup("MSG_task_send_with_timeout() failed")); + + } } JNIEXPORT void JNICALL @@ -1074,7 +1080,6 @@ JNIEXPORT jint JNICALL Java_simgrid_msg_MsgNative_taskListenFromHost(JNIEnv * env, jclass cls, jstring jalias, jobject jhost) { - int rv; const char *alias; @@ -1084,7 +1089,6 @@ Java_simgrid_msg_MsgNative_taskListenFromHost(JNIEnv * env, jclass cls, jxbt_throw_notbound(env, "host", jhost); return -1; } - alias = (*env)->GetStringUTFChars(env, jalias, 0); rv = MSG_task_listen_from_host(alias, host); diff --git a/src/java/jmsg_application_handler.c b/src/java/jmsg_application_handler.c index 120e8ea076..075a786b4f 100644 --- a/src/java/jmsg_application_handler.c +++ b/src/java/jmsg_application_handler.c @@ -6,7 +6,6 @@ * * Upcalls to the Java functions used as callback to the FleXML application file parser. */ - #include "jmsg_application_handler.h" #include "jmsg.h" diff --git a/src/java/jxbt_utilities.c b/src/java/jxbt_utilities.c index 0a4ea4bb6f..67eca4fec1 100644 --- a/src/java/jxbt_utilities.c +++ b/src/java/jxbt_utilities.c @@ -102,7 +102,6 @@ jmethodID jxbt_get_static_smethod(JNIEnv * env, const char *classname, { jclass cls; - jmethodID id; cls = jxbt_get_class(env, classname); @@ -129,7 +128,6 @@ jmethodID jxbt_get_smethod(JNIEnv * env, const char *classname, { jclass cls; - jmethodID id; cls = jxbt_get_class(env, classname); @@ -246,7 +244,6 @@ void jxbt_throw_null(JNIEnv * env, char *msg) jxbt_throw_by_name(env, "java/lang/NullPointerException", msg); } - /* Errors on user side */ void jxbt_throw_illegal(JNIEnv * env, char *msg) { @@ -266,3 +263,23 @@ void jxbt_throw_process_not_found(JNIEnv * env, const char *invalid_name) "simgrid/msg/ProcessNotFoundException", bprintf("No such process: %s", invalid_name)); } + +// tranfert failure +void jxbt_throw_transfer_failure(JNIEnv *env,const char *task_name,const char *alias) +{ + + jxbt_throw_by_name(env, + "simgrid/msg/TransferFailureException", + bprintf("There has been a problem during your task transfer (task :%s / alias :%s)",task_name,alias)); + +} + +// host failure Exception +void jxbt_throw_host_failure(JNIEnv *env,const char *task_name,const char *alias) +{ + + jxbt_throw_by_name(env, + "simgrid/msg/HostFailureException", + bprintf("Host Failure while sending (task :%s / alias %s) : The host on which you are running has just been rebooted",task_name,alias)); + +} \ No newline at end of file diff --git a/src/java/jxbt_utilities.h b/src/java/jxbt_utilities.h index 78ddb4b03e..f87391ce9c 100644 --- a/src/java/jxbt_utilities.h +++ b/src/java/jxbt_utilities.h @@ -75,5 +75,9 @@ void jxbt_throw_illegal(JNIEnv * env, char *msg); void jxbt_throw_host_not_found(JNIEnv * env, const char *invalid_name); /** Thrown when looking for an host from name does not lead to anything */ void jxbt_throw_process_not_found(JNIEnv * env, const char *invalid_name); +/** Thrown when a transfer failure accure while Sending task */ +void jxbt_throw_transfer_failure(JNIEnv * env,const char *task_name,const char *alias); +/** Thrown when a host failure accures while Sending task*/ +void jxbt_throw_host_failure(JNIEnv *env,const char *task_name,const char *alias); #endif /* ! JXBT_UTILITY_H */ diff --git a/src/java/simgrid/msg/Msg.java b/src/java/simgrid/msg/Msg.java index 26fa5c03ec..15dffa119a 100644 --- a/src/java/simgrid/msg/Msg.java +++ b/src/java/simgrid/msg/Msg.java @@ -35,7 +35,7 @@ public final class Msg { /** Something must be not perfectly clean (but I may be paranoid freak...) */ public static final int WARNING = 1; - /** There has been a problem during you task transfer. + /** There has been a problem during your task transfer. * Either the network is down or the remote host has been shutdown */ public static final int TRANSFERT_FAILURE = 2; @@ -50,7 +50,6 @@ public final class Msg { /** You've done something wrong. You'd better look at it... */ public static final int FATAL_ERROR = 5; - /** Retrieve the simulation time */ public final static native double getClock(); @@ -108,7 +107,6 @@ public final class Msg { /* Load the platform and deploy the application */ Msg.createEnvironment(args[0]); Msg.deployApplication(args[1]); - /* Execute the simulation */ Msg.run(); } diff --git a/src/java/simgrid/msg/MsgException.java b/src/java/simgrid/msg/MsgException.java index e7a89ead06..0699e48b94 100644 --- a/src/java/simgrid/msg/MsgException.java +++ b/src/java/simgrid/msg/MsgException.java @@ -36,7 +36,8 @@ public abstract class MsgException extends Exception { * Constructs an MsgException with a detail message. * * @param s the detail message. - */ public MsgException(String s) { + */ + public MsgException(String s) { super(s); } } diff --git a/src/java/simgrid/msg/MsgNative.java b/src/java/simgrid/msg/MsgNative.java index 354afa280e..e64718b765 100644 --- a/src/java/simgrid/msg/MsgNative.java +++ b/src/java/simgrid/msg/MsgNative.java @@ -426,7 +426,7 @@ final class MsgNative { **************************************************************** */ - final static native void taskSend(String alias, Task task, double timeout) throws NativeException; + final static native void taskSend(String alias, Task task, double timeout) throws TransferFailureException,HostFailureException,NativeException; 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 boolean taskListen(String alias);