Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update cloud example to use MSG_vm_reboot. Update the tesh file
[simgrid.git] / examples / msg / cloud / masterslave_virtual_machines.c
index ed1ac27..d1df1c7 100644 (file)
@@ -43,7 +43,7 @@ static void work_batch(int slaves_count) {
 
 int master(int argc, char *argv[]) {
   int slaves_count = 10;
-  m_host_t *slaves = xbt_new(m_host_t,10);
+  msg_host_t *slaves = xbt_new(msg_host_t,10);
 
   int i;
 
@@ -66,6 +66,7 @@ int master(int argc, char *argv[]) {
     MSG_vm_bind(vm, MSG_process_create_with_arguments(slavename,slave_fun,NULL,slaves[i],2,argv));
   }
 
+
   xbt_dynar_t vms = MSG_vms_as_dynar();
   XBT_INFO("Launched %ld VMs", xbt_dynar_length(vms));
 
@@ -99,6 +100,12 @@ int master(int argc, char *argv[]) {
     MSG_vm_bind(vm, MSG_process_create_with_arguments(slavename,slave_fun,NULL,slaves[i],2,argv));
   }
 
+  XBT_INFO("Reboot all the VMs");
+  for (i=0;i<xbt_dynar_length(vms);i++)
+    MSG_vm_reboot(xbt_dynar_get_as(vms,i,msg_vm_t));
+
+  work_batch(slaves_count*2);
+
   XBT_INFO("Migrate everyone to the second host.");
   for (i=0;i<xbt_dynar_length(vms);i++)
     MSG_vm_migrate(xbt_dynar_get_as(vms,i,msg_vm_t),slaves[1]);
@@ -111,13 +118,12 @@ int master(int argc, char *argv[]) {
     MSG_vm_resume(vm);
   }
 
-  work_batch(slaves_count*2);
 
   XBT_INFO("Let's shut down the simulation. 10 first processes will be shut down cleanly while the second half will forcefully get killed");
   for (i = 0; i < slaves_count; i++) {
     char mailbox_buffer[64];
     sprintf(mailbox_buffer,"Slave_%d",i);
-    m_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
+    msg_task_t finalize = MSG_task_create("finalize", 0, 0, 0);
     MSG_task_send(finalize, mailbox_buffer);
   }
 
@@ -137,13 +143,12 @@ int master(int argc, char *argv[]) {
 int slave_fun(int argc, char *argv[])
 {
   char *mailbox_name;
-  m_task_t task = NULL;
+  msg_task_t task = NULL;
   _XBT_GNUC_UNUSED int res;
-
   /* since the slaves will move around, use slave_%d as mailbox names instead of hostnames */
   xbt_assert(argc>=2, "slave processes need to be given their rank as parameter");
   mailbox_name=bprintf("Slave_%s",argv[1]);
-
+  XBT_INFO("Slave listenning on %s",argv[1]);
   while (1) {
     res = MSG_task_receive(&(task),mailbox_name);
     xbt_assert(res == MSG_OK, "MSG_task_get failed");
@@ -167,15 +172,15 @@ int slave_fun(int argc, char *argv[])
 /** Main function */
 int main(int argc, char *argv[])
 {
-  MSG_error_t res = MSG_OK;
+  msg_error_t res = MSG_OK;
   xbt_dynar_t hosts_dynar;
-  m_host_t*hosts= xbt_new(m_host_t,10);
+  msg_host_t*hosts= xbt_new(msg_host_t,10);
   char**hostnames= xbt_new(char*,10);
   char**masterargv=xbt_new(char*,12);
   int i;
 
   /* Get the arguments */
-  MSG_global_init(&argc, argv);
+  MSG_init(&argc, argv);
   if (argc < 2) {
     printf("Usage: %s platform_file\n", argv[0]);
     printf("example: %s msg_platform.xml\n", argv[0]);
@@ -193,7 +198,7 @@ int main(int argc, char *argv[])
       "I need at least 10 hosts in the platform file, but %s contains only %ld hosts_dynar.",
       argv[1],xbt_dynar_length(hosts_dynar));
   for (i=0;i<10;i++) {
-    hosts[i] = xbt_dynar_get_as(hosts_dynar,i,m_host_t);
+    hosts[i] = xbt_dynar_get_as(hosts_dynar,i,msg_host_t);
     hostnames[i] = xbt_strdup(MSG_host_get_name(hosts[i]));
   }
   masterargv[0]=xbt_strdup("master");