#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;
(*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
Java_simgrid_msg_MsgNative_taskListenFromHost(JNIEnv * env, jclass cls,
jstring jalias, jobject jhost)
{
-
int rv;
const char *alias;
jxbt_throw_notbound(env, "host", jhost);
return -1;
}
-
alias = (*env)->GetStringUTFChars(env, jalias, 0);
rv = MSG_task_listen_from_host(alias, host);
*
* Upcalls to the Java functions used as callback to the FleXML application file parser.
*/
-
#include "jmsg_application_handler.h"
#include "jmsg.h"
{
jclass cls;
-
jmethodID id;
cls = jxbt_get_class(env, classname);
{
jclass cls;
-
jmethodID id;
cls = jxbt_get_class(env, classname);
jxbt_throw_by_name(env, "java/lang/NullPointerException", msg);
}
-
/* Errors on user side */
void jxbt_throw_illegal(JNIEnv * env, char *msg)
{
"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
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 */
/** 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;
/** 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();
/* Load the platform and deploy the application */
Msg.createEnvironment(args[0]);
Msg.deployApplication(args[1]);
-
/* Execute the simulation */
Msg.run();
}
* Constructs an <code>MsgException</code> with a detail message.
*
* @param s the detail message.
- */ public MsgException(String s) {
+ */
+ public MsgException(String s) {
super(s);
}
}
**************************************************************** */
- 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);