Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / src / plugins / chaos_monkey.cpp
index 45f4df6..282bcd5 100644 (file)
@@ -23,12 +23,27 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cmonkey, kernel, "Chaos Monkey plugin");
 
 static void sg_chaos_monkey_plugin_run()
 {
-  auto engine = sg4::Engine::get_instance();
+  const auto* engine = sg4::Engine::get_instance();
   auto hosts  = engine->get_all_hosts();
   auto links  = engine->get_all_links();
 
   sg4::Engine::on_deadlock_cb([]() { exit(2); });
 
+  if (not cfg_tell && cfg_time < 0 && cfg_host == -1 && cfg_link == -1) {
+    XBT_CRITICAL(
+        "You invoked the Chaos Monkey without anything to do.\n"
+        "Bored, it kills your simulation after this message about how to use it manually (note that the\n"
+        "simgrid-monkey script can tame the monkey for you if you prefer).\n\n"
+        "First of all, you need information. Use --cfg=cmonkey/tell:1 to get all information about the existing\n"
+        "resources and the timestamps of interest in your simulation.\n\n"
+        "Then, use --cfg=cmonkey/host:0 --cfg=cmonkey/time:0.1 to turn off and on the host #0 at time 0.1s,\n"
+        "or --cfg=cmonkey/link:22 --cfg=cmonkey/time:0.4 to turn the link #22 off and on again at time 0.4s.\n"
+        "Only one resource can be rebooted in a given run.\n\n"
+        "Please read the comments at the beginning of the simgrid-monkey script about how to exhaustively test a\n"
+        "program resilience.\n");
+    exit(1);
+  }
+
   if (cfg_tell) {
     XBT_INFO("HOST_COUNT=%zu", hosts.size());
     XBT_INFO("LINK_COUNT=%zu", links.size());
@@ -42,7 +57,7 @@ static void sg_chaos_monkey_plugin_run()
                "If a kill time is given, you must also specify a resource to kill (either a link or an host)");
     xbt_assert(host < 0 || link < 0, "Cannot specify both a link and an host to kill");
     if (host >= 0) {
-      auto* h = hosts[host];
+      auto* h = hosts.at(host);
       simgrid::kernel::timer::Timer::set(cfg_time, [h]() {
         XBT_INFO("Kill host %s", h->get_cname());
         h->turn_off();
@@ -53,7 +68,7 @@ static void sg_chaos_monkey_plugin_run()
       });
     }
     if (link >= 0) {
-      auto* l = links[link];
+      auto* l = links.at(link);
       simgrid::kernel::timer::Timer::set(cfg_time, [l]() {
         XBT_INFO("Kill link %s", l->get_cname());
         l->turn_off();
@@ -68,9 +83,9 @@ static void sg_chaos_monkey_plugin_run()
   sg4::Engine::on_simulation_end_cb([]() { XBT_INFO("Chaos Monkey done!"); });
 }
 
-// Makes sure that this plugin can be activated from the command line with ``--cfg=plugin:chaos_monkey``
+// Makes sure that this plugin can be activated from the command line with ``--cfg=plugin:cmonkey``
 SIMGRID_REGISTER_PLUGIN(cmonkey, "Chaos monkey", []() {
-  XBT_INFO("Initializing the chaos monkey");
+  XBT_INFO("Initializing the chaos monkey.");
 
   // delay the initialization until after the parameter are parsed
   sg4::Engine::on_simulation_start_cb(sg_chaos_monkey_plugin_run);