Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 23 Nov 2017 17:19:53 +0000 (18:19 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 23 Nov 2017 17:19:53 +0000 (18:19 +0100)
25 files changed:
examples/java/io/file/Main.java
examples/java/io/storage/Main.java
examples/msg/io-file/io-file.c
examples/msg/io-file/io-file.tesh
examples/msg/io-remote/io-remote.c
examples/msg/io-storage/io-storage.c
examples/s4u/actions-storage/s4u-actions-storage.cpp
examples/s4u/io/s4u-io.cpp
include/simgrid/plugins/file_system.h [new file with mode: 0644]
include/simgrid/s4u/File.hpp
include/simgrid/s4u/Storage.hpp
src/bindings/java/jmsg.cpp
src/bindings/java/jmsg.hpp
src/bindings/java/org/simgrid/msg/Msg.java
src/s4u/s4u_file.cpp
src/s4u/s4u_storage.cpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
src/surf/storage_n11.cpp
teshsuite/msg/actions-storage/actions-storage.c
teshsuite/s4u/concurrent_rw/concurrent_rw.cpp
teshsuite/s4u/concurrent_rw/concurrent_rw.tesh
teshsuite/s4u/storage_client_server/storage_client_server.cpp
teshsuite/s4u/storage_client_server/storage_client_server.tesh
tools/cmake/DefinePackages.cmake

index 6134fe8..d0dd64c 100644 (file)
@@ -15,6 +15,7 @@ public class Main {
 
   public static void main(String[] args) {
     Msg.init(args);
+    Msg.fileSystemInit();
     if(args.length < 1) {
       Msg.info("Usage   : IO platform_file ");
       Msg.info("example : IO ../platforms/storage/storage.xml ");
index 306eee8..0e8392e 100644 (file)
@@ -14,6 +14,7 @@ public class Main {
 
   public static void main(String[] args) {
     Msg.init(args);
+    Msg.fileSystemInit();
     if(args.length < 1) {
       Msg.info("Usage   : Storage platform_file ");
       Msg.info("example : Storage ../platforms/storage/storage.xml ");
index c0ad633..ec15057 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
+#include "simgrid/plugins/file_system.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(io_file, "Messages specific for this io example");
 
@@ -88,6 +89,8 @@ static int host(int argc, char *argv[])
 int main(int argc, char **argv)
 {
   MSG_init(&argc, argv);
+  MSG_storage_file_system_init();
+
   MSG_create_environment(argv[1]);
   xbt_dynar_t hosts =  MSG_hosts_as_dynar();
   MSG_function_register("host", host);
index d3700af..34f4ef0 100644 (file)
@@ -3,8 +3,11 @@
 $ ${bindir:=.}/io-file ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (0:maestro@) Number of host '4'
 > [  0.000000] (1:host@alice)  Open file 'c:\Windows\setupact.log'
+> [  0.000000] (1:host@alice)  Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391537133 / 536870912000
 > [  0.000000] (2:host@bob)    Open file '/home/doc/simgrid/examples/platforms/nancy.xml'
+> [  0.000000] (2:host@bob)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 36933331 / 536870912000
 > [  0.000000] (3:host@carl)   Open file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
+> [  0.000000] (3:host@carl)   Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 36933331 / 536870912000
 > [  0.000000] (4:host@denise) File Descriptor information:
 >              Full path: '/home/doc/simgrid/examples/platforms/g5k.xml'
 >              Size: 17028
@@ -13,9 +16,6 @@ $ ${bindir:=.}/io-file ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r]
 >              Storage Type: 'single_SSD'
 >              File Descriptor Id: 0
 > [  0.000000] (4:host@denise)         Open file '/home/doc/simgrid/examples/platforms/g5k.xml'
-> [  0.000000] (1:host@alice)  Capacity of the storage element 'c:\Windows\setupact.log' is stored on: 2391537133 / 536870912000
-> [  0.000000] (2:host@bob)    Capacity of the storage element '/home/doc/simgrid/examples/platforms/nancy.xml' is stored on: 36933331 / 536870912000
-> [  0.000000] (3:host@carl)   Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 36933331 / 536870912000
 > [  0.000000] (4:host@denise)         Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k.xml' is stored on: 13221994 / 536870912000
 > [  0.000040] (2:host@bob)    Have read 4028 from '/home/doc/simgrid/examples/platforms/nancy.xml'
 > [  0.000085] (4:host@denise)         Have read 17028 from '/home/doc/simgrid/examples/platforms/g5k.xml'
index 948950b..aaece80 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
+#include "simgrid/plugins/file_system.h"
 
 #define INMEGA (1024*1024)
 
@@ -55,6 +56,8 @@ int main(int argc, char **argv)
   msg_storage_t st;
 
   MSG_init(&argc, argv);
+  MSG_storage_file_system_init();
+
   MSG_create_environment(argv[1]);
   MSG_function_register("host", host);
   MSG_launch_application(argv[2]);
index 298e6e6..69d0713 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
+#include "simgrid/plugins/file_system.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation");
 
@@ -114,6 +115,8 @@ static int host(int argc, char *argv[]){
 int main(int argc, char *argv[])
 {
   MSG_init(&argc, argv);
+  MSG_storage_file_system_init();
+
   MSG_create_environment(argv[1]);
   MSG_function_register("host", host);
   xbt_dynar_t hosts =  MSG_hosts_as_dynar();
index 79a8aba..39d8bd5 100644 (file)
@@ -103,6 +103,7 @@ public:
 int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
+  sg_storage_file_system_init();
 
   xbt_assert(argc > 3, "Usage: %s platform_file deployment_file [action_files]\n"
                        "\texample: %s platform.xml deployment.xml actions # if all actions are in the same file\n"
index 46a5013..c783697 100644 (file)
@@ -86,6 +86,7 @@ public:
 int main(int argc, char **argv)
 {
   simgrid::s4u::Engine e(&argc, argv);
+  sg_storage_file_system_init();
   e.loadPlatform("../../platforms/storage/storage.xml");
   simgrid::s4u::Actor::createActor("host", simgrid::s4u::Host::by_name("denise"), MyHost());
   e.run();
diff --git a/include/simgrid/plugins/file_system.h b/include/simgrid/plugins/file_system.h
new file mode 100644 (file)
index 0000000..bb22a1a
--- /dev/null
@@ -0,0 +1,21 @@
+/* Copyright (c) 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. */
+
+#ifndef SIMGRID_PLUGINS_FILE_SYSTEM_H_
+#define SIMGRID_PLUGINS_FILE_SYSTEM_H_
+
+#include <simgrid/forward.h>
+#include <xbt/base.h>
+
+SG_BEGIN_DECL()
+
+XBT_PUBLIC(void) sg_storage_file_system_init();
+
+#define MSG_storage_file_system_init() sg_storage_file_system_init()
+
+SG_END_DECL()
+
+#endif
index 70249e3..e821cc1 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef SIMGRID_S4U_FILE_HPP
 #define SIMGRID_S4U_FILE_HPP
 
+#include "simgrid/plugins/file_system.h"
+#include <xbt/Extendable.hpp>
 #include <xbt/base.h>
 
 #include <simgrid/simix.h>
@@ -70,6 +72,21 @@ private:
   sg_size_t current_position_ = SEEK_SET;
   void* userdata_             = nullptr;
 };
+
+class FileSystemStorageExt {
+public:
+  static simgrid::xbt::Extension<simgrid::s4u::Storage, FileSystemStorageExt> EXTENSION_ID;
+  explicit FileSystemStorageExt(simgrid::s4u::Storage* ptr);
+  ~FileSystemStorageExt();
+  std::map<std::string, sg_size_t>* parseContent(std::string filename);
+  std::map<std::string, sg_size_t>* getContent() { return content_; }
+  sg_size_t getUsedSize() { return usedSize_; }
+  void decrUsedSize(sg_size_t size) { usedSize_ -= size; }
+  void incrUsedSize(sg_size_t size) { usedSize_ += size; }
+private:
+  std::map<std::string, sg_size_t>* content_;
+  sg_size_t usedSize_ = 0;
+};
 }
 } // namespace simgrid::s4u
 
index c009740..8ba939c 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef INCLUDE_SIMGRID_S4U_STORAGE_HPP_
 #define INCLUDE_SIMGRID_S4U_STORAGE_HPP_
 
+#include "xbt/Extendable.hpp"
 #include <map>
 #include <simgrid/s4u/forward.hpp>
 #include <simgrid/simix.h>
 #include <xbt/base.h>
 
 namespace simgrid {
+namespace xbt {
+extern template class XBT_PUBLIC() Extendable<simgrid::s4u::Storage>;
+}
 namespace s4u {
 
 XBT_ATTRIB_PUBLIC std::map<std::string, Storage*>* allStorages();
 
-XBT_PUBLIC_CLASS Storage
+XBT_PUBLIC_CLASS Storage : public simgrid::xbt::Extendable<Storage>
 {
   friend s4u::Engine;
   friend simgrid::surf::StorageImpl;
@@ -39,6 +43,7 @@ public:
   sg_size_t getSizeFree();
   sg_size_t getSizeUsed();
   void decrUsedSize(sg_size_t size);
+  void incrUsedSize(sg_size_t size);
 
   std::map<std::string, std::string>* getProperties();
   const char* getProperty(std::string key);
index 21b56a9..44f5f5f 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "simgrid/msg.h"
 #include "simgrid/plugins/energy.h"
+#include "simgrid/plugins/file_system.h"
 #include "simgrid/simix.h"
 
 #include "simgrid/s4u/Host.hpp"
@@ -239,6 +240,11 @@ Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls, jstring jde
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_energyInit() {
   sg_host_energy_plugin_init();
 }
+
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_fileSystemInit()
+{
+  sg_storage_file_system_init();
+}
 } // extern "C"
 
 /** Run a Java org.simgrid.msg.Process
index 295a938..e7d0919 100644 (file)
@@ -37,6 +37,7 @@ JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv* env, jclass
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv* env, jclass cls, jobjectArray jargs);
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_energyInit();
+JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_fileSystemInit();
 
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_debug(JNIEnv* env, jclass cls, jstring jargs);
 JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_verb(JNIEnv* env, jclass cls, jstring jargs);
index c58b213..cc1cb7d 100644 (file)
@@ -40,6 +40,7 @@ public final class Msg {
        
        /** Tell the kernel that you want to use the energy plugin */
        public static final native void energyInit();
+       public static final native void fileSystemInit();
 
        /** Run the MSG simulation.
         *
index 5615bac..cd89f99 100644 (file)
 #include "simgrid/simix.hpp"
 #include "src/surf/HostImpl.hpp"
 
+#include <algorithm>
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/split.hpp>
+#include <fstream>
+
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files");
 
 namespace simgrid {
 namespace s4u {
+simgrid::xbt::Extension<s4u::Storage, FileSystemStorageExt> FileSystemStorageExt::EXTENSION_ID;
 
 File::File(std::string fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
 
@@ -75,6 +82,8 @@ sg_size_t File::write(sg_size_t size)
   localStorage->decrUsedSize(size_ - current_position_);
 
   sg_size_t write_size = localStorage->write(size);
+  localStorage->incrUsedSize(write_size);
+
   current_position_ += write_size;
   size_ = current_position_;
 
@@ -153,4 +162,70 @@ int File::unlink()
   }
 }
 
-}} // namespace simgrid::s4u
+FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr)
+{
+  content_ = parseContent(ptr->getImpl()->content_name);
+}
+
+FileSystemStorageExt::~FileSystemStorageExt()
+{
+  delete content_;
+}
+
+std::map<std::string, sg_size_t>* FileSystemStorageExt::parseContent(std::string filename)
+{
+  if (filename.empty())
+    return nullptr;
+
+  std::map<std::string, sg_size_t>* parse_content = new std::map<std::string, sg_size_t>();
+
+  std::ifstream* fs = surf_ifsopen(filename);
+
+  std::string line;
+  std::vector<std::string> tokens;
+  do {
+    std::getline(*fs, line);
+    boost::trim(line);
+    if (line.length() > 0) {
+      boost::split(tokens, line, boost::is_any_of(" \t"), boost::token_compress_on);
+      xbt_assert(tokens.size() == 2, "Parse error in %s: %s", filename.c_str(), line.c_str());
+      sg_size_t size = std::stoull(tokens.at(1));
+
+      usedSize_ += size;
+      parse_content->insert({tokens.front(), size});
+    }
+  } while (not fs->eof());
+  delete fs;
+  return parse_content;
+}
+}
+}
+
+using simgrid::s4u::FileSystemStorageExt;
+
+static void onStorageCreation(simgrid::s4u::Storage& st)
+{
+  st.extension_set(new FileSystemStorageExt(&st));
+}
+
+static void onStorageDestruction(simgrid::s4u::Storage& st)
+{
+  XBT_INFO("BLIH");
+}
+
+/* **************************** Public interface *************************** */
+SG_BEGIN_DECL()
+
+void sg_storage_file_system_init()
+{
+
+  if (FileSystemStorageExt::EXTENSION_ID.valid())
+    return;
+
+  FileSystemStorageExt::EXTENSION_ID = simgrid::s4u::Storage::extension_create<FileSystemStorageExt>();
+
+  simgrid::s4u::Storage::onCreation.connect(&onStorageCreation);
+  simgrid::s4u::Storage::onDestruction.connect(&onStorageDestruction);
+}
+
+SG_END_DECL()
index 5cb09af..9123343 100644 (file)
@@ -3,6 +3,7 @@
 /* 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/File.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Storage.hpp"
 #include "simgrid/simix.hpp"
 #include <unordered_map>
 
 namespace simgrid {
+namespace xbt {
+template class Extendable<simgrid::s4u::Storage>;
+}
+
 namespace s4u {
 
 std::map<std::string, Storage*>* allStorages()
@@ -52,17 +57,27 @@ Host* Storage::getHost()
 
 sg_size_t Storage::getSizeFree()
 {
-  return simgrid::simix::kernelImmediate([this] { return pimpl_->getFreeSize(); });
+  FileSystemStorageExt* file_system = extension<FileSystemStorageExt>();
+
+  return pimpl_->getSize() - file_system->getUsedSize();
 }
 
 sg_size_t Storage::getSizeUsed()
 {
-  return simgrid::simix::kernelImmediate([this] { return pimpl_->getUsedSize(); });
+  FileSystemStorageExt* file_system = extension<FileSystemStorageExt>();
+  return file_system->getUsedSize();
 }
 
 void Storage::decrUsedSize(sg_size_t size)
 {
-  simgrid::simix::kernelImmediate([this, size] { pimpl_->usedSize_ -= size; });
+  FileSystemStorageExt* file_system = extension<FileSystemStorageExt>();
+  file_system->decrUsedSize(size);
+}
+
+void Storage::incrUsedSize(sg_size_t size)
+{
+  FileSystemStorageExt* file_system = extension<FileSystemStorageExt>();
+  file_system->incrUsedSize(size);
 }
 
 sg_size_t Storage::getSize()
@@ -87,7 +102,8 @@ void Storage::setProperty(std::string key, std::string value)
 
 std::map<std::string, sg_size_t>* Storage::getContent()
 {
-  return simgrid::simix::kernelImmediate([this] { return pimpl_->getContent(); });
+  FileSystemStorageExt* file_system = extension<FileSystemStorageExt>();
+  return file_system->getContent();
 }
 
 sg_size_t Storage::read(sg_size_t size)
index cc888dd..9ce12e2 100644 (file)
@@ -5,13 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "StorageImpl.hpp"
-
 #include "surf_private.hpp"
-#include <algorithm>
-#include <boost/algorithm/string.hpp>
-#include <boost/algorithm/string/join.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <fstream>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
 
@@ -64,10 +58,10 @@ StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSyst
     : Resource(model, name.c_str(), lmm_constraint_new(maxminSystem, this, std::max(bread, bwrite)))
     , piface_(this)
     , typeId_(type_id)
+    , content_name(content_name)
     , size_(size)
     , attach_(attach)
 {
-  content_ = parseContent(content_name);
   StorageImpl::turnOn();
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
   constraintRead_  = lmm_constraint_new(maxminSystem, this, bread);
@@ -78,37 +72,8 @@ StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSyst
 StorageImpl::~StorageImpl()
 {
   storageDestructedCallbacks(this);
-  if (content_ != nullptr)
-    delete content_;
 }
 
-std::map<std::string, sg_size_t>* StorageImpl::parseContent(std::string filename)
-{
-  usedSize_ = 0;
-  if (filename.empty())
-    return nullptr;
-
-  std::map<std::string, sg_size_t>* parse_content = new std::map<std::string, sg_size_t>();
-
-  std::ifstream* fs = surf_ifsopen(filename);
-
-  std::string line;
-  std::vector<std::string> tokens;
-  do {
-    std::getline(*fs, line);
-    boost::trim(line);
-    if (line.length() > 0) {
-      boost::split(tokens, line, boost::is_any_of(" \t"), boost::token_compress_on);
-      xbt_assert(tokens.size() == 2, "Parse error in %s: %s", filename.c_str(), line.c_str());
-      sg_size_t size = std::stoull(tokens.at(1));
-
-      usedSize_ += size;
-      parse_content->insert({tokens.front(), size});
-    }
-  } while (not fs->eof());
-  delete fs;
-  return parse_content;
-}
 
 bool StorageImpl::isUsed()
 {
@@ -136,22 +101,6 @@ void StorageImpl::turnOff()
   }
 }
 
-std::map<std::string, sg_size_t>* StorageImpl::getContent()
-{
-  /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
-  return content_;
-}
-
-sg_size_t StorageImpl::getFreeSize()
-{
-  return size_ - usedSize_;
-}
-
-sg_size_t StorageImpl::getUsedSize()
-{
-  return usedSize_;
-}
-
 /**********
  * Action *
  **********/
index c66f9f9..d83cd62 100644 (file)
@@ -115,31 +115,9 @@ public:
    * @return The StorageAction corresponding to the writing
    */
   virtual StorageAction* write(sg_size_t size) = 0;
-
-  /**
-   * @brief Get the content of the current Storage
-   *
-   * @return A map with path as keys and size in bytes as values
-   */
-  virtual std::map<std::string, sg_size_t>* getContent();
-
-  /**
-   * @brief Get the available size in bytes of the current Storage
-   *
-   * @return The available size in bytes of the current Storage
-   */
-  virtual sg_size_t getFreeSize();
-
-  /**
-   * @brief Get the used size in bytes of the current Storage
-   *
-   * @return The used size in bytes of the current Storage
-   */
-  virtual sg_size_t getUsedSize();
   virtual sg_size_t getSize() { return size_; }
   virtual std::string getHost() { return attach_; }
 
-  std::map<std::string, sg_size_t>* parseContent(std::string filename);
   static std::unordered_map<std::string, StorageImpl*>* storagesMap() { return StorageImpl::storages; }
 
   lmm_constraint_t constraintWrite_; /* Constraint for maximum write bandwidth*/
@@ -147,11 +125,11 @@ public:
 
   std::string typeId_;
   sg_size_t usedSize_ = 0;
+  std::string content_name;
 
 private:
   sg_size_t size_;
   static std::unordered_map<std::string, StorageImpl*>* storages;
-  std::map<std::string, sg_size_t>* content_;
   // Name of the host to which this storage is attached. Only used at platform parsing time, then the interface stores
   // the Host directly.
   std::string attach_;
index 54f2847..71ee41d 100644 (file)
@@ -78,20 +78,13 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
   for (auto it = std::begin(*getRunningActionSet()); it != std::end(*getRunningActionSet());) {
     StorageAction& action = static_cast<StorageAction&>(*it);
     ++it; // increment iterator here since the following calls to action.finish() may invalidate it
-    double current_progress = lrint(lmm_variable_getvalue(action.getVariable()) * delta);
-    action.updateRemains(current_progress);
-    if (action.type_ == WRITE) {
-      action.storage_->usedSize_ += current_progress;
-    }
+    action.updateRemains(lrint(lmm_variable_getvalue(action.getVariable()) * delta));
 
     if (action.getMaxDuration() > NO_MAX_DURATION)
       action.updateMaxDuration(delta);
 
-    if (action.getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action.getVariable()) > 0 &&
-        action.storage_->usedSize_ == action.storage_->getSize()) {
-      action.finish(Action::State::failed);
-    } else if (((action.getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
-               ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+    if (((action.getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action.getVariable()) > 0)) ||
+        ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
       action.finish(Action::State::done);
     }
   }
index d0fc423..e4cfac8 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/msg.h"
+#include "simgrid/plugins/file_system.h"
 #include <xbt/replay.hpp>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(storage_actions, "Messages specific for this example");
@@ -98,6 +99,7 @@ static void action_close(const char* const* action)
 int main(int argc, char* argv[])
 {
   MSG_init(&argc, argv);
+  MSG_storage_file_system_init();
   /* Explicit initialization of the action module is required */
   MSG_action_init();
 
index 217a166..0c1db3c 100644 (file)
@@ -4,38 +4,27 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u.hpp"
-#include <unistd.h>
-
-#define FILENAME1 "/home/doc/simgrid/examples/platforms/g5k.xml"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u test");
 
 static void host()
 {
-  char name[2048];
+  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk1");
   int id = simgrid::s4u::this_actor::getPid();
-  snprintf(name, 2048, "%s%i", FILENAME1, id);
-  simgrid::s4u::File* file = new simgrid::s4u::File(name, NULL);
   XBT_INFO("process %d is writing!", id);
-  file->write(3000000);
+  storage->write(3000000);
   XBT_INFO("process %d goes to sleep for %d seconds", id, id);
   simgrid::s4u::this_actor::sleep_for(id);
   XBT_INFO("process %d is writing again!", id);
-  file->write(3000000);
+  storage->write(3000000);
   XBT_INFO("process %d goes to sleep for %d seconds", id, 6 - id);
   simgrid::s4u::this_actor::sleep_for(6 - id);
   XBT_INFO("process %d is reading!", id);
-  file->seek(0);
-  file->read(3000000);
+  storage->read(3000000);
   XBT_INFO("process %d goes to sleep for %d seconds", id, id);
   simgrid::s4u::this_actor::sleep_for(id);
   XBT_INFO("process %d is reading again!", id);
-  file->seek(0);
-  file->read(3000000);
-
-  XBT_INFO("process %d => Size of %s: %llu", id, name, file->size());
-  // Close the file
-  delete file;
+  storage->read(3000000);
 }
 
 int main(int argc, char** argv)
index 6e2576a..1d46abe 100644 (file)
@@ -30,13 +30,8 @@ $ ./concurrent_rw$EXEEXT ${srcdir:=.}/../../../examples/platforms/storage/storag
 > [  6.750000] (host@bob) process 4 goes to sleep for 4 seconds
 > [  6.750000] (host@bob) process 5 goes to sleep for 5 seconds
 > [  7.750000] (host@bob) process 1 is reading again!
-> [  7.780000] (host@bob) process 1 => Size of /home/doc/simgrid/examples/platforms/g5k.xml1: 6000000
 > [  8.750000] (host@bob) process 2 is reading again!
-> [  8.780000] (host@bob) process 2 => Size of /home/doc/simgrid/examples/platforms/g5k.xml2: 6000000
 > [  9.750000] (host@bob) process 3 is reading again!
-> [  9.780000] (host@bob) process 3 => Size of /home/doc/simgrid/examples/platforms/g5k.xml3: 6000000
 > [ 10.750000] (host@bob) process 4 is reading again!
-> [ 10.780000] (host@bob) process 4 => Size of /home/doc/simgrid/examples/platforms/g5k.xml4: 6000000
 > [ 11.750000] (host@bob) process 5 is reading again!
-> [ 11.780000] (host@bob) process 5 => Size of /home/doc/simgrid/examples/platforms/g5k.xml5: 6000000
 > [ 11.780000] (maestro@) Simulation time 11.78
index 9ef8840..78598bc 100644 (file)
@@ -157,6 +157,7 @@ static void server()
 int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
+  sg_storage_file_system_init();
   xbt_assert(argc == 2, "Usage: %s platform_file\n", argv[0]);
   e.loadPlatform(argv[1]);
 
index 08781a1..0a7dffc 100644 (file)
@@ -54,11 +54,11 @@ $ ./storage_client_server$EXEEXT ${srcdir:=.}/../../../examples/platforms/storag
 > [  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: c:
+> [  1.207952] (server@alice)          Free size: 534479367024 bytes
+> [  1.207952] (server@alice)          Used size: 2391544976 bytes
 > [  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)          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
index 510bb81..18103ba 100644 (file)
@@ -664,6 +664,7 @@ set(MC_SIMGRID_MC_SRC  src/mc/checker/simgrid_mc.cpp)
 set(headers_to_install
   include/simgrid/chrono.hpp
   include/simgrid/plugins/energy.h
+  include/simgrid/plugins/file_system.h
   include/simgrid/plugins/load.h
   include/simgrid/instr.h
   include/simgrid/msg.h