static simgrid::config::Flag<int> cfg_host_count{"host-count", "Host count (master on one, workers on the others)", 3};
static simgrid::config::Flag<double> cfg_deadline{"deadline", "When to fail the simulation (infinite loop detection)",
120};
-static simgrid::config::Flag<int> cfg_task_count{"task-count", "Amount of tasks that must be executed to succeed", 2};
+static simgrid::config::Flag<int> cfg_task_count{"task-count", "Amount of tasks that must be executed to succeed", 1};
int todo; // remaining amount of tasks to execute, a global variable
sg4::Mailbox* mailbox; // as a global to reduce the amount of simcalls during actor reboot
{
double comp_size = 1e6;
long comm_size = 1e6;
- XBT_INFO("Master booting");
- sg4::Actor::self()->daemonize();
- sg4::this_actor::on_exit(
- [](bool forcefully) { XBT_INFO("Master dying %s.", forcefully ? "forcefully" : "peacefully"); });
+ bool rebooting = sg4::Actor::self()->get_restart_count() > 0;
+
+ XBT_INFO("Master %s", rebooting ? "rebooting" : "booting");
+ if (not rebooting) // Starting for the first time
+ sg4::this_actor::on_exit(
+ [](bool forcefully) { XBT_INFO("Master dying %s.", forcefully ? "forcefully" : "peacefully"); });
while (true) { // This is a daemon
xbt_assert(sg4::Engine::get_clock() < cfg_deadline,
static void worker(int id)
{
- XBT_INFO("Worker booting");
- sg4::this_actor::on_exit(
- [id](bool forcefully) { XBT_INFO("worker %d dying %s.", id, forcefully ? "forcefully" : "peacefully"); });
+ bool rebooting = sg4::Actor::self()->get_restart_count() > 0;
+
+ XBT_INFO("Worker %s", rebooting ? "rebooting" : "booting");
+ if (not rebooting) // Starting for the first time
+ sg4::this_actor::on_exit(
+ [id](bool forcefully) { XBT_INFO("worker %d dying %s.", id, forcefully ? "forcefully" : "peacefully"); });
while (todo > 0) {
xbt_assert(sg4::Engine::get_clock() < cfg_deadline,
}
rootzone->seal();
- sg4::Actor::create("master", main, master)->set_auto_restart(true);
+ sg4::Actor::create("master", main, master)->daemonize()->set_auto_restart(true);
int id = 0;
for (auto* h : worker_hosts) {
sg4::Actor::create("worker", h, worker, id)->set_auto_restart(true);
p Smoke test: do one arbitrary run of the monkey, just to make sure that *something* is happening.
-$ ${bindir:=.}/monkey-masterworkers --cfg=plugin:cmonkey --cfg=cmonkey/time:1 --cfg=cmonkey/host:1
+$ ${bindir:=.}/monkey-masterworkers --cfg=plugin:cmonkey --cfg=cmonkey/time:1 --cfg=cmonkey/host:1 --cfg=task-count:2
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'plugin' to 'cmonkey'
> [0.000000] [cmonkey/INFO] Initializing the chaos monkey
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'cmonkey/time' to '1'
> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'cmonkey/host' to '1'
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'task-count' to '2'
> [lilibeth 0:master:(1) 0.000000] [s4u_test/INFO] Master booting
> [lilibeth 1:worker:(2) 0.000000] [s4u_test/INFO] Worker booting
> [lilibeth 2:worker:(3) 0.000000] [s4u_test/INFO] Worker booting
+> [lilibeth 0:master:(1) 0.000000] [s4u_test/INFO] Try to send a message
> [lilibeth 1:worker:(2) 0.000000] [s4u_test/INFO] Waiting a message on mailbox
> [lilibeth 2:worker:(3) 0.000000] [s4u_test/INFO] Waiting a message on mailbox
-> [lilibeth 0:master:(1) 0.000000] [s4u_test/INFO] Try to send a message
> [1.000000] [cmonkey/INFO] Kill host lilibeth 1
> [lilibeth 0:master:(1) 1.000000] [s4u_test/INFO] Got a NetworkFailureException. Wait a second before starting again.
> [lilibeth 1:worker:(2) 1.000000] [s4u_test/INFO] worker 0 dying forcefully.
> [lilibeth 2:worker:(3) 4.167573] [s4u_test/INFO] worker 1 dying peacefully.
> [lilibeth 0:master:(1) 4.167573] [s4u_test/INFO] Master dying forcefully.
> [31.000000] [cmonkey/INFO] Restart host lilibeth 1
-> [lilibeth 1:worker:(4) 31.000000] [s4u_test/INFO] Worker booting
-> [lilibeth 1:worker:(4) 31.000000] [s4u_test/INFO] worker 0 dying peacefully.
+> [lilibeth 1:worker:(4) 31.000000] [s4u_test/INFO] Worker rebooting
> [lilibeth 1:worker:(4) 31.000000] [s4u_test/INFO] worker 0 dying peacefully.
> [31.000000] [cmonkey/INFO] Chaos Monkey done!
> [31.000000] [s4u_test/INFO] WE SURVIVED!