Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
enable remote copy and move for disks
[simgrid.git] / examples / s4u / io-file-remote / s4u-io-file-remote.cpp
index b4e6350..d1dda93 100644 (file)
@@ -17,31 +17,18 @@ static int host(int argc, char* argv[])
   const char* filename = file.get_path();
   XBT_INFO("Opened file '%s'", filename);
   file.dump();
-
-  XBT_INFO("Try to read %llu from '%s'", file.size(), filename);
-  sg_size_t read = file.read(file.size());
-  XBT_INFO("Have read %llu from '%s'. Offset is now at: %llu", read, filename, file.tell());
-  XBT_INFO("Seek back to the beginning of the stream...");
-  file.seek(0, SEEK_SET);
-  XBT_INFO("Offset is now at: %llu", file.tell());
-
-  if (argc > 5) {
-    simgrid::s4u::File remoteFile(argv[2], nullptr);
-    filename = remoteFile.get_path();
-    XBT_INFO("Opened file '%s'", filename);
-    XBT_INFO("Try to write %llu MiB to '%s'", remoteFile.size() / 1024, filename);
-    sg_size_t write = remoteFile.write(remoteFile.size() * 1024);
-    XBT_INFO("Have written %llu bytes to '%s'.", write, filename);
-
-    if (std::stoi(argv[5]) != 0) {
-      XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, remoteFile.size(),
-               simgrid::s4u::Host::current()->get_cname(), argv[3]);
-      remoteFile.remote_move(simgrid::s4u::Host::by_name(argv[3]), argv[4]);
-    } else {
-      XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, remoteFile.size(),
-               simgrid::s4u::Host::current()->get_cname(), argv[3]);
-      remoteFile.remote_copy(simgrid::s4u::Host::by_name(argv[3]), argv[4]);
-    }
+  XBT_INFO("Try to write %llu MiB to '%s'", file.size() / 1024, filename);
+  sg_size_t write = file.write(file.size() * 1024);
+  XBT_INFO("Have written %llu bytes to '%s'.", write, filename);
+
+  if (std::stoi(argv[4]) != 0) {
+    XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
+             simgrid::s4u::Host::current()->get_cname(), argv[2]);
+    file.remote_move(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
+  } else {
+    XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
+             simgrid::s4u::Host::current()->get_cname(), argv[2]);
+    file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
   }
 
   return 0;
@@ -54,18 +41,20 @@ int main(int argc, char** argv)
   e.load_platform(argv[1]);
   e.register_function("host", host);
   e.load_deployment(argv[2]);
-  std::vector<simgrid::s4u::Storage*> allStorages = e.get_all_storages();
+  std::vector<simgrid::s4u::Host*> all_hosts = e.get_all_hosts();
 
-  for (auto const& s : allStorages) {
-    XBT_INFO("Init: %llu/%llu MiB used/free on '%s'", sg_storage_get_size_used(s) / INMEGA,
-             sg_storage_get_size_free(s) / INMEGA, s->get_cname());
+  for (auto const& h : all_hosts) {
+    for (auto const& d : h->get_disks())
+      XBT_INFO("Init: %llu/%llu MiB used/free on '%s@%s'", sg_disk_get_size_used(d) / INMEGA,
+               sg_disk_get_size_free(d) / INMEGA, d->get_cname(), h->get_cname());
   }
 
   e.run();
 
-  for (auto const& s : allStorages) {
-    XBT_INFO("End: %llu/%llu MiB used/free on '%s'", sg_storage_get_size_used(s) / INMEGA,
-             sg_storage_get_size_free(s) / INMEGA, s->get_cname());
+  for (auto const& h : all_hosts) {
+    for (auto const& d : h->get_disks())
+      XBT_INFO("End: %llu/%llu MiB used/free on '%s@%s'", sg_disk_get_size_used(d) / INMEGA,
+               sg_disk_get_size_free(d) / INMEGA, d->get_cname(), h->get_cname());
   }
 
   XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());