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));
}
}
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);
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);
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()
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);
* 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"
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
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
{
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_;
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_);
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()
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()
{
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());