1 /* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include <simgrid/plugins/file_system.h>
7 #include <simgrid/s4u.hpp>
10 #define INMEGA (1024 * 1024)
12 XBT_LOG_NEW_DEFAULT_CATEGORY(remote_io, "Messages specific for this io example");
14 static int host(int argc, char* argv[])
16 simgrid::s4u::File file(argv[1], nullptr);
17 const char* filename = file.get_path();
18 XBT_INFO("Opened file '%s'", filename);
20 XBT_INFO("Try to write %llu MiB to '%s'", file.size() / 1024, filename);
21 sg_size_t write = file.write(file.size() * 1024);
22 XBT_INFO("Have written %llu MiB to '%s'.", write / (1024 * 1024), filename);
25 if (std::stoi(argv[4]) != 0) {
26 XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
27 simgrid::s4u::Host::current()->get_cname(), argv[2]);
28 file.remote_move(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
30 XBT_INFO("Copy '%s' (of size %llu) from '%s' to '%s'", filename, file.size(),
31 simgrid::s4u::Host::current()->get_cname(), argv[2]);
32 file.remote_copy(simgrid::s4u::Host::by_name(argv[2]), argv[3]);
38 int main(int argc, char** argv)
40 simgrid::s4u::Engine e(&argc, argv);
41 sg_storage_file_system_init();
42 e.load_platform(argv[1]);
43 e.register_function("host", host);
44 e.load_deployment(argv[2]);
45 std::vector<simgrid::s4u::Host*> all_hosts = e.get_all_hosts();
47 for (auto const& h : all_hosts) {
48 for (auto const& d : h->get_disks())
49 XBT_INFO("Init: %s: %llu/%llu MiB used/free on '%s@%s'", h->get_cname(), sg_disk_get_size_used(d) / INMEGA,
50 sg_disk_get_size_free(d) / INMEGA, d->get_cname(), d->get_host()->get_cname());
55 for (auto const& h : all_hosts) {
56 for (auto const& d : h->get_disks())
57 XBT_INFO("End: %llu/%llu MiB used/free on '%s@%s'", sg_disk_get_size_used(d) / INMEGA,
58 sg_disk_get_size_free(d) / INMEGA, d->get_cname(), h->get_cname());
61 XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());