Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix github issue (#132)
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 13 Feb 2019 16:42:44 +0000 (17:42 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 13 Feb 2019 16:44:23 +0000 (17:44 +0100)
The Host.off() now throws a HostFailure exception if it captures that
an actor was ended by this action.  When a Java process wants to turn
off its own host (and thus die), it now has to catch a HostFailure
exception and the simulation can goes on.

ChangeLog
src/bindings/java/jmsg_host.cpp
src/bindings/java/org/simgrid/msg/Host.java

index e086474..87eab8d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,6 +36,7 @@ XML
    XML file version remains 4.2 since old files are still compatible.
 
 Fixed bugs:
+ - #132: Java : a process can not shut down its own host
  - #261: Document the parameters of parallel execution's constructor
  - #300: [s4u] BarrierPtr is missing
  - #314: SMPI args internal cleanup
index a6ed529..299d8db 100644 (file)
@@ -10,6 +10,7 @@
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
 
+#include "JavaContext.hpp"
 #include "jmsg.hpp"
 #include "jmsg_host.h"
 #include "jmsg_storage.h"
@@ -141,7 +142,8 @@ JNIEXPORT void JNICALL 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);
+  if (not simgrid::kernel::context::StopRequest::try_n_catch([host]() { MSG_host_off(host); }))
+    jxbt_throw_host_failure(env, "");
 }
 
 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Host_getCount(JNIEnv * env, jclass cls) {
@@ -414,4 +416,4 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Host_getAvgLoad (JNIEnv *env, job
   }
 
   return MSG_host_get_avg_load(host);
-}
\ No newline at end of file
+}
index fc1322e..6222186 100644 (file)
@@ -111,7 +111,7 @@ public class Host {
        /** Starts the host if it is off */
        public native void on();
        /** Stops the host if it is on */
-       public native void off();
+       public native void off() throws HostFailureException;
 
        /**
         * This method returns the speed of the processor of a host (in flops),