sg_size_t sizeUsed();
/** Retrieve the total amount of space of this storage element */
sg_size_t size();
+ xbt_dict_t properties();
+ xbt_dict_t content();
/* TODO: missing API:
-XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
XBT_PUBLIC(void) MSG_storage_set_property_value(msg_storage_t storage, const char *name, char *value,void_f_pvoid_t free_ctn);
XBT_PUBLIC(const char *)MSG_storage_get_property_value(msg_storage_t storage, const char *name);
XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar(void);
return *res;
}
-const char*Storage::name() {
+const char* Storage::name()
+{
return name_.c_str();
}
-sg_size_t Storage::sizeFree() {
+sg_size_t Storage::sizeFree()
+{
return simcall_storage_get_free_size(pimpl_);
}
-sg_size_t Storage::sizeUsed() {
+
+sg_size_t Storage::sizeUsed()
+{
return simcall_storage_get_used_size(pimpl_);
}
+
sg_size_t Storage::size() {
return size_;
}
+xbt_dict_t Storage::properties()
+{
+ return simcall_storage_get_properties(pimpl_);
+}
+
+xbt_dict_t Storage::content()
+{
+ return simcall_storage_get_content(pimpl_);
+}
+
} /* namespace s4u */
} /* namespace simgrid */
# C examples
-foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes storage_client_server trace_integration)
+foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes trace_integration)
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1-c1s1-c3s2.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml PARENT_SCOPE)
-foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv storage_client_server task_destroy_cancel
- trace_integration)
+foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel trace_integration)
ADD_TESH_FACTORIES(tesh-msg-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
endforeach()
+++ /dev/null
-/* Copyright (c) 2013-2015. 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"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
-
-static void display_storage_properties(msg_storage_t storage){
- xbt_dict_cursor_t cursor = NULL;
- char *key;
- char *data;
- xbt_dict_t props = MSG_storage_get_properties(storage);
- if (xbt_dict_length(props) > 0){
- XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage));
- xbt_dict_foreach(props, cursor, key, data)
- XBT_INFO("\t\t'%s' -> '%s'", key, data);
- }else{
- XBT_INFO("\tNo property attached.");
- }
-}
-
-static sg_size_t write_local_file(const char *dest, sg_size_t file_size)
-{
- msg_file_t file = MSG_file_open(dest, NULL);
- sg_size_t written = MSG_file_write(file, file_size);
- XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1",written, file_size,
- MSG_host_get_name(MSG_host_self()));
- MSG_file_close(file);
- return written;
-}
-
-static sg_size_t read_local_file(const char *src)
-{
- msg_file_t file = MSG_file_open(src, NULL);
- sg_size_t file_size = MSG_file_get_size(file);
-
- sg_size_t read = MSG_file_read(file, file_size);
- XBT_INFO("%s has read %llu on %s",MSG_host_get_name(MSG_host_self()),read,src);
- MSG_file_close(file);
-
- return read;
-}
-
-// Read src file on local disk and send a put message to remote host (size of message = size of src file)
-static 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_size_t read_size = read_local_file(src);
-
- // Send file
- XBT_INFO("%s sends %llu 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);
- MSG_process_sleep(.4);
- return 1;
-}
-
-static 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_size_t *psize;
- xbt_dict_t content = MSG_storage_get_content(storage);
- if (content){
- xbt_dict_foreach(content, cursor, file, psize)
- XBT_INFO("\t%s size: %llu bytes", file, *psize);
- } else {
- XBT_INFO("\tNo content.");
- }
- xbt_dict_free(&content);
-}
-
-static 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);
- }
-}
-
-static 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, xbt_strdup("Some data"));
- data = MSG_storage_get_data(storage);
- XBT_INFO("\tSet and get data: '%s'", data);
- xbt_free(data);
-}
-
-static void dump_platform_storages(void){
- unsigned int cursor;
- xbt_dynar_t storages = MSG_storages_as_dynar();
- msg_storage_t storage;
- xbt_dynar_foreach(storages, cursor, storage){
- XBT_INFO("Storage %s is attached to %s", MSG_storage_get_name(storage), MSG_storage_get_host(storage));
- MSG_storage_set_property_value(storage, "other usage", xbt_strdup("gpfs"));
- }
- xbt_dynar_free(&storages);
-}
-
-static 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_dict_cursor_t cursor = NULL;
- char* mount_name;
- char* storage_name;
- msg_storage_t storage;
-
- xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self());
-
- xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
- XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
-
- storage = MSG_storage_get_by_name(storage_name);
-
- sg_size_t free_size = MSG_storage_get_free_size(storage);
- sg_size_t used_size = MSG_storage_get_used_size(storage);
-
- XBT_INFO("\t\tFree size: %llu bytes", free_size);
- XBT_INFO("\t\tUsed size: %llu bytes", used_size);
-
- display_storage_properties(storage);
- dump_storage_by_name(storage_name);
- }
- xbt_dict_free(&storage_list);
-}
-
-static int client(int argc, char *argv[])
-{
- hsm_put("alice","/home/doc/simgrid/examples/msg/icomms/small_platform.xml","c:\\Windows\\toto.cxx");
- hsm_put("alice","/home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml","c:\\Windows\\titi.xml");
- hsm_put("alice","/home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c","c:\\Windows\\tata.c");
-
- msg_task_t finalize = MSG_task_create("finalize", 0, 0, NULL);
- MSG_task_send(finalize, "alice");
-
- get_set_storage_data("Disk1");
-
- return 1;
-}
-
-static int server(int argc, char *argv[])
-{
- msg_task_t to_execute = NULL;
- XBT_ATTRIB_UNUSED int res;
-
- 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_size_t size_to_write = (sg_size_t)MSG_task_get_bytes_amount(to_execute);
- write_local_file(dest, size_to_write);
- }
-
- MSG_task_destroy(to_execute);
- to_execute = NULL;
- }
-
- storage_info(MSG_host_self());
- dump_platform_storages();
- return 1;
-}
-
-int main(int argc, char *argv[])
-{
- MSG_init(&argc, argv);
-
- /* Check the arguments */
- xbt_assert(argc == 2,"Usage: %s platform_file\n", argv[0]);
-
- MSG_create_environment(argv[1]);
-
- MSG_process_create("server", server, NULL, MSG_get_host_by_name("alice"));
- MSG_process_create("client", client, NULL, MSG_get_host_by_name("bob"));
-
- msg_error_t res = MSG_main();
- XBT_INFO("Simulated time: %g", MSG_get_clock());
-
- return res != MSG_OK;
-}
+++ /dev/null
-$ ./storage_client_server$EXEEXT ${srcdir:=.}/../../../examples/platforms/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (1:server@alice) *** Storage info on alice ***
-> [ 0.000000] (1:server@alice) Storage name: Disk2, mount name: c:
-> [ 0.000000] (1:server@alice) Free size: 534479374867 bytes
-> [ 0.000000] (1:server@alice) Used size: 2391537133 bytes
-> [ 0.000000] (1:server@alice) No property attached.
-> [ 0.000000] (1:server@alice) *** Dump a storage element ***
-> [ 0.000000] (1:server@alice) Print the content of the storage element: Disk2
-> [ 0.000000] (1:server@alice) \Windows\win.ini size: 92 bytes
-> [ 0.000000] (1:server@alice) \Windows\mib.bin size: 43131 bytes
-> [ 0.000000] (1:server@alice) \Windows\DtcInstall.log size: 1955 bytes
-> [ 0.000000] (1:server@alice) \Windows\vmgcoinstall.log size: 1585 bytes
-> [ 0.000000] (1:server@alice) \Windows\Starter.xml size: 31537 bytes
-> [ 0.000000] (1:server@alice) \Windows\_isusr32.dll size: 180320 bytes
-> [ 0.000000] (1:server@alice) \Windows\winhlp32.exe size: 10752 bytes
-> [ 0.000000] (1:server@alice) \Windows\setuperr.log size: 0 bytes
-> [ 0.000000] (1:server@alice) \Windows\system.ini size: 219 bytes
-> [ 0.000000] (1:server@alice) \Windows\Professional.xml size: 31881 bytes
-> [ 0.000000] (1:server@alice) \Windows\hapint.exe size: 382056 bytes
-> [ 0.000000] (1:server@alice) \Windows\regedit.exe size: 159232 bytes
-> [ 0.000000] (1:server@alice) \Windows\setupact.log size: 101663 bytes
-> [ 0.000000] (1:server@alice) \Windows\WindowsUpdate.log size: 1518934 bytes
-> [ 0.000000] (1:server@alice) \Windows\explorer.exe size: 2380944 bytes
-> [ 0.000000] (1:server@alice) \Windows\DirectX.log size: 10486 bytes
-> [ 0.000000] (1:server@alice) \Windows\WMSysPr9.prx size: 316640 bytes
-> [ 0.000000] (1:server@alice) \Windows\PFRO.log size: 6770 bytes
-> [ 0.000000] (1:server@alice) \Windows\csup.txt size: 12 bytes
-> [ 0.000000] (1:server@alice) \Windows\WLXPGSS.SCR size: 322048 bytes
-> [ 0.000000] (1:server@alice) \Windows\avastSS.scr size: 41664 bytes
-> [ 0.000000] (1:server@alice) \Windows\font1.sii size: 4907 bytes
-> [ 0.000000] (1:server@alice) \Windows\write.exe size: 10752 bytes
-> [ 0.000000] (1:server@alice) \Windows\font2.sii size: 8698 bytes
-> [ 0.000000] (1:server@alice) \Windows\CoreSingleLanguage.xml size: 31497 bytes
-> [ 0.000000] (1:server@alice) \Windows\dchcfg64.exe size: 335464 bytes
-> [ 0.000000] (1:server@alice) \Windows\notepad.exe size: 243712 bytes
-> [ 0.000000] (1:server@alice) \Windows\HelpPane.exe size: 883712 bytes
-> [ 0.000000] (1:server@alice) \Windows\hh.exe size: 17408 bytes
-> [ 0.000000] (1:server@alice) \Windows\DPINST.LOG size: 18944 bytes
-> [ 0.000000] (1:server@alice) \Windows\bfsvc.exe size: 75264 bytes
-> [ 0.000000] (1:server@alice) \Windows\splwow64.exe size: 126464 bytes
-> [ 0.000000] (1:server@alice) \Windows\MEMORY.DMP size: 2384027342 bytes
-> [ 0.000000] (1:server@alice) \Windows\dcmdev64.exe size: 93288 bytes
-> [ 0.000000] (1:server@alice) \Windows\twain_32.dll size: 50176 bytes
-> [ 0.000000] (1:server@alice) \Windows\bootstat.dat size: 67584 bytes
-> [ 0.000000] (1:server@alice) Server waiting for transfers ...
-> [ 0.000010] (2:client@bob) bob has read 972 on /home/doc/simgrid/examples/msg/icomms/small_platform.xml
-> [ 0.000010] (2:client@bob) bob sends 972 to alice
-> [ 0.001986] (1:server@alice) 972 bytes on 972 bytes have been written by alice on /sd1
-> [ 0.401976] (2:client@bob) bob has read 654 on /home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml
-> [ 0.401976] (2:client@bob) bob sends 654 to alice
-> [ 0.403944] (1:server@alice) 654 bytes on 654 bytes have been written by alice on /sd1
-> [ 0.803996] (2:client@bob) bob has read 6217 on /home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c
-> [ 0.803996] (2:client@bob) bob sends 6217 to alice
-> [ 0.806104] (1:server@alice) 6217 bytes on 6217 bytes have been written by alice on /sd1
-> [ 1.207952] (1:server@alice) *** Storage info on alice ***
-> [ 1.207952] (2:client@bob) *** GET/SET DATA for storage element: Disk1 ***
-> [ 1.207952] (2:client@bob) Get data: '(null)'
-> [ 1.207952] (2:client@bob) Set and get data: 'Some data'
-> [ 1.207952] (1:server@alice) Storage name: Disk2, mount name: c:
-> [ 1.207952] (1:server@alice) Free size: 534479367024 bytes
-> [ 1.207952] (1:server@alice) Used size: 2391544976 bytes
-> [ 1.207952] (1:server@alice) No property attached.
-> [ 1.207952] (1:server@alice) *** Dump a storage element ***
-> [ 1.207952] (1:server@alice) Print the content of the storage element: Disk2
-> [ 1.207952] (1:server@alice) \Windows\titi.xml size: 654 bytes
-> [ 1.207952] (1:server@alice) \Windows\win.ini size: 92 bytes
-> [ 1.207952] (1:server@alice) \Windows\mib.bin size: 43131 bytes
-> [ 1.207952] (1:server@alice) \Windows\DtcInstall.log size: 1955 bytes
-> [ 1.207952] (1:server@alice) \Windows\vmgcoinstall.log size: 1585 bytes
-> [ 1.207952] (1:server@alice) \Windows\Starter.xml size: 31537 bytes
-> [ 1.207952] (1:server@alice) \Windows\_isusr32.dll size: 180320 bytes
-> [ 1.207952] (1:server@alice) \Windows\winhlp32.exe size: 10752 bytes
-> [ 1.207952] (1:server@alice) \Windows\setuperr.log size: 0 bytes
-> [ 1.207952] (1:server@alice) \Windows\system.ini size: 219 bytes
-> [ 1.207952] (1:server@alice) \Windows\Professional.xml size: 31881 bytes
-> [ 1.207952] (1:server@alice) \Windows\hapint.exe size: 382056 bytes
-> [ 1.207952] (1:server@alice) \Windows\regedit.exe size: 159232 bytes
-> [ 1.207952] (1:server@alice) \Windows\setupact.log size: 101663 bytes
-> [ 1.207952] (1:server@alice) \Windows\WindowsUpdate.log size: 1518934 bytes
-> [ 1.207952] (1:server@alice) \Windows\explorer.exe size: 2380944 bytes
-> [ 1.207952] (1:server@alice) \Windows\DirectX.log size: 10486 bytes
-> [ 1.207952] (1:server@alice) \Windows\WMSysPr9.prx size: 316640 bytes
-> [ 1.207952] (1:server@alice) \Windows\PFRO.log size: 6770 bytes
-> [ 1.207952] (1:server@alice) \Windows\toto.cxx size: 972 bytes
-> [ 1.207952] (1:server@alice) \Windows\csup.txt size: 12 bytes
-> [ 1.207952] (1:server@alice) \Windows\WLXPGSS.SCR size: 322048 bytes
-> [ 1.207952] (1:server@alice) \Windows\avastSS.scr size: 41664 bytes
-> [ 1.207952] (1:server@alice) \Windows\font1.sii size: 4907 bytes
-> [ 1.207952] (1:server@alice) \Windows\write.exe size: 10752 bytes
-> [ 1.207952] (1:server@alice) \Windows\font2.sii size: 8698 bytes
-> [ 1.207952] (1:server@alice) \Windows\CoreSingleLanguage.xml size: 31497 bytes
-> [ 1.207952] (1:server@alice) \Windows\dchcfg64.exe size: 335464 bytes
-> [ 1.207952] (1:server@alice) \Windows\notepad.exe size: 243712 bytes
-> [ 1.207952] (1:server@alice) \Windows\tata.c size: 6217 bytes
-> [ 1.207952] (1:server@alice) \Windows\HelpPane.exe size: 883712 bytes
-> [ 1.207952] (1:server@alice) \Windows\hh.exe size: 17408 bytes
-> [ 1.207952] (1:server@alice) \Windows\DPINST.LOG size: 18944 bytes
-> [ 1.207952] (1:server@alice) \Windows\bfsvc.exe size: 75264 bytes
-> [ 1.207952] (1:server@alice) \Windows\splwow64.exe size: 126464 bytes
-> [ 1.207952] (1:server@alice) \Windows\MEMORY.DMP size: 2384027342 bytes
-> [ 1.207952] (1:server@alice) \Windows\dcmdev64.exe size: 93288 bytes
-> [ 1.207952] (1:server@alice) \Windows\twain_32.dll size: 50176 bytes
-> [ 1.207952] (1:server@alice) \Windows\bootstat.dat size: 67584 bytes
-> [ 1.207952] (1:server@alice) Storage Disk1 is attached to bob
-> [ 1.207952] (1:server@alice) Storage Disk2 is attached to alice
-> [ 1.207952] (1:server@alice) Storage Disk3 is attached to carl
-> [ 1.207952] (1:server@alice) Storage Disk4 is attached to denise
-> [ 1.207952] (0:maestro@) Simulated time: 1.20795
-foreach(x actor concurrent_rw host_on_off_wait listen_async pid)
+foreach(x actor concurrent_rw host_on_off_wait listen_async pid storage_client_server)
add_executable (${x} ${x}/${x}.cpp)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
set(tesh_files ${tesh_files} PARENT_SCOPE)
set(xml_files ${xml_files} PARENT_SCOPE)
-foreach(x actor concurrent_rw host_on_off_wait listen_async pid)
+foreach(x actor concurrent_rw host_on_off_wait listen_async pid storage_client_server)
ADD_TESH_FACTORIES(tesh-s4u-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/s4u/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/s4u/${x}/${x}.tesh)
endforeach()
--- /dev/null
+/* Copyright (c) 2013-2015, 2017. 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/s4u.hpp"
+#include <string>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation");
+
+static void display_storage_properties(simgrid::s4u::Storage* storage)
+{
+ xbt_dict_cursor_t cursor = NULL;
+ char* key;
+ char* data;
+ xbt_dict_t props = storage->properties();
+ if (xbt_dict_length(props) > 0) {
+ XBT_INFO("\tProperties of mounted storage: %s", storage->name());
+ xbt_dict_foreach (props, cursor, key, data)
+ XBT_INFO("\t\t'%s' -> '%s'", key, data);
+ } else {
+ XBT_INFO("\tNo property attached.");
+ }
+}
+
+static sg_size_t write_local_file(const char* dest, sg_size_t file_size)
+{
+ simgrid::s4u::File* file = new simgrid::s4u::File(dest, nullptr);
+ sg_size_t written = file->write(file_size);
+ XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1", written, file_size,
+ simgrid::s4u::Actor::self()->name().c_str());
+ delete file;
+ return written;
+}
+
+static sg_size_t read_local_file(const char* src)
+{
+ simgrid::s4u::File* file = new simgrid::s4u::File(src, nullptr);
+ sg_size_t file_size = file->size();
+ sg_size_t read = file->read(file_size);
+
+ XBT_INFO("%s has read %llu on %s", simgrid::s4u::Actor::self()->name().c_str(), read, src);
+ delete file;
+
+ return read;
+}
+
+// Read src file on local disk and send a put message to remote host (size of message = size of src file)
+static void 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_size_t read_size = read_local_file(src);
+
+ // Send file
+ XBT_INFO("%s sends %llu to %s", simgrid::s4u::this_actor::name().c_str(), read_size, remote_host);
+ char* payload = bprintf("%s %llu", dest, read_size);
+ simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(remote_host);
+ simgrid::s4u::this_actor::send(mailbox, payload, static_cast<double>(read_size));
+ simgrid::s4u::this_actor::sleep_for(.4);
+}
+
+static void display_storage_content(simgrid::s4u::Storage* storage)
+{
+ XBT_INFO("Print the content of the storage element: %s", storage->name());
+ xbt_dict_cursor_t cursor = NULL;
+ char* file;
+ sg_size_t* psize;
+ xbt_dict_t content = storage->content();
+ if (content) {
+ xbt_dict_foreach (content, cursor, file, psize)
+ XBT_INFO("\t%s size: %llu bytes", file, *psize);
+ } else {
+ XBT_INFO("\tNo content.");
+ }
+ xbt_dict_free(&content);
+}
+
+static void dump_storage_by_name(char* name)
+{
+ XBT_INFO("*** Dump a storage element ***");
+ simgrid::s4u::Storage& storage = simgrid::s4u::Storage::byName(name);
+ display_storage_content(&storage);
+}
+
+static void get_set_storage_data(const char* storage_name)
+{
+ XBT_INFO("*** GET/SET DATA for storage element: %s ***", storage_name);
+ simgrid::s4u::Storage& storage = simgrid::s4u::Storage::byName(storage_name);
+
+ char* data = (char*)storage.userdata();
+ XBT_INFO("Get data: '%s'", data);
+ storage.setUserdata(xbt_strdup("Some data"));
+ data = (char*)storage.userdata();
+ XBT_INFO("\tSet and get data: '%s'", data);
+ xbt_free(data);
+}
+
+// static void dump_platform_storages(void){
+// unsigned int cursor;
+// xbt_dynar_t storages = MSG_storages_as_dynar();
+// msg_storage_t storage;
+// xbt_dynar_foreach(storages, cursor, storage){
+// XBT_INFO("Storage %s is attached to %s", MSG_storage_get_name(storage), MSG_storage_get_host(storage));
+// MSG_storage_set_property_value(storage, "other usage", xbt_strdup("gpfs"));
+// }
+// xbt_dynar_free(&storages);
+// Expected output in tesh file
+//> [ 1.207952] (server@alice) Storage Disk1 is attached to bob
+//> [ 1.207952] (server@alice) Storage Disk2 is attached to alice
+//> [ 1.207952] (server@alice) Storage Disk3 is attached to carl
+//> [ 1.207952] (server@alice) Storage Disk4 is attached to denise
+//}
+
+static void storage_info(simgrid::s4u::Host* host)
+{
+ XBT_INFO("*** Storage info on %s ***", host->cname());
+ xbt_dict_cursor_t cursor = NULL;
+ char* mount_name;
+ char* storage_name;
+
+ xbt_dict_t storage_list = host->mountedStoragesAsDict();
+ xbt_dict_foreach (storage_list, cursor, mount_name, storage_name) {
+ XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name);
+ simgrid::s4u::Storage& storage = simgrid::s4u::Storage::byName(storage_name);
+
+ sg_size_t free_size = storage.sizeFree();
+ sg_size_t used_size = storage.sizeUsed();
+
+ XBT_INFO("\t\tFree size: %llu bytes", free_size);
+ XBT_INFO("\t\tUsed size: %llu bytes", used_size);
+
+ display_storage_properties(&storage);
+ dump_storage_by_name(storage_name);
+ }
+ xbt_dict_free(&storage_list);
+}
+
+static void client()
+{
+ hsm_put("alice", "/home/doc/simgrid/examples/msg/icomms/small_platform.xml", "c:\\Windows\\toto.cxx");
+ hsm_put("alice", "/home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml", "c:\\Windows\\titi.xml");
+ hsm_put("alice", "/home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c", "c:\\Windows\\tata.c");
+
+ simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName("alice");
+ simgrid::s4u::this_actor::send(mailbox, xbt_strdup("finalize"), 0);
+
+ get_set_storage_data("Disk1");
+}
+
+static void server()
+{
+ storage_info(simgrid::s4u::this_actor::host());
+ simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::host()->cname());
+
+ XBT_INFO("Server waiting for transfers ...");
+ while (1) {
+ char* msg = static_cast<char*>(simgrid::s4u::this_actor::recv(mailbox));
+ if (!strcmp(msg, "finalize")) { // Shutdown ...
+ xbt_free(msg);
+ break;
+ } else { // Receive file to save
+ char* saveptr;
+ char* dest = strtok_r(msg, " ", &saveptr);
+ sg_size_t size_to_write = std::stoull(strtok_r(nullptr, " ", &saveptr));
+ write_local_file(dest, size_to_write);
+ }
+ }
+
+ storage_info(simgrid::s4u::this_actor::host());
+ // dump_platform_storages();
+}
+
+int main(int argc, char* argv[])
+{
+ simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
+ xbt_assert(argc == 2, "Usage: %s platform_file\n", argv[0]);
+ e->loadPlatform(argv[1]);
+
+ simgrid::s4u::Actor::createActor("server", simgrid::s4u::Host::by_name("alice"), server);
+ simgrid::s4u::Actor::createActor("client", simgrid::s4u::Host::by_name("bob"), client);
+
+ e->run();
+
+ XBT_INFO("Simulated time: %g", e->getClock());
+
+ return 0;
+}
--- /dev/null
+$ ./storage_client_server$EXEEXT ${srcdir:=.}/../../../examples/platforms/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n"
+> [ 0.000000] (server@alice) *** Storage info on alice ***
+> [ 0.000000] (server@alice) Storage name: Disk2, mount name: c:
+> [ 0.000000] (server@alice) Free size: 534479374867 bytes
+> [ 0.000000] (server@alice) Used size: 2391537133 bytes
+> [ 0.000000] (server@alice) No property attached.
+> [ 0.000000] (server@alice) *** Dump a storage element ***
+> [ 0.000000] (server@alice) Print the content of the storage element: Disk2
+> [ 0.000000] (server@alice) \Windows\win.ini size: 92 bytes
+> [ 0.000000] (server@alice) \Windows\mib.bin size: 43131 bytes
+> [ 0.000000] (server@alice) \Windows\DtcInstall.log size: 1955 bytes
+> [ 0.000000] (server@alice) \Windows\vmgcoinstall.log size: 1585 bytes
+> [ 0.000000] (server@alice) \Windows\Starter.xml size: 31537 bytes
+> [ 0.000000] (server@alice) \Windows\_isusr32.dll size: 180320 bytes
+> [ 0.000000] (server@alice) \Windows\winhlp32.exe size: 10752 bytes
+> [ 0.000000] (server@alice) \Windows\setuperr.log size: 0 bytes
+> [ 0.000000] (server@alice) \Windows\system.ini size: 219 bytes
+> [ 0.000000] (server@alice) \Windows\Professional.xml size: 31881 bytes
+> [ 0.000000] (server@alice) \Windows\hapint.exe size: 382056 bytes
+> [ 0.000000] (server@alice) \Windows\regedit.exe size: 159232 bytes
+> [ 0.000000] (server@alice) \Windows\setupact.log size: 101663 bytes
+> [ 0.000000] (server@alice) \Windows\WindowsUpdate.log size: 1518934 bytes
+> [ 0.000000] (server@alice) \Windows\explorer.exe size: 2380944 bytes
+> [ 0.000000] (server@alice) \Windows\DirectX.log size: 10486 bytes
+> [ 0.000000] (server@alice) \Windows\WMSysPr9.prx size: 316640 bytes
+> [ 0.000000] (server@alice) \Windows\PFRO.log size: 6770 bytes
+> [ 0.000000] (server@alice) \Windows\csup.txt size: 12 bytes
+> [ 0.000000] (server@alice) \Windows\WLXPGSS.SCR size: 322048 bytes
+> [ 0.000000] (server@alice) \Windows\avastSS.scr size: 41664 bytes
+> [ 0.000000] (server@alice) \Windows\font1.sii size: 4907 bytes
+> [ 0.000000] (server@alice) \Windows\write.exe size: 10752 bytes
+> [ 0.000000] (server@alice) \Windows\font2.sii size: 8698 bytes
+> [ 0.000000] (server@alice) \Windows\CoreSingleLanguage.xml size: 31497 bytes
+> [ 0.000000] (server@alice) \Windows\dchcfg64.exe size: 335464 bytes
+> [ 0.000000] (server@alice) \Windows\notepad.exe size: 243712 bytes
+> [ 0.000000] (server@alice) \Windows\HelpPane.exe size: 883712 bytes
+> [ 0.000000] (server@alice) \Windows\hh.exe size: 17408 bytes
+> [ 0.000000] (server@alice) \Windows\DPINST.LOG size: 18944 bytes
+> [ 0.000000] (server@alice) \Windows\bfsvc.exe size: 75264 bytes
+> [ 0.000000] (server@alice) \Windows\splwow64.exe size: 126464 bytes
+> [ 0.000000] (server@alice) \Windows\MEMORY.DMP size: 2384027342 bytes
+> [ 0.000000] (server@alice) \Windows\dcmdev64.exe size: 93288 bytes
+> [ 0.000000] (server@alice) \Windows\twain_32.dll size: 50176 bytes
+> [ 0.000000] (server@alice) \Windows\bootstat.dat size: 67584 bytes
+> [ 0.000000] (server@alice) Server waiting for transfers ...
+> [ 0.000010] (client@bob) client has read 972 on /home/doc/simgrid/examples/msg/icomms/small_platform.xml
+> [ 0.000010] (client@bob) client sends 972 to alice
+> [ 0.001986] (server@alice) 972 bytes on 972 bytes have been written by server on /sd1
+> [ 0.401976] (client@bob) client has read 654 on /home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml
+> [ 0.401976] (client@bob) client sends 654 to alice
+> [ 0.403944] (server@alice) 654 bytes on 654 bytes have been written by server on /sd1
+> [ 0.803996] (client@bob) client has read 6217 on /home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c
+> [ 0.803996] (client@bob) client sends 6217 to alice
+> [ 0.806104] (server@alice) 6217 bytes on 6217 bytes have been written by server on /sd1
+> [ 1.207952] (server@alice) *** Storage info on alice ***
+> [ 1.207952] (client@bob) *** GET/SET DATA for storage element: Disk1 ***
+> [ 1.207952] (client@bob) Get data: '(null)'
+> [ 1.207952] (client@bob) Set and get data: 'Some data'
+> [ 1.207952] (server@alice) Storage name: Disk2, mount name: c:
+> [ 1.207952] (server@alice) Free size: 534479367024 bytes
+> [ 1.207952] (server@alice) Used size: 2391544976 bytes
+> [ 1.207952] (server@alice) No property attached.
+> [ 1.207952] (server@alice) *** Dump a storage element ***
+> [ 1.207952] (server@alice) Print the content of the storage element: Disk2
+> [ 1.207952] (server@alice) \Windows\titi.xml size: 654 bytes
+> [ 1.207952] (server@alice) \Windows\win.ini size: 92 bytes
+> [ 1.207952] (server@alice) \Windows\mib.bin size: 43131 bytes
+> [ 1.207952] (server@alice) \Windows\DtcInstall.log size: 1955 bytes
+> [ 1.207952] (server@alice) \Windows\vmgcoinstall.log size: 1585 bytes
+> [ 1.207952] (server@alice) \Windows\Starter.xml size: 31537 bytes
+> [ 1.207952] (server@alice) \Windows\_isusr32.dll size: 180320 bytes
+> [ 1.207952] (server@alice) \Windows\winhlp32.exe size: 10752 bytes
+> [ 1.207952] (server@alice) \Windows\setuperr.log size: 0 bytes
+> [ 1.207952] (server@alice) \Windows\system.ini size: 219 bytes
+> [ 1.207952] (server@alice) \Windows\Professional.xml size: 31881 bytes
+> [ 1.207952] (server@alice) \Windows\hapint.exe size: 382056 bytes
+> [ 1.207952] (server@alice) \Windows\regedit.exe size: 159232 bytes
+> [ 1.207952] (server@alice) \Windows\setupact.log size: 101663 bytes
+> [ 1.207952] (server@alice) \Windows\WindowsUpdate.log size: 1518934 bytes
+> [ 1.207952] (server@alice) \Windows\explorer.exe size: 2380944 bytes
+> [ 1.207952] (server@alice) \Windows\DirectX.log size: 10486 bytes
+> [ 1.207952] (server@alice) \Windows\WMSysPr9.prx size: 316640 bytes
+> [ 1.207952] (server@alice) \Windows\PFRO.log size: 6770 bytes
+> [ 1.207952] (server@alice) \Windows\toto.cxx size: 972 bytes
+> [ 1.207952] (server@alice) \Windows\csup.txt size: 12 bytes
+> [ 1.207952] (server@alice) \Windows\WLXPGSS.SCR size: 322048 bytes
+> [ 1.207952] (server@alice) \Windows\avastSS.scr size: 41664 bytes
+> [ 1.207952] (server@alice) \Windows\font1.sii size: 4907 bytes
+> [ 1.207952] (server@alice) \Windows\write.exe size: 10752 bytes
+> [ 1.207952] (server@alice) \Windows\font2.sii size: 8698 bytes
+> [ 1.207952] (server@alice) \Windows\CoreSingleLanguage.xml size: 31497 bytes
+> [ 1.207952] (server@alice) \Windows\dchcfg64.exe size: 335464 bytes
+> [ 1.207952] (server@alice) \Windows\notepad.exe size: 243712 bytes
+> [ 1.207952] (server@alice) \Windows\tata.c size: 6217 bytes
+> [ 1.207952] (server@alice) \Windows\HelpPane.exe size: 883712 bytes
+> [ 1.207952] (server@alice) \Windows\hh.exe size: 17408 bytes
+> [ 1.207952] (server@alice) \Windows\DPINST.LOG size: 18944 bytes
+> [ 1.207952] (server@alice) \Windows\bfsvc.exe size: 75264 bytes
+> [ 1.207952] (server@alice) \Windows\splwow64.exe size: 126464 bytes
+> [ 1.207952] (server@alice) \Windows\MEMORY.DMP size: 2384027342 bytes
+> [ 1.207952] (server@alice) \Windows\dcmdev64.exe size: 93288 bytes
+> [ 1.207952] (server@alice) \Windows\twain_32.dll size: 50176 bytes
+> [ 1.207952] (server@alice) \Windows\bootstat.dat size: 67584 bytes
+> [ 1.207952] (maestro@) Simulated time: 1.20795