From 49ae6e61753b41f28accc4c0890097286d660e9f Mon Sep 17 00:00:00 2001 From: Adrien Lebre Date: Thu, 24 Jul 2014 15:49:37 +0200 Subject: [PATCH] fix minor issues in the management of Java Exceptions + comment process cancelled exception call --- examples/java/cloud/migration/Test.java | 1 + src/bindings/java/jmsg.c | 5 ++++- src/bindings/java/jmsg_host.c | 2 +- src/bindings/java/org/simgrid/msg/Process.java | 3 +-- src/bindings/java/smx_context_java.c | 5 ++++- src/msg/msg_vm.c | 5 ++++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/examples/java/cloud/migration/Test.java b/examples/java/cloud/migration/Test.java index f1b5936056..7edd53808f 100644 --- a/examples/java/cloud/migration/Test.java +++ b/examples/java/cloud/migration/Test.java @@ -129,6 +129,7 @@ public class Test extends Process{ endTime = Msg.getClock(); Msg.info(" - End of Migration from host 1 to host 0 (duration:"+(endTime-startTime)+")"); + Msg.info("\n \n \nRound trip of VM1 (load "+load2+"%)"); vm1.setLoad(load2); Msg.info(" - Launch migration from host 0 to host 1"); diff --git a/src/bindings/java/jmsg.c b/src/bindings/java/jmsg.c index ecb2108691..c11ba91e7b 100644 --- a/src/bindings/java/jmsg.c +++ b/src/bindings/java/jmsg.c @@ -67,8 +67,11 @@ void jmsg_throw_status(JNIEnv *env, msg_error_t status) { case MSG_HOST_FAILURE: jxbt_throw_host_failure(env,NULL); break; + case MSG_TASK_CANCELED: + jxbt_throw_task_cancelled(env,NULL); + break; default: - jxbt_throw_native(env,xbt_strdup("communication failed")); + jxbt_throw_native(env,xbt_strdup("undefined message failed (please see jmsg_throw_status function in jmsg.c)")); } } diff --git a/src/bindings/java/jmsg_host.c b/src/bindings/java/jmsg_host.c index 9cf997703f..279130af1a 100644 --- a/src/bindings/java/jmsg_host.c +++ b/src/bindings/java/jmsg_host.c @@ -165,7 +165,7 @@ Java_org_simgrid_msg_Host_on(JNIEnv *env, jobject jhost) { JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_off(JNIEnv *env, jobject jhost) { msg_host_t host = jhost_get_native(env, jhost); - MSG_host_off(host); + MSG_host_off(host); } JNIEXPORT jint JNICALL diff --git a/src/bindings/java/org/simgrid/msg/Process.java b/src/bindings/java/org/simgrid/msg/Process.java index 2fe319e41e..5791ccdaec 100644 --- a/src/bindings/java/org/simgrid/msg/Process.java +++ b/src/bindings/java/org/simgrid/msg/Process.java @@ -378,8 +378,7 @@ public abstract class Process implements Runnable { System.exit(1); } catch(ProcessKilledError pk) { - - } + } exit(); } diff --git a/src/bindings/java/smx_context_java.c b/src/bindings/java/smx_context_java.c index de3518834b..2e94604ff6 100644 --- a/src/bindings/java/smx_context_java.c +++ b/src/bindings/java/smx_context_java.c @@ -153,8 +153,11 @@ void smx_ctx_java_stop(smx_context_t context) if (context->iwannadie) { context->iwannadie = 0; JNIEnv *env = get_current_thread_env(); + XBT_DEBUG("Gonnal launch Killed Error"); jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", xbt_strdup("Process killed :)")); - THROWF(cancel_error, 0, "process cancelled"); + // TODO emptty/adsein, comment the following line. This avoid to raise process cancelled exception at the Java level but + // it impacts the shutdown of VMs :( see java-cloud example + //THROWF(cancel_error, 0, "process cancelled"); } else { smx_ctx_base_stop(context); /* detach the thread and kills it */ diff --git a/src/msg/msg_vm.c b/src/msg/msg_vm.c index 4539a93497..bc400f4918 100644 --- a/src/msg/msg_vm.c +++ b/src/msg/msg_vm.c @@ -391,10 +391,13 @@ static int migration_rx_fun(int argc, char *argv[]) } - /* deinstall the current affinity setting */ + /* deinstall the current affinity setting for the CPU */ simcall_vm_set_affinity(ms->vm, ms->src_pm, 0); + /* Update the vm location */ simcall_vm_migrate(ms->vm, ms->dst_pm); + + /* Resume the VM */ simcall_vm_resume(ms->vm); /* install the affinity setting of the VM on the destination pm */ -- 2.20.1