Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
throw the right exception corresponding to HostFailureException, TransferFailureException
authorcoldpeace <coldpeace@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 15 Mar 2010 10:04:41 +0000 (10:04 +0000)
committercoldpeace <coldpeace@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 15 Mar 2010 10:04:41 +0000 (10:04 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7248 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/java/jmsg.c
src/java/jmsg_application_handler.c
src/java/jxbt_utilities.c
src/java/jxbt_utilities.h
src/java/simgrid/msg/Msg.java
src/java/simgrid/msg/MsgException.java
src/java/simgrid/msg/MsgNative.java

index 24d1413..e86c09f 100644 (file)
 #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);
index 120e8ea..075a786 100644 (file)
@@ -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"
index 0a4ea4b..67eca4f 100644 (file)
@@ -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
index 78ddb4b..f87391c 100644 (file)
@@ -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 */
index 26fa5c0..15dffa1 100644 (file)
@@ -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();
        }
index e7a89ea..0699e48 100644 (file)
@@ -36,7 +36,8 @@ public abstract class MsgException extends Exception {
    * Constructs an <code>MsgException</code> with a detail message. 
    *
    * @param   s   the detail message.
-   */ public MsgException(String s) {
+   */ 
+  public MsgException(String s) {
     super(s);
   }
 }
index 354afa2..e64718b 100644 (file)
@@ -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);