#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;
(process->simdata->s_process->context))->jprocess;
}
-
/*
* The MSG process connected functions implementation.
*/
m_process_t process = jprocess_to_native_process(jprocess, env);
if (!process) {
- jxbt_throw_notbound(env, "process", jprocess);
+ jxbt_throw_notbound(env,"process", jprocess);
return;
}
return jprocess;
}
-
-JNIEXPORT jint JNICALL
-Java_simgrid_msg_MsgNative_processSelfPID(JNIEnv * env, jclass cls)
-{
- return (jint) MSG_process_self_PID();
-}
-
-
-JNIEXPORT jint JNICALL
-Java_simgrid_msg_MsgNative_processSelfPPID(JNIEnv * env, jclass cls)
-{
- return (jint) MSG_process_self_PPID();
-}
-
JNIEXPORT void JNICALL
Java_simgrid_msg_MsgNative_processChangeHost(JNIEnv * env, jclass cls,
jobject jhost)
jdouble jmessageSize)
{
m_task_t task; /* the native task to create */
- const char *name; /* the name of the task */
+ const char *name=NULL; /* the name of the task */
if (jcomputeDuration < 0) {
jxbt_throw_illegal(env,
return;
}
- if (!jname) {
- jxbt_throw_null(env, xbt_strdup("Task name cannot be null"));
- return;
+ if (jname) {
+ /* get the C string from the java string */
+ name = (*env)->GetStringUTFChars(env, jname, 0);
}
- /* get the C string from the java string */
- name = (*env)->GetStringUTFChars(env, jname, 0);
/* create the task */
task =
MSG_task_create(name, (double) jcomputeDuration, (double) jmessageSize,
NULL);
- (*env)->ReleaseStringUTFChars(env, jname, name);
+ if (jname)
+ (*env)->ReleaseStringUTFChars(env, jname, name);
/* bind & store the task */
jtask_bind(jtask, task, env);
(*env)->ReleaseStringUTFChars(env, jalias, alias);
+ /* 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 if ( rv == MSG_TIMEOUT_FAILURE )
+ jxbt_throw_time_out_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);