Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 29 Nov 2017 11:48:50 +0000 (12:48 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 29 Nov 2017 11:48:50 +0000 (12:48 +0100)
examples/s4u/io/s4u-io.cpp
include/simgrid/msg.h
include/simgrid/plugins/file_system.h
include/simgrid/s4u/Storage.hpp
src/bindings/java/jmsg_storage.cpp
src/msg/msg_io.cpp
src/s4u/s4u_file.cpp
src/s4u/s4u_storage.cpp
teshsuite/s4u/storage_client_server/storage_client_server.cpp

index c783697..ab43a7a 100644 (file)
@@ -21,12 +21,8 @@ public:
       simgrid::s4u::Storage* storage = kv.second;
 
       // Retrieve disk's information
-      sg_size_t free_size = storage->getSizeFree();
-      sg_size_t used_size = storage->getSizeUsed();
-      sg_size_t size      = storage->getSize();
-
-      XBT_INFO("    %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->getCname(), mountpoint.c_str(), used_size,
-               free_size, size);
+      XBT_INFO("    %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->getCname(), mountpoint.c_str(),
+               sg_storage_get_size_used(storage), sg_storage_get_size_free(storage), sg_storage_get_size(storage));
     }
   }
 
index c8af06f..ad8c242 100644 (file)
@@ -234,8 +234,6 @@ XBT_PUBLIC(msg_error_t) MSG_file_rcopy(msg_file_t fd, msg_host_t host, const cha
 XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const char* fullpath);
 /************************** Storage handling ***********************************/
 XBT_PUBLIC(const char *) MSG_storage_get_name(msg_storage_t storage);
-XBT_PUBLIC(sg_size_t) MSG_storage_get_free_size(msg_storage_t storage);
-XBT_PUBLIC(sg_size_t) MSG_storage_get_used_size(msg_storage_t storage);
 XBT_PUBLIC(msg_storage_t) MSG_storage_get_by_name(const char *name);
 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);
@@ -244,7 +242,6 @@ XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar();
 XBT_PUBLIC(msg_error_t) MSG_storage_set_data(msg_storage_t host, void *data);
 XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage);
 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage);
-XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage);
 XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage);
 XBT_PUBLIC(sg_size_t) MSG_storage_read(msg_storage_t storage, sg_size_t size);
 XBT_PUBLIC(sg_size_t) MSG_storage_write(msg_storage_t storage, sg_size_t size);
index bb22a1a..b89b951 100644 (file)
 SG_BEGIN_DECL()
 
 XBT_PUBLIC(void) sg_storage_file_system_init();
+XBT_PUBLIC(sg_size_t) sg_storage_get_size_free(sg_storage_t st);
+XBT_PUBLIC(sg_size_t) sg_storage_get_size_used(sg_storage_t st);
+XBT_PUBLIC(sg_size_t) sg_storage_get_size(sg_storage_t st);
 
 #define MSG_storage_file_system_init() sg_storage_file_system_init()
+#define MSG_storage_get_free_size(st) sg_storage_get_size_free(st)
+#define MSG_storage_get_used_size(st) sg_storage_get_size_used(st)
+#define MSG_storage_get_size(st) sg_storage_get_size(st)
 
 SG_END_DECL()
 
index 8ba939c..9b1fe85 100644 (file)
@@ -39,11 +39,6 @@ public:
   const char* getCname() const;
   const char* getType();
   Host* getHost();
-  sg_size_t getSize(); /** Retrieve the total amount of space of this storage element */
-  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 a31349d..548780c 100644 (file)
@@ -6,6 +6,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 "include/xbt/signal.hpp"
 #include "jmsg.hpp"
index 3949987..9484c56 100644 (file)
@@ -361,26 +361,6 @@ const char* MSG_storage_get_name(msg_storage_t storage)
   return storage->getCname();
 }
 
