From 79e1c778024ec716af1f44407f59b009e4eb4798 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 17 Sep 2019 13:45:44 +0200 Subject: [PATCH] convert a last s4u test to disks --- .../storage_client_server.cpp | 77 +++++++++---------- .../storage_client_server.tesh | 51 ++++++------ 2 files changed, 61 insertions(+), 67 deletions(-) diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index 78fe0efb7f..480350504f 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -11,11 +11,11 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage, "Messages specific for this simulation"); -static void display_storage_properties(simgrid::s4u::Storage* storage) +static void display_disk_properties(simgrid::s4u::Disk* disk) { - const std::unordered_map* props = storage->get_properties(); + const std::unordered_map* props = disk->get_properties(); if (not props->empty()) { - XBT_INFO(" Properties of mounted storage: %s", storage->get_cname()); + XBT_INFO(" Properties of disk: %s", disk->get_cname()); for (auto const& elm : *props) { XBT_INFO(" %s->%s", elm.first.c_str(), elm.second.c_str()); @@ -57,10 +57,11 @@ static void hsm_put(const std::string& remote_host, const std::string& src, cons simgrid::s4u::this_actor::sleep_for(.4); } -static void display_storage_content(simgrid::s4u::Storage* storage) +static void display_disk_content(simgrid::s4u::Disk* disk) { - XBT_INFO("Print the content of the storage element: %s", storage->get_cname()); - std::map* content = storage->extension()->get_content(); + XBT_INFO("*** Dump a disk ***"); + XBT_INFO("Print the content of the disk: %s", disk->get_cname()); + std::map* content = disk->extension()->get_content(); if (not content->empty()) { for (auto const& entry : *content) XBT_INFO(" %s size: %llu bytes", entry.first.c_str(), entry.second); @@ -69,68 +70,60 @@ static void display_storage_content(simgrid::s4u::Storage* storage) } } -static void dump_storage_by_name(const std::string& name) +static void get_set_disk_data(simgrid::s4u::Disk* disk) { - XBT_INFO("*** Dump a storage element ***"); - simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name(name); - display_storage_content(storage); -} - -static void get_set_storage_data(const std::string& storage_name) -{ - XBT_INFO("*** GET/SET DATA for storage element: %s ***", storage_name.c_str()); - simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name(storage_name); + XBT_INFO("*** GET/SET DATA for disk: %s ***", disk->get_cname()); - std::string* data = static_cast(storage->get_data()); + std::string* data = static_cast(disk->get_data()); XBT_INFO("Get data: '%s'", data ? data->c_str() : "No User Data"); - storage->set_data(new std::string("Some data")); - data = static_cast(storage->get_data()); + disk->set_data(new std::string("Some data")); + data = static_cast(disk->get_data()); XBT_INFO(" Set and get data: '%s'", data->c_str()); delete data; } -static void dump_platform_storages() +static void dump_platform_disks() { - std::vector storages = simgrid::s4u::Engine::get_instance()->get_all_storages(); - for (auto const& s : storages) { - XBT_INFO("Storage %s is attached to %s", s->get_cname(), s->get_host()->get_cname()); - s->set_property("other usage", "gpfs"); - } + for (auto const& h : simgrid::s4u::Engine::get_instance()->get_all_hosts()) + for (auto const& d : h->get_disks()) { + if (h == d->get_host()) + XBT_INFO("%s is attached to %s", d->get_cname(), d->get_host()->get_cname()); + d->set_property("other usage", "gpfs"); + } } -static void storage_info(simgrid::s4u::Host* host) +static void disk_info(simgrid::s4u::Host* host) { - XBT_INFO("*** Storage info on %s ***", host->get_cname()); + XBT_INFO("*** Disk info on %s ***", host->get_cname()); - for (auto const& elm : host->get_mounted_storages()) { - const std::string& mount_name = elm.first; - simgrid::s4u::Storage* storage = elm.second; - XBT_INFO(" Storage name: %s, mount name: %s", storage->get_cname(), mount_name.c_str()); + for (auto const& disk : host->get_disks()) { + const char* mount_name = sg_disk_get_mount_point(disk); + XBT_INFO(" Disk name: %s, mount name: %s", disk->get_cname(), mount_name); - XBT_INFO(" Free size: %llu bytes", sg_storage_get_size_free(storage)); - XBT_INFO(" Used size: %llu bytes", sg_storage_get_size_used(storage)); + XBT_INFO(" Free size: %llu bytes", sg_disk_get_size_free(disk)); + XBT_INFO(" Used size: %llu bytes", sg_disk_get_size_used(disk)); - display_storage_properties(storage); - dump_storage_by_name(storage->get_cname()); + display_disk_properties(disk); + display_disk_content(disk); } } static void client() { - hsm_put("alice", "/home/doc/simgrid/examples/msg/icomms/small_platform.xml", "/tmp/toto.xml"); - hsm_put("alice", "/home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml", "/tmp/titi.xml"); - hsm_put("alice", "/home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c", "/tmp/tata.c"); + hsm_put("alice", "/scratch/doc/simgrid/examples/msg/icomms/small_platform.xml", "/tmp/toto.xml"); + hsm_put("alice", "/scratch/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml", "/tmp/titi.xml"); + hsm_put("alice", "/scratch/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c", "/tmp/tata.c"); simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("alice"); mailbox->put(new std::string("finalize"), 0); - get_set_storage_data("Disk1"); + get_set_disk_data(simgrid::s4u::Host::current()->get_disks().front()); // Disk1 } static void server() { - storage_info(simgrid::s4u::this_actor::get_host()); + disk_info(simgrid::s4u::this_actor::get_host()); simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_host()->get_cname()); XBT_INFO("Server waiting for transfers ..."); @@ -148,8 +141,8 @@ static void server() } } - storage_info(simgrid::s4u::this_actor::get_host()); - dump_platform_storages(); + disk_info(simgrid::s4u::this_actor::get_host()); + dump_platform_disks(); } int main(int argc, char* argv[]) diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.tesh b/teshsuite/s4u/storage_client_server/storage_client_server.tesh index c3ab82daa5..b4d284175d 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.tesh +++ b/teshsuite/s4u/storage_client_server/storage_client_server.tesh @@ -1,11 +1,12 @@ -$ ./storage_client_server ${platfdir}/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: /tmp +$ ./storage_client_server ${platfdir}/hosts_with_disks.xml "--log=root.fmt:[%10.6r]%e(%P@%h)%e%m%n" +> [ 0.000000] (server@alice) *** Disk info on alice *** +> [ 0.000000] (server@alice) Disk name: Disk1, mount name: / > [ 0.000000] (server@alice) Free size: 536857690006 bytes > [ 0.000000] (server@alice) Used size: 13221994 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) Properties of disk: Disk1 +> [ 0.000000] (server@alice) content->storage/content/small_content.txt +> [ 0.000000] (server@alice) *** Dump a disk *** +> [ 0.000000] (server@alice) Print the content of the disk: Disk1 > [ 0.000000] (server@alice) /bin/smpicc size: 918 bytes > [ 0.000000] (server@alice) /bin/tesh size: 356434 bytes > [ 0.000000] (server@alice) /doc/simgrid/examples/msg/README size: 4805 bytes @@ -37,22 +38,23 @@ $ ./storage_client_server ${platfdir}/storage/storage.xml "--log=root.fmt:[%10.6 > [ 0.000000] (server@alice) /include/xbt/fifo.h size: 3626 bytes > [ 0.000000] (server@alice) /lib/libsimgrid.so.3.6.2 size: 12710497 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 has read 972 on /scratch/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.001982] (server@alice) 972 bytes on 972 bytes have been written by server on /sd1 +> [ 0.401976] (client@bob) client has read 654 on /scratch/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.403942] (server@alice) 654 bytes on 654 bytes have been written by server on /sd1 +> [ 0.803996] (client@bob) client has read 6217 on /scratch/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] (server@alice) Storage name: Disk2, mount name: /tmp +> [ 0.806079] (server@alice) 6217 bytes on 6217 bytes have been written by server on /sd1 +> [ 1.207952] (server@alice) *** Disk info on alice *** +> [ 1.207952] (server@alice) Disk name: Disk1, mount name: / > [ 1.207952] (server@alice) Free size: 536857682163 bytes > [ 1.207952] (server@alice) Used size: 13229837 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) Properties of disk: Disk1 +> [ 1.207952] (server@alice) content->storage/content/small_content.txt +> [ 1.207952] (server@alice) *** Dump a disk *** +> [ 1.207952] (server@alice) Print the content of the disk: Disk1 > [ 1.207952] (server@alice) /bin/smpicc size: 918 bytes > [ 1.207952] (server@alice) /bin/tesh size: 356434 bytes > [ 1.207952] (server@alice) /doc/simgrid/examples/msg/README size: 4805 bytes @@ -83,14 +85,13 @@ $ ./storage_client_server ${platfdir}/storage/storage.xml "--log=root.fmt:[%10.6 > [ 1.207952] (server@alice) /include/surf/simgrid_dtd.h size: 23583 bytes > [ 1.207952] (server@alice) /include/xbt/fifo.h size: 3626 bytes > [ 1.207952] (server@alice) /lib/libsimgrid.so.3.6.2 size: 12710497 bytes -> [ 1.207952] (server@alice) /tata.c size: 6217 bytes -> [ 1.207952] (server@alice) /titi.xml size: 654 bytes -> [ 1.207952] (server@alice) /toto.xml size: 972 bytes -> [ 1.207952] (server@alice) Storage Disk1 is attached to bob -> [ 1.207952] (client@bob) *** GET/SET DATA for storage element: Disk1 *** +> [ 1.207952] (server@alice) /tmp/tata.c size: 6217 bytes +> [ 1.207952] (server@alice) /tmp/titi.xml size: 654 bytes +> [ 1.207952] (server@alice) /tmp/toto.xml size: 972 bytes +> [ 1.207952] (client@bob) *** GET/SET DATA for disk: Disk1 *** > [ 1.207952] (client@bob) Get data: 'No User Data' > [ 1.207952] (client@bob) Set and get data: 'Some data' -> [ 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 +> [ 1.207952] (server@alice) Disk1 is attached to alice +> [ 1.207952] (server@alice) Disk1 is attached to bob +> [ 1.207952] (server@alice) Disk2 is attached to bob > [ 1.207952] (maestro@) Simulated time: 1.20795 -- 2.20.1