Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remote Exec should not survive to a host failure
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 23 Aug 2021 15:41:21 +0000 (17:41 +0200)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Mon, 23 Aug 2021 15:41:21 +0000 (17:41 +0200)
examples/cpp/exec-remote/s4u-exec-remote.cpp
examples/cpp/exec-remote/s4u-exec-remote.tesh
src/s4u/s4u_Exec.cpp

index dc91d04..aa6d80b 100644 (file)
@@ -42,6 +42,19 @@ static void wizard()
 
   exec->wait();
   XBT_INFO("Done!");
+
+  XBT_INFO("And now, even harder. Start a remote activity on Ginette and turn off the host after 0.5 sec");
+  exec = simgrid::s4u::this_actor::exec_init(48.492e6)->set_host(ginette);
+  exec->start();
+
+  simgrid::s4u::this_actor::sleep_for(0.5);
+  ginette->turn_off();
+  try {
+    exec->wait();
+  } catch (const simgrid::HostFailureException& e) {
+    XBT_INFO("Execution failed on %s", ginette->get_cname());
+  }
+  XBT_INFO("Done!");
 }
 
 int main(int argc, char* argv[])
index 9b2c993..3ccd924 100644 (file)
@@ -10,3 +10,6 @@ $ ${bindir:=.}/s4u-exec-remote ${platfdir}/small_platform.xml "--log=root.fmt:[%
 > [  1.500000] (1:test@Fafard) Loads before the move: Boivin=0; Fafard=0; Ginette=48492000
 > [  1.600000] (1:test@Fafard) Loads after the move: Boivin=98095000; Fafard=0; Ginette=0
 > [  2.000000] (1:test@Fafard) Done!
+> [  2.000000] (1:test@Fafard) And now, even harder. Start a remote activity on Ginette and turn off the host after 0.5 sec
+> [  2.500000] (1:test@Fafard) Execution failed on Ginette
+> [  2.500000] (1:test@Fafard) Done!
index febefce..ab680d8 100644 (file)
@@ -7,6 +7,7 @@
 #include "simgrid/exec.h"
 #include "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Exec.hpp"
+#include "simgrid/s4u/Host.hpp"
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/kernel/actor/ActorImpl.hpp"
 #include "src/kernel/actor/SimcallObserver.hpp"
@@ -33,6 +34,13 @@ void Exec::complete(Activity::State state)
 ExecPtr Exec::init()
 {
   auto pimpl = kernel::activity::ExecImplPtr(new kernel::activity::ExecImpl());
+  Host::on_state_change.connect([pimpl](s4u::Host const& h) {
+    if (not h.is_on() && pimpl->state_ == kernel::activity::State::RUNNING &&
+        std::find(pimpl->get_hosts().begin(), pimpl->get_hosts().end(), &h) != pimpl->get_hosts().end()) {
+      pimpl->state_ = kernel::activity::State::FAILED;
+      pimpl->post();
+    }
+  });
   return ExecPtr(pimpl->get_iface());
 }