-/** \ingroup msg_storage_management
- * \brief Returns the free space size of a storage element
- * \param storage a storage
- * \return the free space size of the storage element (as a #sg_size_t)
- */
-sg_size_t MSG_storage_get_free_size(msg_storage_t storage)
-{
-  return storage->getSizeFree();
-}
-
-/** \ingroup msg_storage_management
- * \brief Returns the used space size of a storage element
- * \param storage a storage
- * \return the used space size of the storage element (as a #sg_size_t)
- */
-sg_size_t MSG_storage_get_used_size(msg_storage_t storage)
-{
-  return storage->getSizeUsed();
-}
-
 /** \ingroup msg_storage_management
  * \brief Returns a xbt_dict_t consisting of the list of properties assigned to this storage
  * \param storage a storage
@@ -489,17 +469,6 @@ xbt_dict_t MSG_storage_get_content(msg_storage_t storage)
   return content_as_dict;
 }
 
-/** \ingroup msg_storage_management
- *
- * \brief Returns the size of a #msg_storage_t.
- * \param storage a storage
- * \return The size of the storage
- */
-sg_size_t MSG_storage_get_size(msg_storage_t storage)
-{
-  return storage->getSize();
-}
-
 /** \ingroup msg_storage_management
  *
  * \brief Returns the host name the storage is attached to
index a78e0f9..a81e922 100644 (file)
@@ -76,13 +76,13 @@ sg_size_t File::write(sg_size_t size)
 {
   XBT_DEBUG("WRITE %s on disk '%s'. size '%llu/%llu'", getPath(), localStorage->getCname(), size, size_);
   // If the storage is full before even starting to write
-  if (localStorage->getSizeUsed() >= localStorage->getSize())
+  if (sg_storage_get_size_used(localStorage) >= sg_storage_get_size(localStorage))
     return 0;
   /* Substract the part of the file that might disappear from the used sized on the storage element */
-  localStorage->decrUsedSize(size_ - current_position_);
+  localStorage->extension<FileSystemStorageExt>()->decrUsedSize(size_ - current_position_);
 
   sg_size_t write_size = localStorage->write(size);
-  localStorage->incrUsedSize(write_size);
+  localStorage->extension<FileSystemStorageExt>()->incrUsedSize(write_size);
 
   current_position_ += write_size;
   size_ = current_position_;
@@ -153,7 +153,7 @@ int File::unlink()
     return -1;
   } else {
     XBT_DEBUG("UNLINK %s on disk '%s'", path_.c_str(), localStorage->getCname());
-    localStorage->decrUsedSize(size_);
+    localStorage->extension<FileSystemStorageExt>()->decrUsedSize(size_);
 
     // Remove the file from storage
     localStorage->getContent()->erase(fullpath_);
@@ -228,4 +228,19 @@ void sg_storage_file_system_init()
   simgrid::s4u::Storage::onDestruction.connect(&onStorageDestruction);
 }
 
+sg_size_t sg_storage_get_size_free(sg_storage_t st)
+{
+  return st->getImpl()->getSize() - st->extension<FileSystemStorageExt>()->getUsedSize();
+}
+
+sg_size_t sg_storage_get_size_used(sg_storage_t st)
+{
+  return st->extension<FileSystemStorageExt>()->getUsedSize();
+}
+
+sg_size_t sg_storage_get_size(sg_storage_t st)
+{
+  return st->getImpl()->getSize();
+}
+
 SG_END_DECL()
index 9123343..96f9733 100644 (file)
@@ -55,35 +55,6 @@ Host* Storage::getHost()
   return attached_to_;
 }
 
-sg_size_t Storage::getSizeFree()
-{
-  FileSystemStorageExt* file_system = extension<FileSystemStorageExt>();
-
-  return pimpl_->getSize() - file_system->getUsedSize();
-}
-
-sg_size_t Storage::getSizeUsed()
-{
-  FileSystemStorageExt* file_system = extension<FileSystemStorageExt>();
-  return file_system->getUsedSize();
-}
-
-void Storage::decrUsedSize(sg_size_t 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()
-{
-  return pimpl_->getSize();
-}
 
 std::map<std::string, std::string>* Storage::getProperties()
 {
index 78598bc..3e0169b 100644 (file)
@@ -107,11 +107,8 @@ static void storage_info(simgrid::s4u::Host* host)
     simgrid::s4u::Storage* storage = elm.second;
     XBT_INFO("\tStorage name: %s, mount name: %s", storage->getCname(), mount_name.c_str());
 
-    sg_size_t free_size = storage->getSizeFree();
-    sg_size_t used_size = storage->getSizeUsed();
-
-    XBT_INFO("\t\tFree size: %llu bytes", free_size);
-    XBT_INFO("\t\tUsed size: %llu bytes", used_size);
+    XBT_INFO("\t\tFree size: %llu bytes", sg_storage_get_size_free(storage));
+    XBT_INFO("\t\tUsed size: %llu bytes", sg_storage_get_size_used(storage));
 
     display_storage_properties(storage);
     dump_storage_by_name(storage->getCname());