Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert cloud-masterworker
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 10 Mar 2020 08:02:18 +0000 (09:02 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 10 Mar 2020 08:02:18 +0000 (09:02 +0100)
MANIFEST.in
examples/c/CMakeLists.txt
examples/c/cloud-masterworker/cloud-masterworker.c [new file with mode: 0644]
examples/c/cloud-masterworker/cloud-masterworker.tesh [new file with mode: 0644]
examples/deprecated/msg/CMakeLists.txt
examples/deprecated/msg/cloud-masterworker/cloud-masterworker.c [deleted file]
examples/deprecated/msg/cloud-masterworker/cloud-masterworker.tesh [deleted file]

index 4ab1a27..31e2667 100644 (file)
@@ -64,6 +64,8 @@ include examples/c/async-waitany/async-waitany.tesh
 include examples/c/async-waitany/async-waitany_d.xml
 include examples/c/cloud-capping/cloud-capping.c
 include examples/c/cloud-capping/cloud-capping.tesh
+include examples/c/cloud-masterworker/cloud-masterworker.c
+include examples/c/cloud-masterworker/cloud-masterworker.tesh
 include examples/c/cloud-migration/cloud-migration.c
 include examples/c/cloud-migration/cloud-migration.tesh
 include examples/c/cloud-simple/cloud-simple.c
@@ -220,8 +222,6 @@ include examples/deprecated/msg/app-masterworker/app-masterworker-vivaldi_d.xml
 include examples/deprecated/msg/app-masterworker/app-masterworker.c
 include examples/deprecated/msg/app-masterworker/app-masterworker.tesh
 include examples/deprecated/msg/app-masterworker/app-masterworker_d.xml
-include examples/deprecated/msg/cloud-masterworker/cloud-masterworker.c
-include examples/deprecated/msg/cloud-masterworker/cloud-masterworker.tesh
 include examples/deprecated/msg/dht-kademlia/answer.c
 include examples/deprecated/msg/dht-kademlia/answer.h
 include examples/deprecated/msg/dht-kademlia/common.h
@@ -470,6 +470,7 @@ include examples/s4u/network-ns3/crosstraffic_d.xml
 include examples/s4u/network-ns3/dogbone_d.xml
 include examples/s4u/network-ns3/one_cluster_d.xml
 include examples/s4u/network-ns3/onelink_d.xml
+include examples/s4u/network-ns3/s4u-network-ns3.cpp
 include examples/s4u/network-ns3/s4u-network-ns3.tesh
 include examples/s4u/platform-failures/s4u-platform-failures.cpp
 include examples/s4u/platform-failures/s4u-platform-failures.tesh
index dcf5c24..37de897 100644 (file)
@@ -6,7 +6,7 @@ foreach(x
         actor-suspend actor-yield
         app-pingpong app-token-ring 
         async-wait async-waitall async-waitany
-        cloud-capping cloud-migration cloud-simple
+        cloud-capping cloud-masterworker cloud-migration cloud-simple
         exec-async exec-basic exec-dvfs exec-remote exec-waitany
         energy-exec energy-exec-ptask energy-vm
         io-disk-raw io-file-remote
@@ -62,7 +62,7 @@ foreach(x
         actor-suspend actor-yield
         app-chainsend app-pingpong app-token-ring
         async-wait async-waitall async-waitany
-        cloud-capping cloud-migration cloud-simple
+        cloud-capping  cloud-masterworker cloud-migration cloud-simple
         exec-async exec-basic exec-dvfs exec-remote exec-waitany
         energy-exec energy-exec-ptask energy-vm
         io-disk-raw io-file-remote
diff --git a/examples/c/cloud-masterworker/cloud-masterworker.c b/examples/c/cloud-masterworker/cloud-masterworker.c
new file mode 100644 (file)
index 0000000..0fb1776
--- /dev/null
@@ -0,0 +1,206 @@
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/actor.h"
+#include "simgrid/engine.h"
+#include "simgrid/exec.h"
+#include "simgrid/host.h"
+#include "simgrid/mailbox.h"
+#include "simgrid/plugins/live_migration.h"
+#include "simgrid/vm.h"
+
+#include "xbt/asserts.h"
+#include "xbt/log.h"
+#include "xbt/str.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(cloud_masterworker, "Messages specific for this example");
+
+#define MAXMBOXLEN 64
+#define FINALIZE 221297 /* a magic number to tell people to stop working */
+
+const double comp_size = 10000000;
+const double comm_size = 10000000;
+
+static void send_tasks(int nb_workers)
+{
+  for (int i = 0; i < nb_workers; i++) {
+    char mbox_name[MAXMBOXLEN];
+    snprintf(mbox_name, MAXMBOXLEN, "MBOX:WRK%02d", i);
+    double* payload   = (double*)malloc(sizeof(double));
+    *payload          = comp_size;
+    sg_mailbox_t mbox = sg_mailbox_by_name(mbox_name);
+
+    XBT_INFO("Send to mailbox(%s)", mbox_name);
+    sg_mailbox_put(mbox, payload, comm_size);
+  }
+}
+
+static void worker_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+  const char* pr_name = sg_actor_self_get_name();
+  char mbox_name[MAXMBOXLEN];
+  snprintf(mbox_name, MAXMBOXLEN, "MBOX:%s", pr_name);
+  sg_mailbox_t mbox = sg_mailbox_by_name(mbox_name);
+  double* payload   = NULL;
+
+  XBT_INFO("%s is listening on mailbox(%s)", pr_name, mbox_name);
+
+  for (;;) {
+    payload = (double*)sg_mailbox_get(mbox);
+
+    XBT_INFO("%s received from mailbox(%s)", pr_name, mbox_name);
+
+    if (*payload == FINALIZE) {
+      free(payload);
+      break;
+    }
+
+    sg_actor_execute(*payload);
+    XBT_INFO("%s executed", pr_name);
+    free(payload);
+  }
+}
+
+static void master_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
+{
+  unsigned int i;
+
+  sg_host_t* worker_pms = sg_actor_self_data();
+
+  sg_vm_t* vms = (sg_vm_t*)malloc(2 * sizeof(sg_vm_t));
+
+  /* Launch VMs and worker actors. One VM per PM, and one worker actor per VM. */
+  XBT_INFO("# Launch 2 VMs");
+  for (int i = 0; i < 2; i++) {
+    char* vm_name = bprintf("VM%02d", i);
+    char* pr_name = bprintf("WRK%02d", i);
+
+    sg_host_t pm = worker_pms[i];
+
+    XBT_INFO("create %s on PM(%s)", vm_name, sg_host_get_name(pm));
+    sg_vm_t vm = sg_vm_create_core(pm, vm_name);
+
+    sg_vm_set_ramsize(vm, 1L * 1024 * 1024 * 1024); // 1GiB
+
+    sg_vm_start(vm);
+    vms[i] = vm;
+
+    XBT_INFO("put an actor (%s) on %s", pr_name, vm_name);
+    sg_actor_create(pr_name, (sg_host_t)vm, worker_fun, 0, NULL);
+
+    xbt_free(vm_name);
+    xbt_free(pr_name);
+  }
+
+  /* Send a bunch of work to every one */
+  XBT_INFO("# Send to 2 worker actors");
+  send_tasks(2);
+
+  XBT_INFO("# Suspend all VMs");
+  for (int i = 0; i < 2; i++) {
+    XBT_INFO("suspend %s", sg_vm_get_name(vms[i]));
+    sg_vm_suspend(vms[i]);
+  }
+
+  XBT_INFO("# Wait a while");
+  sg_actor_sleep_for(2);
+
+  XBT_INFO("# Resume all VMs");
+  for (int i = 0; i < 2; i++) {
+    sg_vm_resume(vms[i]);
+  }
+
+  XBT_INFO("# Sleep long enough for everyone to be done with previous batch of work");
+  sg_actor_sleep_for(10 - simgrid_get_clock());
+
+  XBT_INFO("# Add one more actor on each VM");
+  for (unsigned int i = 0; i < 2; i++) {
+    char* vm_name = bprintf("VM%02u", i);
+    char* pr_name = bprintf("WRK%02u", i + 2);
+
+    XBT_INFO("put an actor (%s) on %s", pr_name, vm_name);
+    sg_actor_create(pr_name, (sg_host_t)vms[i], worker_fun, 0, NULL);
+
+    free(vm_name);
+    free(pr_name);
+  }
+
+  XBT_INFO("# Send to 4 worker actors");
+  send_tasks(4);
+
+  sg_host_t worker_pm0 = worker_pms[0];
+  sg_host_t worker_pm1 = worker_pms[1];
+
+  XBT_INFO("# Migrate all VMs to PM(%s)", sg_host_get_name(worker_pm0));
+  for (int i = 0; i < 2; i++) {
+    sg_vm_migrate(vms[i], worker_pm0);
+  }
+
+  XBT_INFO("# Migrate all VMs to PM(%s)", sg_host_get_name(worker_pm1));
+  for (int i = 0; i < 2; i++) {
+    sg_vm_migrate(vms[i], worker_pm1);
+  }
+
+  XBT_INFO("# Shutdown the half of worker actors gracefully. The remaining half will be forcibly killed.");
+  for (i = 0; i < 2; i++) {
+    char mbox_name[MAXMBOXLEN];
+    snprintf(mbox_name, MAXMBOXLEN, "MBOX:WRK%02u", i);
+    sg_mailbox_t mbox = sg_mailbox_by_name(mbox_name);
+    double* payload   = (double*)malloc(sizeof(double));
+    *payload          = FINALIZE;
+    sg_mailbox_put(mbox, payload, 0);
+  }
+
+  XBT_INFO("# Wait a while before effective shutdown.");
+  sg_actor_sleep_for(2);
+
+  XBT_INFO("# Shutdown and destroy all the VMs. The remaining worker actors will be forcibly killed.");
+  for (int i = 0; i < 2; i++) {
+    XBT_INFO("shutdown %s", sg_vm_get_name(vms[i]));
+    sg_vm_shutdown(vms[i]);
+    XBT_INFO("destroy %s", sg_vm_get_name(vms[i]));
+    sg_vm_destroy(vms[i]);
+  }
+
+  XBT_INFO("# Goodbye now!");
+  free(vms);
+}
+
+int main(int argc, char* argv[])
+{
+  simgrid_init(&argc, argv);
+  sg_vm_live_migration_plugin_init();
+
+  xbt_assert(argc > 1, "Usage: %s example/platforms/cluster_backbone.xml\n", argv[0]);
+
+  /* Load the platform file */
+  simgrid_load_platform(argv[1]);
+
+  /* Retrieve hosts from the platform file */
+  sg_host_t* pms = sg_host_list();
+
+  /* we need a master node and worker nodes */
+  xbt_assert(sg_host_count() > 2, "need at least 3 hosts");
+
+  /* the first pm is the master, the others are workers */
+  sg_host_t master_pm = pms[0];
+
+  sg_host_t* worker_pms = (sg_host_t*)malloc(2 * sizeof(sg_host_t));
+  for (int i = 0; i < 2 + 1; i++)
+    worker_pms[i] = pms[i + 1];
+
+  free(pms);
+
+  sg_actor_t actor = sg_actor_init("master", master_pm);
+  sg_actor_data_set(actor, worker_pms);
+  sg_actor_start(actor, master_fun, 0, NULL);
+
+  simgrid_run();
+  XBT_INFO("Bye (simulation time %g)", simgrid_get_clock());
+
+  free(worker_pms);
+
+  return 0;
+}
diff --git a/examples/c/cloud-masterworker/cloud-masterworker.tesh b/examples/c/cloud-masterworker/cloud-masterworker.tesh
new file mode 100644 (file)
index 0000000..0738081
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/env tesh
+
+p Testing the Cloud API with a simple master/workers
+
+$ ${bindir:=.}/cloud-masterworker-c --log=no_loc ${platfdir}/cluster_backbone.xml
+> [node-0.simgrid.org:master:(1) 0.000000] [cloud_masterworker/INFO] # Launch 2 VMs
+> [node-0.simgrid.org:master:(1) 0.000000] [cloud_masterworker/INFO] create VM00 on PM(node-1.simgrid.org)
+> [node-0.simgrid.org:master:(1) 0.000000] [cloud_masterworker/INFO] put an actor (WRK00) on VM00
+> [node-0.simgrid.org:master:(1) 0.000000] [cloud_masterworker/INFO] create VM01 on PM(node-10.simgrid.org)
+> [VM00:WRK00:(2) 0.000000] [cloud_masterworker/INFO] WRK00 is listening on mailbox(MBOX:WRK00)
+> [node-0.simgrid.org:master:(1) 0.000000] [cloud_masterworker/INFO] put an actor (WRK01) on VM01
+> [node-0.simgrid.org:master:(1) 0.000000] [cloud_masterworker/INFO] # Send to 2 worker actors
+> [node-0.simgrid.org:master:(1) 0.000000] [cloud_masterworker/INFO] Send to mailbox(MBOX:WRK00)
+> [VM01:WRK01:(3) 0.000000] [cloud_masterworker/INFO] WRK01 is listening on mailbox(MBOX:WRK01)
+> [VM00:WRK00:(2) 0.090280] [cloud_masterworker/INFO] WRK00 received from mailbox(MBOX:WRK00)
+> [node-0.simgrid.org:master:(1) 0.090280] [cloud_masterworker/INFO] Send to mailbox(MBOX:WRK01)
+> [VM00:WRK00:(2) 0.100280] [cloud_masterworker/INFO] WRK00 executed
+> [VM01:WRK01:(3) 0.180560] [cloud_masterworker/INFO] WRK01 received from mailbox(MBOX:WRK01)
+> [node-0.simgrid.org:master:(1) 0.180560] [cloud_masterworker/INFO] # Suspend all VMs
+> [node-0.simgrid.org:master:(1) 0.180560] [cloud_masterworker/INFO] suspend VM00
+> [node-0.simgrid.org:master:(1) 0.180560] [cloud_masterworker/INFO] suspend VM01
+> [node-0.simgrid.org:master:(1) 0.180560] [cloud_masterworker/INFO] # Wait a while
+> [node-0.simgrid.org:master:(1) 2.180560] [cloud_masterworker/INFO] # Resume all VMs
+> [node-0.simgrid.org:master:(1) 2.180560] [cloud_masterworker/INFO] # Sleep long enough for everyone to be done with previous batch of work
+> [VM01:WRK01:(3) 2.190560] [cloud_masterworker/INFO] WRK01 executed
+> [node-0.simgrid.org:master:(1) 10.000000] [cloud_masterworker/INFO] # Add one more actor on each VM
+> [node-0.simgrid.org:master:(1) 10.000000] [cloud_masterworker/INFO] put an actor (WRK02) on VM00
+> [node-0.simgrid.org:master:(1) 10.000000] [cloud_masterworker/INFO] put an actor (WRK03) on VM01
+> [VM00:WRK02:(4) 10.000000] [cloud_masterworker/INFO] WRK02 is listening on mailbox(MBOX:WRK02)
+> [node-0.simgrid.org:master:(1) 10.000000] [cloud_masterworker/INFO] # Send to 4 worker actors
+> [node-0.simgrid.org:master:(1) 10.000000] [cloud_masterworker/INFO] Send to mailbox(MBOX:WRK00)
+> [VM01:WRK03:(5) 10.000000] [cloud_masterworker/INFO] WRK03 is listening on mailbox(MBOX:WRK03)
+> [VM00:WRK00:(2) 10.090280] [cloud_masterworker/INFO] WRK00 received from mailbox(MBOX:WRK00)
+> [node-0.simgrid.org:master:(1) 10.090280] [cloud_masterworker/INFO] Send to mailbox(MBOX:WRK01)
+> [VM00:WRK00:(2) 10.100280] [cloud_masterworker/INFO] WRK00 executed
+> [VM01:WRK01:(3) 10.180560] [cloud_masterworker/INFO] WRK01 received from mailbox(MBOX:WRK01)
+> [node-0.simgrid.org:master:(1) 10.180560] [cloud_masterworker/INFO] Send to mailbox(MBOX:WRK02)
+> [VM01:WRK01:(3) 10.190560] [cloud_masterworker/INFO] WRK01 executed
+> [VM00:WRK02:(4) 10.270841] [cloud_masterworker/INFO] WRK02 received from mailbox(MBOX:WRK02)
+> [node-0.simgrid.org:master:(1) 10.270841] [cloud_masterworker/INFO] Send to mailbox(MBOX:WRK03)
+> [VM00:WRK02:(4) 10.280841] [cloud_masterworker/INFO] WRK02 executed
+> [VM01:WRK03:(5) 10.361121] [cloud_masterworker/INFO] WRK03 received from mailbox(MBOX:WRK03)
+> [node-0.simgrid.org:master:(1) 10.361121] [cloud_masterworker/INFO] # Migrate all VMs to PM(node-1.simgrid.org)
+> [VM01:WRK03:(5) 10.371121] [cloud_masterworker/INFO] WRK03 executed
+> [node-0.simgrid.org:master:(1) 28.561942] [cloud_masterworker/INFO] # Migrate all VMs to PM(node-10.simgrid.org)
+> [node-0.simgrid.org:master:(1) 46.319984] [cloud_masterworker/INFO] # Shutdown the half of worker actors gracefully. The remaining half will be forcibly killed.
+> [VM00:WRK00:(2) 46.327790] [cloud_masterworker/INFO] WRK00 received from mailbox(MBOX:WRK00)
+> [VM01:WRK01:(3) 46.335596] [cloud_masterworker/INFO] WRK01 received from mailbox(MBOX:WRK01)
+> [node-0.simgrid.org:master:(1) 46.335596] [cloud_masterworker/INFO] # Wait a while before effective shutdown.
+> [node-0.simgrid.org:master:(1) 48.335596] [cloud_masterworker/INFO] # Shutdown and destroy all the VMs. The remaining worker actors will be forcibly killed.
+> [node-0.simgrid.org:master:(1) 48.335596] [cloud_masterworker/INFO] shutdown VM00
+> [node-0.simgrid.org:master:(1) 48.335596] [cloud_masterworker/INFO] destroy VM00
+> [node-0.simgrid.org:master:(1) 48.335596] [cloud_masterworker/INFO] shutdown VM01
+> [node-0.simgrid.org:master:(1) 48.335596] [cloud_masterworker/INFO] destroy VM01
+> [node-0.simgrid.org:master:(1) 48.335596] [cloud_masterworker/INFO] # Goodbye now!
+> [48.335596] [cloud_masterworker/INFO] Bye (simulation time 48.3356)
index 51ff5fd..90078d8 100644 (file)
@@ -1,5 +1,5 @@
 # C examples
-foreach(x app-masterworker cloud-masterworker
+foreach(x app-masterworker
           dht-pastry
           synchro-semaphore trace-categories 
           trace-route-user-variables trace-link-user-variables trace-masterworker
@@ -41,9 +41,7 @@ set(xml_files    ${xml_files}     ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworker/a
                                   PARENT_SCOPE)
 
 if(enable_msg)
-  foreach(x app-masterworker cloud-masterworker
-            dht-pastry dht-kademlia
-            synchro-semaphore)
+  foreach(x app-masterworker dht-pastry dht-kademlia synchro-semaphore)
     ADD_TESH_FACTORIES(msg-${x} "thread;ucontext;raw;boost" 
                                 --setenv bindir=${CMAKE_BINARY_DIR}/examples/deprecated/msg/${x}
                                --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/deprecated/msg/${x} 
diff --git a/examples/deprecated/msg/cloud-masterworker/cloud-masterworker.c b/examples/deprecated/msg/cloud-masterworker/cloud-masterworker.c
deleted file mode 100644 (file)
index dfe25f8..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "simgrid/msg.h"
-#include "simgrid/plugins/live_migration.h"
-
-#include <stdio.h> /* snprintf */
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
-
-#define MAXMBOXLEN 64
-
-/** @addtogroup MSG_examples
- *
- *  - <b>cloud/master_worker_vm.c: Master/workers
- *    example on a cloud</b>. The classical example revisited to demonstrate the use of virtual machines.
- */
-
-const double task_comp_size = 10000000;
-const double task_comm_size = 10000000;
-
-static void send_tasks(int nb_workers)
-{
-  for (int i = 0; i < nb_workers; i++) {
-    char *tname = bprintf("Task%02d", i);
-    char *mbox  = bprintf("MBOX:WRK%02d", i);
-
-    msg_task_t task = MSG_task_create(tname, task_comp_size, task_comm_size, NULL);
-
-    XBT_INFO("Send task(%s) to mailbox(%s)", tname, mbox);
-    MSG_task_send(task, mbox);
-
-    free(tname);
-    free(mbox);
-  }
-}
-
-static int worker_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
-  const char *pr_name = MSG_process_get_name(MSG_process_self());
-  char mbox[MAXMBOXLEN];
-  snprintf(mbox, MAXMBOXLEN, "MBOX:%s", pr_name);
-
-  XBT_INFO("%s is listening on mailbox(%s)", pr_name, mbox);
-
-  for (;;) {
-    msg_task_t task = NULL;
-
-    msg_error_t res = MSG_task_receive(&task, mbox);
-    xbt_assert(res == MSG_OK, "MSG_task_get failed");
-
-    XBT_INFO("%s received task(%s) from mailbox(%s)", pr_name, MSG_task_get_name(task), mbox);
-
-    if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
-      MSG_task_destroy(task);
-      break;
-    }
-
-    MSG_task_execute(task);
-    XBT_INFO("%s executed task(%s)", pr_name, MSG_task_get_name(task));
-    MSG_task_destroy(task);
-  }
-  return 0;
-}
-
-static int master_fun(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
-{
-  msg_vm_t vm;
-  unsigned int i;
-
-  const_xbt_dynar_t worker_pms = MSG_process_get_data(MSG_process_self());
-  int nb_workers = xbt_dynar_length(worker_pms);
-
-  xbt_dynar_t vms = xbt_dynar_new(sizeof(msg_vm_t), NULL);
-
-  /* Launch VMs and worker processes. One VM per PM, and one worker process per VM. */
-  XBT_INFO("# Launch %d VMs", nb_workers);
-  for (int i = 0; i< nb_workers; i++) {
-    char *vm_name = bprintf("VM%02d", i);
-    char *pr_name = bprintf("WRK%02d", i);
-
-    msg_host_t pm = xbt_dynar_get_as(worker_pms, i, msg_host_t);
-
-    XBT_INFO("create %s on PM(%s)", vm_name, MSG_host_get_name(pm));
-    msg_vm_t vm = MSG_vm_create_core(pm, vm_name);
-
-    MSG_vm_set_ramsize(vm, 1L * 1024 * 1024 * 1024); // 1GiB
-
-    MSG_vm_start(vm);
-    xbt_dynar_push(vms, &vm);
-
-    XBT_INFO("put a process (%s) on %s", pr_name, vm_name);
-    MSG_process_create(pr_name, worker_fun, NULL, (msg_host_t)vm);
-
-    xbt_free(vm_name);
-    xbt_free(pr_name);
-  }
-
-  /* Send a bunch of work to every one */
-  XBT_INFO("# Send a task to %d worker process", nb_workers);
-  send_tasks(nb_workers);
-
-  XBT_INFO("# Suspend all VMs");
-  xbt_dynar_foreach(vms, i, vm) {
-    XBT_INFO("suspend %s", MSG_vm_get_name(vm));
-    MSG_vm_suspend(vm);
-  }
-
-  XBT_INFO("# Wait a while");
-  MSG_process_sleep(2);
-
-  XBT_INFO("# Resume all VMs");
-  xbt_dynar_foreach(vms, i, vm) {
-    MSG_vm_resume(vm);
-  }
-
-  XBT_INFO("# Sleep long enough for everyone to be done with previous batch of work");
-  MSG_process_sleep(10 - MSG_get_clock());
-
-  XBT_INFO("# Add one more process on each VM");
-  xbt_dynar_foreach(vms, i, vm) {
-    unsigned int index = i + xbt_dynar_length(vms);
-    char* vm_name      = bprintf("VM%02u", i);
-    char* pr_name      = bprintf("WRK%02u", index);
-
-    XBT_INFO("put a process (%s) on %s", pr_name, vm_name);
-    MSG_process_create(pr_name, worker_fun, NULL, (msg_host_t)vm);
-
-    xbt_free(vm_name);
-    xbt_free(pr_name);
-  }
-
-  XBT_INFO("# Send a task to %d worker process", nb_workers * 2);
-  send_tasks(nb_workers * 2);
-
-  msg_host_t worker_pm0 = xbt_dynar_get_as(worker_pms, 0, msg_host_t);
-  msg_host_t worker_pm1 = xbt_dynar_get_as(worker_pms, 1, msg_host_t);
-
-  XBT_INFO("# Migrate all VMs to PM(%s)", MSG_host_get_name(worker_pm0));
-  xbt_dynar_foreach(vms, i, vm) {
-    MSG_vm_migrate(vm, worker_pm0);
-  }
-
-  XBT_INFO("# Migrate all VMs to PM(%s)", MSG_host_get_name(worker_pm1));
-  xbt_dynar_foreach(vms, i, vm) {
-    MSG_vm_migrate(vm, worker_pm1);
-  }
-
-  XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.");
-  for (i = 0; i < nb_workers; i++) {
-    char mbox[MAXMBOXLEN];
-    snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02u", i);
-    msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
-    MSG_task_send(finalize, mbox);
-  }
-
-  XBT_INFO("# Wait a while before effective shutdown.");
-  MSG_process_sleep(2);
-
-  XBT_INFO("# Shutdown and destroy all the VMs. The remaining worker processes will be forcibly killed.");
-  xbt_dynar_foreach(vms, i, vm) {
-    XBT_INFO("shutdown %s", MSG_vm_get_name(vm));
-    MSG_vm_shutdown(vm);
-    XBT_INFO("destroy %s", MSG_vm_get_name(vm));
-    MSG_vm_destroy(vm);
-  }
-
-  XBT_INFO("# Goodbye now!");
-  xbt_dynar_free(&vms);
-  return 0;
-}
-
-/** Receiver function  */
-int main(int argc, char *argv[])
-{
-  const int nb_workers = 2;
-
-  MSG_init(&argc, argv);
-  MSG_vm_live_migration_plugin_init();
-
-  xbt_assert(argc >1,"Usage: %s example/platforms/cluster_backbone.xml\n", argv[0]);
-
-  /* Load the platform file */
-  MSG_create_environment(argv[1]);
-
-  /* Retrieve hosts from the platform file */
-  xbt_dynar_t pms = MSG_hosts_as_dynar();
-
-  /* we need a master node and worker nodes */
-  xbt_assert(xbt_dynar_length(pms) > nb_workers,"need %d hosts", nb_workers + 1);
-
-  /* the first pm is the master, the others are workers */
-  msg_host_t master_pm = xbt_dynar_get_as(pms, 0, msg_host_t);
-
-  xbt_dynar_t worker_pms = xbt_dynar_new(sizeof(msg_host_t), NULL);
-  for (int i = 1; i < nb_workers + 1; i++) {
-    msg_host_t pm = xbt_dynar_get_as(pms, i, msg_host_t);
-    xbt_dynar_push(worker_pms, &pm);
-  }
-  xbt_dynar_free(&pms);
-
-  /* Start the master process on the master pm. */
-  MSG_process_create("master", master_fun, worker_pms, master_pm);
-
-  msg_error_t res = MSG_main();
-  XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
-
-  xbt_dynar_free(&worker_pms);
-
-  return !(res == MSG_OK);
-}
diff --git a/examples/deprecated/msg/cloud-masterworker/cloud-masterworker.tesh b/examples/deprecated/msg/cloud-masterworker/cloud-masterworker.tesh
deleted file mode 100644 (file)
index f4abd36..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env tesh
-
-p Testing the Cloud API with a simple master/workers
-
-$ ${bindir:=.}/cloud-masterworker --log=no_loc ${platfdir}/cluster_backbone.xml
-> [node-0.simgrid.org:master:(1) 0.000000] [msg_test/INFO] # Launch 2 VMs
-> [node-0.simgrid.org:master:(1) 0.000000] [msg_test/INFO] create VM00 on PM(node-1.simgrid.org)
-> [node-0.simgrid.org:master:(1) 0.000000] [msg_test/INFO] put a process (WRK00) on VM00
-> [VM00:WRK00:(2) 0.000000] [msg_test/INFO] WRK00 is listening on mailbox(MBOX:WRK00)
-> [node-0.simgrid.org:master:(1) 0.000000] [msg_test/INFO] create VM01 on PM(node-10.simgrid.org)
-> [node-0.simgrid.org:master:(1) 0.000000] [msg_test/INFO] put a process (WRK01) on VM01
-> [VM01:WRK01:(3) 0.000000] [msg_test/INFO] WRK01 is listening on mailbox(MBOX:WRK01)
-> [node-0.simgrid.org:master:(1) 0.000000] [msg_test/INFO] # Send a task to 2 worker process
-> [node-0.simgrid.org:master:(1) 0.000000] [msg_test/INFO] Send task(Task00) to mailbox(MBOX:WRK00)
-> [VM00:WRK00:(2) 0.090280] [msg_test/INFO] WRK00 received task(Task00) from mailbox(MBOX:WRK00)
-> [node-0.simgrid.org:master:(1) 0.090280] [msg_test/INFO] Send task(Task01) to mailbox(MBOX:WRK01)
-> [VM00:WRK00:(2) 0.100280] [msg_test/INFO] WRK00 executed task(Task00)
-> [VM01:WRK01:(3) 0.180560] [msg_test/INFO] WRK01 received task(Task01) from mailbox(MBOX:WRK01)
-> [node-0.simgrid.org:master:(1) 0.180560] [msg_test/INFO] # Suspend all VMs
-> [node-0.simgrid.org:master:(1) 0.180560] [msg_test/INFO] suspend VM00
-> [node-0.simgrid.org:master:(1) 0.180560] [msg_test/INFO] suspend VM01
-> [node-0.simgrid.org:master:(1) 0.180560] [msg_test/INFO] # Wait a while
-> [node-0.simgrid.org:master:(1) 2.180560] [msg_test/INFO] # Resume all VMs
-> [node-0.simgrid.org:master:(1) 2.180560] [msg_test/INFO] # Sleep long enough for everyone to be done with previous batch of work
-> [VM01:WRK01:(3) 2.190560] [msg_test/INFO] WRK01 executed task(Task01)
-> [node-0.simgrid.org:master:(1) 10.000000] [msg_test/INFO] # Add one more process on each VM
-> [node-0.simgrid.org:master:(1) 10.000000] [msg_test/INFO] put a process (WRK02) on VM00
-> [VM00:WRK02:(4) 10.000000] [msg_test/INFO] WRK02 is listening on mailbox(MBOX:WRK02)
-> [node-0.simgrid.org:master:(1) 10.000000] [msg_test/INFO] put a process (WRK03) on VM01
-> [VM01:WRK03:(5) 10.000000] [msg_test/INFO] WRK03 is listening on mailbox(MBOX:WRK03)
-> [node-0.simgrid.org:master:(1) 10.000000] [msg_test/INFO] # Send a task to 4 worker process
-> [node-0.simgrid.org:master:(1) 10.000000] [msg_test/INFO] Send task(Task00) to mailbox(MBOX:WRK00)
-> [VM00:WRK00:(2) 10.090280] [msg_test/INFO] WRK00 received task(Task00) from mailbox(MBOX:WRK00)
-> [node-0.simgrid.org:master:(1) 10.090280] [msg_test/INFO] Send task(Task01) to mailbox(MBOX:WRK01)
-> [VM00:WRK00:(2) 10.100280] [msg_test/INFO] WRK00 executed task(Task00)
-> [VM01:WRK01:(3) 10.180560] [msg_test/INFO] WRK01 received task(Task01) from mailbox(MBOX:WRK01)
-> [node-0.simgrid.org:master:(1) 10.180560] [msg_test/INFO] Send task(Task02) to mailbox(MBOX:WRK02)
-> [VM01:WRK01:(3) 10.190560] [msg_test/INFO] WRK01 executed task(Task01)
-> [VM00:WRK02:(4) 10.270841] [msg_test/INFO] WRK02 received task(Task02) from mailbox(MBOX:WRK02)
-> [node-0.simgrid.org:master:(1) 10.270841] [msg_test/INFO] Send task(Task03) to mailbox(MBOX:WRK03)
-> [VM00:WRK02:(4) 10.280841] [msg_test/INFO] WRK02 executed task(Task02)
-> [VM01:WRK03:(5) 10.361121] [msg_test/INFO] WRK03 received task(Task03) from mailbox(MBOX:WRK03)
-> [node-0.simgrid.org:master:(1) 10.361121] [msg_test/INFO] # Migrate all VMs to PM(node-1.simgrid.org)
-> [VM01:WRK03:(5) 10.371121] [msg_test/INFO] WRK03 executed task(Task03)
-> [node-0.simgrid.org:master:(1) 28.561942] [msg_test/INFO] # Migrate all VMs to PM(node-10.simgrid.org)
-> [node-0.simgrid.org:master:(1) 46.319984] [msg_test/INFO] # Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.
-> [VM00:WRK00:(2) 46.327790] [msg_test/INFO] WRK00 received task(finalize) from mailbox(MBOX:WRK00)
-> [VM01:WRK01:(3) 46.335596] [msg_test/INFO] WRK01 received task(finalize) from mailbox(MBOX:WRK01)
-> [node-0.simgrid.org:master:(1) 46.335596] [msg_test/INFO] # Wait a while before effective shutdown.
-> [node-0.simgrid.org:master:(1) 48.335596] [msg_test/INFO] # Shutdown and destroy all the VMs. The remaining worker processes will be forcibly killed.
-> [node-0.simgrid.org:master:(1) 48.335596] [msg_test/INFO] shutdown VM00
-> [node-0.simgrid.org:master:(1) 48.335596] [msg_test/INFO] destroy VM00
-> [node-0.simgrid.org:master:(1) 48.335596] [msg_test/INFO] shutdown VM01
-> [node-0.simgrid.org:master:(1) 48.335596] [msg_test/INFO] destroy VM01
-> [node-0.simgrid.org:master:(1) 48.335596] [msg_test/INFO] # Goodbye now!
-> [48.335596] [msg_test/INFO] Bye (simulation time 48.3356)