Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update msg-storage tesh
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Wed, 2 Oct 2013 11:29:41 +0000 (13:29 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Wed, 2 Oct 2013 11:29:41 +0000 (13:29 +0200)
teshsuite/msg/storage/deployment.xml
teshsuite/msg/storage/platform.xml
teshsuite/msg/storage/storage.c
teshsuite/msg/storage/storage.tesh
teshsuite/msg/storage/storage_content_c.txt
teshsuite/msg/storage/storage_content_s1.txt
teshsuite/msg/storage/storage_content_s2.txt

index 4ff8c10..dab6a8c 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
-  <process host="client" function="client"/>
-  <process host="server" function="server"/>
+  <process host="server" function="server" />
+  <process host="client" function="client" />
 </platform>
\ No newline at end of file
index c288fb5..caec3da 100644 (file)
@@ -16,7 +16,8 @@
                        <prop id="Bconnection" value="150MBps" />
                </storage_type>
 
-               <storage_type id="single_SSD" model="linear_no_lat" size="500GiB">
+               <storage_type id="single_SSD" model="linear_no_lat"
+                       content="content/storage_content.txt" size="500GiB">
                        <prop id="Bwrite" value="30MBps" />
                        <prop id="Bread" value="100MBps" />
                        <prop id="Bconnection" value="150MBps" />
@@ -24,8 +25,9 @@
 
                <!-- DISKS -->
                <storage id="cdisk" typeId="single_HDD" content="msg/storage/storage_content_c.txt">
-                  <prop id="usage" value="scratch"/>
-                  <prop id="date" value="31-08-13"/>
+                  <prop id="filename" value="prop.xml"/>
+                  <prop id="date" value="31-08-12"/>
+           <prop id="author" value="pnavarro"/>
                </storage>
                <storage id="sdisk1" typeId="single_SSD" content="msg/storage/storage_content_s1.txt" />
                <storage id="sdisk2" typeId="single_HDD" content="msg/storage/storage_content_s2.txt" />
@@ -38,7 +40,7 @@
                <host id="server" power="1000000000">
                        <mount storageId="sdisk1" name="/sd1" />
                        <mount storageId="sdisk2" name="/sd2" />
-                       <prop id="ip adress" value="134.165.2.5"/>
+                       <prop id="ip adress" value="127.0.0.5"/>
                </host>
 
                <!-- LINKS & ROUTES -->
index b4a3a54..33dfab5 100644 (file)
@@ -5,26 +5,20 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 
 void storage_info(msg_host_t host);
 void display_storage_properties(msg_storage_t storage);
+int hsm_put(const char *remote_host, const char *src, const char *dest);
+sg_storage_size_t write_local_file(char *dest, sg_storage_size_t file_size);
+sg_storage_size_t read_local_file(const char *src);
+void display_storage_info(msg_host_t host);
+void dump_storage_by_name(char *name);
+void display_storage_content(msg_storage_t storage);
+void get_set_storage_data(const char *storage_name);
 int client(int argc, char *argv[]);
 int server(int argc, char *argv[]);
 
-
-int client(int argc, char *argv[])
+void storage_info(msg_host_t host)
 {
-  storage_info(MSG_host_self());
-  return 1;
-}
-
-int server(int argc, char *argv[])
-{
-  //display_storage_info();
-  return 1;
-}
-
-void storage_info(msg_host_t host){
-
   const char* host_name = MSG_host_get_name(host);
-  XBT_INFO("** Storage info on %s:", host_name);
+  XBT_INFO("*** Storage info on %s ***:", host_name);
 
   xbt_dict_cursor_t cursor = NULL;
   char* mount_name;
@@ -35,13 +29,13 @@ void storage_info(msg_host_t host){
 
   xbt_dict_foreach(storage_list,cursor,mount_name,storage_name)
   {
-    XBT_INFO("\tStorage mount name: %s", mount_name);
+       XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name);
 
     sg_storage_size_t free_size = MSG_storage_get_free_size(mount_name);
     sg_storage_size_t used_size = MSG_storage_get_used_size(mount_name);
 
-    XBT_INFO("\t\tFree size: %zu bytes", free_size);
-    XBT_INFO("\t\tUsed size: %zu bytes", used_size);
+    XBT_INFO("Free size: %zu bytes", free_size);
+    XBT_INFO("Used size: %zu bytes", used_size);
 
     storage = MSG_storage_get_by_name(storage_name);
     display_storage_properties(storage);
@@ -53,14 +47,152 @@ void display_storage_properties(msg_storage_t storage){
   char *key, *data;
   xbt_dict_t props = MSG_storage_get_properties(storage);
   if (props){
-    XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage));
+    XBT_INFO("Properties of mounted storage: %s", MSG_storage_get_name(storage));
     xbt_dict_foreach(props, cursor, key, data)
-         XBT_INFO("\t\t'%s' -> '%s'", key, data);
+         XBT_INFO("'%s' -> '%s'", key, data);
   }else{
-       XBT_INFO("\t\tNo property attached.");
+       XBT_INFO("No property attached.");
   }
 }
 
+// Read src file on local disk and send a put message to remote host (size of message = size of src file)
+int hsm_put(const char *remote_host, const char *src, const char *dest){
+
+  // Read local src file, and return the size that was actually read
+  sg_storage_size_t read_size = read_local_file(src);
+
+  // Send file
+  XBT_INFO("%s sends %zu to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host);
+  msg_task_t to_execute = MSG_task_create((const char*)"hsm_put", 0, (double) read_size, (void*)dest);
+  MSG_task_send(to_execute, remote_host);
+
+  return 1;
+}
+
+sg_storage_size_t write_local_file(char *dest, sg_storage_size_t file_size)
+{
+  sg_storage_size_t write;
+  msg_file_t file = MSG_file_open("/sd1",dest, NULL);
+  write = MSG_file_write(file, file_size);
+  MSG_file_close(file);
+  return write;
+}
+
+sg_storage_size_t read_local_file(const char *src)
+{
+  sg_storage_size_t read, file_size;
+  msg_file_t file = MSG_file_open("/sd1",src, NULL);
+  file_size = MSG_file_get_size(file);
+
+  read = MSG_file_read(file, file_size);
+  XBT_INFO("%s has read %zu on %s",MSG_host_get_name(MSG_host_self()),read,src);
+  MSG_file_close(file);
+
+  return read;
+}
+
+void display_storage_info(msg_host_t host)
+{
+  const char* host_name = MSG_host_get_name(host);
+  XBT_INFO("*** Storage info of: %s ***", host_name);
+
+  xbt_dict_cursor_t cursor = NULL;
+  char* mount_name;
+  char* storage_name;
+
+  xbt_dict_t storage_list = MSG_host_get_storage_list(host);
+
+  xbt_dict_foreach(storage_list,cursor,mount_name,storage_name)
+  {
+    dump_storage_by_name(storage_name);
+  }
+}
+
+void dump_storage_by_name(char *name){
+  XBT_INFO("*** Dump a storage element ***");
+  msg_storage_t storage = MSG_storage_get_by_name(name);
+
+  if(storage){
+    display_storage_content(storage);
+  }
+  else{
+    XBT_INFO("Unable to retrieve storage element by its name: %s.", name);
+  }
+}
+
+void display_storage_content(msg_storage_t storage){
+  XBT_INFO("Print the content of the storage element: %s",MSG_storage_get_name(storage));
+  xbt_dict_cursor_t cursor = NULL;
+  char *file;
+  sg_storage_size_t size;
+  xbt_dict_t content = MSG_storage_get_content(storage);
+  if (content){
+    xbt_dict_foreach(content, cursor, file, size)
+         XBT_INFO("%s size: %zu bytes", file, size);
+  }else{
+       XBT_INFO("No content.");
+  }
+}
+
+void get_set_storage_data(const char *storage_name){
+       XBT_INFO("*** GET/SET DATA for storage element: %s ***",storage_name);
+       msg_storage_t storage = MSG_storage_get_by_name(storage_name);
+       char *data = MSG_storage_get_data(storage);
+       XBT_INFO("Get data: '%s'", data);
+       MSG_storage_set_data(storage,strdup("Some data"));
+       data = MSG_storage_get_data(storage);
+       XBT_INFO("Set and get data: '%s'", data);
+}
+
+int client(int argc, char *argv[])
+{
+  hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx","./scratch/toto.xml");
+  hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml","./scratch/titi.cxx");
+  hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/Slave.cxx","./scratch/tata.cxx");
+
+  msg_task_t finalize = MSG_task_create("finalize", 0, 0, NULL);
+  MSG_task_send(finalize, "server");
+
+  get_set_storage_data("cdisk");
+  display_storage_info(MSG_host_self());
+
+  return 1;
+}
+
+int server(int argc, char *argv[])
+{
+  msg_task_t to_execute = NULL;
+  _XBT_GNUC_UNUSED int res;
+
+  display_storage_info(MSG_host_self());
+
+  XBT_INFO("Server waiting for transfers");
+  while(1){
+    res = MSG_task_receive(&(to_execute), MSG_host_get_name(MSG_host_self()));
+    xbt_assert(res == MSG_OK, "MSG_task_get failed");
+
+    const char *task_name;
+    task_name = MSG_task_get_name(to_execute);
+
+    if (!strcmp(task_name, "finalize")) { // Shutdown ...
+      MSG_task_destroy(to_execute);
+      break;
+    }
+    else if(!strcmp(task_name,"hsm_put")){// Receive file to save
+      // Write file on local disk
+      char *dest = MSG_task_get_data(to_execute);
+      sg_storage_size_t size_to_write = (sg_storage_size_t)MSG_task_get_data_size(to_execute);
+      write_local_file(dest, size_to_write);
+       }
+
+    MSG_task_destroy(to_execute);
+    to_execute = NULL;
+  }
+
+  display_storage_info(MSG_host_self());
+  return 1;
+}
+
 int main(int argc, char *argv[])
 {
   MSG_init(&argc, argv);
@@ -81,6 +213,7 @@ int main(int argc, char *argv[])
   MSG_launch_application(deployment_file);
 
   msg_error_t res = MSG_main();
+  XBT_INFO("Simulated time: %g", MSG_get_clock());
 
   if (res == MSG_OK)
     return 0;
index 473358f..11c12a9 100644 (file)
@@ -1,8 +1,45 @@
 $ msg/storage/storage --cfg=path:${srcdir:=.} ${srcdir:=.}/msg/storage/platform.xml ${srcdir:=.}/msg/storage/deployment.xml 0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [  0.000000] (1:client@client) ** Storage info on client:
-> [  0.000000] (1:client@client)       Storage mount name: /sd1
-> [  0.000000] (1:client@client)               Free size: 536774599000 bytes
-> [  0.000000] (1:client@client)               Used size: 96313000 bytes
-> [  0.000000] (1:client@client)       Properties of mounted storage: cdisk
-> [  0.000000] (1:client@client)               'date' -> '31-08-13'
-> [  0.000000] (1:client@client)               'usage' -> 'scratch'
+> [  0.000000] (1:server@server) *** Storage info of: server ***
+> [  0.000000] (1:server@server) *** Dump a storage element ***
+> [  0.000000] (1:server@server) Print the content of the storage element: sdisk1
+> [  0.000000] (1:server@server) ./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml size: 21339320000 bytes
+> [  0.000000] (1:server@server) ./doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx size: 113700000 bytes
+> [  0.000000] (1:server@server) ./doc/simgrid/examples/cxx/autoDestination/Master.cxx size: 18910000 bytes
+> [  0.000000] (1:server@server) ./doc/simgrid/examples/cxx/basic/FinalizeTask.cxx size: 710000000 bytes
+> [  0.000000] (1:server@server) *** Dump a storage element ***
+> [  0.000000] (1:server@server) Print the content of the storage element: sdisk2
+> [  0.000000] (1:server@server) ./doc/simgrid/examples/cxx/basic/Slave.cxx size: 69300000 bytes
+> [  0.000000] (1:server@server) ./doc/simgrid/examples/cxx/basic/Main.cxx size: 14800000 bytes
+> [  0.000000] (1:server@server) Server waiting for transfers
+> [  0.000710] (2:client@client) client has read 71000 on ./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx
+> [  0.000710] (2:client@client) client sends 71000 to server
+> [  0.014595] (2:client@client) client has read 1262000 on ./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml
+> [  0.014595] (2:client@client) client sends 1262000 to server
+> [  0.896175] (2:client@client) client has read 87000000 on ./doc/simgrid/examples/cxx/autoDestination/Slave.cxx
+> [  0.896175] (2:client@client) client sends 87000000 to server
+> [  4.550878] (2:client@client) *** GET/SET DATA for storage element: cdisk ***
+> [  4.550878] (2:client@client) Get data: '(null)'
+> [  4.550878] (2:client@client) Set and get data: 'Some data'
+> [  4.550878] (2:client@client) *** Storage info of: client ***
+> [  4.550878] (1:server@server) *** Storage info of: server ***
+> [  4.550878] (2:client@client) *** Dump a storage element ***
+> [  4.550878] (2:client@client) Print the content of the storage element: cdisk
+> [  4.550878] (2:client@client) ./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx size: 71000 bytes
+> [  4.550878] (2:client@client) ./doc/simgrid/examples/cxx/autoDestination/BasicTask.cxx size: 6500000 bytes
+> [  4.550878] (2:client@client) ./doc/simgrid/examples/cxx/autoDestination/Main.cxx size: 1480000 bytes
+> [  4.550878] (2:client@client) ./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml size: 1262000 bytes
+> [  4.550878] (2:client@client) ./doc/simgrid/examples/cxx/autoDestination/Slave.cxx size: 87000000 bytes
+> [  4.550878] (1:server@server) *** Dump a storage element ***
+> [  4.550878] (1:server@server) Print the content of the storage element: sdisk1
+> [  4.550878] (1:server@server) ./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml size: 21339320000 bytes
+> [  4.550878] (1:server@server) ./scratch/toto.xml size: 71000 bytes
+> [  4.550878] (1:server@server) ./scratch/tata.cxx size: 87000000 bytes
+> [  4.550878] (1:server@server) ./doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx size: 113700000 bytes
+> [  4.550878] (1:server@server) ./scratch/titi.cxx size: 1262000 bytes
+> [  4.550878] (1:server@server) ./doc/simgrid/examples/cxx/autoDestination/Master.cxx size: 18910000 bytes
+> [  4.550878] (1:server@server) ./doc/simgrid/examples/cxx/basic/FinalizeTask.cxx size: 710000000 bytes
+> [  4.550878] (1:server@server) *** Dump a storage element ***
+> [  4.550878] (1:server@server) Print the content of the storage element: sdisk2
+> [  4.550878] (1:server@server) ./doc/simgrid/examples/cxx/basic/Slave.cxx size: 69300000 bytes
+> [  4.550878] (1:server@server) ./doc/simgrid/examples/cxx/basic/Main.cxx size: 14800000 bytes
+> [  4.550878] (0:@) Simulated time: 4.55088
index d461c10..fef7c55 100644 (file)
@@ -1,5 +1,5 @@
-./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx 71000
+./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx 71000         
 ./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml 1262000         
-./doc/simgrid/examples/cxx/autoDestination/Main.cxx    1480000
-./doc/simgrid/examples/cxx/autoDestination/Slave.cxx 87000000  
-./doc/simgrid/examples/cxx/autoDestination/BasicTask.cxx 6500000
+./doc/simgrid/examples/cxx/autoDestination/Main.cxx 1480000       
+./doc/simgrid/examples/cxx/autoDestination/Slave.cxx 87000000     
+./doc/simgrid/examples/cxx/autoDestination/BasicTask.cxx 6500000        
index 004f34b..55968d0 100644 (file)
@@ -1,4 +1,4 @@
-./doc/simgrid/examples/cxx/autoDestination/Master.cxx 18910000
-./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml        21339320000   
+./doc/simgrid/examples/cxx/autoDestination/Master.cxx 18910000            
+./doc/simgrid/examples/cxx/autoDestination/autoDestination_platform.xml 21339320000   
 ./doc/simgrid/examples/cxx/autoDestination/Forwarder.cxx 113700000        
-./doc/simgrid/examples/cxx/basic/FinalizeTask.cxx 710000000       
+./doc/simgrid/examples/cxx/basic/FinalizeTask.cxx 710000000          
index 98d37e0..0721dbf 100644 (file)
@@ -1,2 +1,2 @@
 ./doc/simgrid/examples/cxx/basic/Main.cxx 14800000
-./doc/simgrid/examples/cxx/basic/Slave.cxx 69300000       
\ No newline at end of file
+./doc/simgrid/examples/cxx/basic/Slave.cxx 69300000   
\ No newline at end of file