Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
snake case storage
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 6 Jun 2018 18:20:32 +0000 (20:20 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 6 Jun 2018 18:20:32 +0000 (20:20 +0200)
12 files changed:
examples/s4u/io-file-system/s4u-io-file-system.cpp
examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp
include/simgrid/s4u/Storage.hpp
src/bindings/java/jmsg_storage.cpp
src/kernel/EngineImpl.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/s4u/s4u_Storage.cpp
src/simix/smx_global.cpp
src/surf/sg_platf.cpp
src/surf/storage_n11.cpp
teshsuite/s4u/concurrent_rw/concurrent_rw.cpp
teshsuite/s4u/storage_client_server/storage_client_server.cpp

index 3f18c14..2c34333 100644 (file)
@@ -54,7 +54,7 @@ public:
     write = file->write(100000); // Write 100,000 bytes
     XBT_INFO("Write %llu bytes on %s", write, filename.c_str());
 
-    simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk4");
+    simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name("Disk4");
 
     // Now rename file from ./tmp/data.txt to ./tmp/simgrid.readme
     std::string newpath = "/home/tmp/simgrid.readme";
@@ -72,10 +72,10 @@ public:
 
     // Now attach some user data to disk1
     XBT_INFO("Get/set data for storage element: %s", storage->get_cname());
-    XBT_INFO("    Uninitialized storage data: '%s'", static_cast<char*>(storage->getUserdata()));
+    XBT_INFO("    Uninitialized storage data: '%s'", static_cast<char*>(storage->get_data()));
 
-    storage->setUserdata(new std::string("Some user data"));
-    std::string* storage_data = static_cast<std::string*>(storage->getUserdata());
+    storage->set_data(new std::string("Some user data"));
+    std::string* storage_data = static_cast<std::string*>(storage->get_data());
     XBT_INFO("    Set and get data: '%s'", storage_data->c_str());
 
     delete storage_data;
index bb8e1c5..e594a1e 100644 (file)
@@ -23,7 +23,7 @@ static void host()
     XBT_INFO("Storage name: %s, mount name: %s", kv.second->get_cname(), kv.first.c_str());
 
   /* - Write 200,000 bytes on Disk4 */
-  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk4");
+  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name("Disk4");
   sg_size_t write                = storage->write(200000);
   XBT_INFO("Wrote %llu bytes on 'Disk4'", write);
 
@@ -34,12 +34,12 @@ static void host()
   /* - Attach some user data to disk1 */
   XBT_INFO("*** Get/set data for storage element: Disk4 ***");
 
-  std::string* data = static_cast<std::string*>(storage->getUserdata());
+  std::string* data = static_cast<std::string*>(storage->get_data());
 
   XBT_INFO("Get storage data: '%s'", data ? data->c_str() : "No user data");
 
-  storage->setUserdata(new std::string("Some user data"));
-  data = static_cast<std::string*>(storage->getUserdata());
+  storage->set_data(new std::string("Some user data"));
+  data = static_cast<std::string*>(storage->get_data());
   XBT_INFO("Set and get data: '%s'", data->c_str());
   delete data;
 }
index 13ae9be..6a9704f 100644 (file)
@@ -30,43 +30,63 @@ class XBT_PUBLIC Storage : public simgrid::xbt::Extendable<Storage> {
 
 public:
   explicit Storage(std::string name, surf::StorageImpl * pimpl);
+
+protected:
   virtual ~Storage() = default;
-  /** Retrieve a Storage by its name. It must exist in the platform file */
-  static Storage* byName(std::string name);
 
-  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_name()") std::string const& getName() const { return get_name(); }
-  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_cname()") const char* getCname() const { return get_cname(); }
+public:
+  /** @brief Callback signal fired when a new Storage is created */
+  static simgrid::xbt::signal<void(s4u::Storage&)> on_creation;
+  /** @brief Callback signal fired when a Storage is destroyed */
+  static simgrid::xbt::signal<void(s4u::Storage&)> on_destruction;
+  /** @brief Callback signal fired when a Storage's state changes */
+  static simgrid::xbt::signal<void(s4u::Storage&)> on_state_change;
+
+  /** Retrieve a Storage by its name. It must exist in the platform file */
+  static Storage* by_name(std::string name);
 
   /** @brief Retrieves the name of that storage as a C++ string */
   std::string const& get_name() const;
   /** @brief Retrieves the name of that storage as a C string */
   const char* get_cname() const;
 
-  const char* getType();
-  Host* getHost();
+  const char* get_type();
+  Host* get_host() { return attached_to_; };
+  void set_host(Host* host) { attached_to_ = host; }
 
   std::map<std::string, std::string>* getProperties();
-  const char* getProperty(std::string key);
-  void setProperty(std::string, std::string value);
+  const char* get_property(std::string key);
+  void set_property(std::string, std::string value);
 
-  void setUserdata(void* data) { userdata_ = data; }
-  void* getUserdata() { return userdata_; }
+  void set_data(void* data) { userdata_ = data; }
+  void* get_data() { return userdata_; }
 
   sg_size_t read(sg_size_t size);
   sg_size_t write(sg_size_t size);
-  surf::StorageImpl* getImpl() { return pimpl_; }
-
-  /* The signals */
-  /** @brief Callback signal fired when a new Storage is created */
-  static simgrid::xbt::signal<void(s4u::Storage&)> on_creation;
-  /** @brief Callback signal fired when a Storage is destroyed */
-  static simgrid::xbt::signal<void(s4u::Storage&)> on_destruction;
-  /** @brief Callback signal fired when a Storage's state changes */
-  static simgrid::xbt::signal<void(s4u::Storage&)> on_state_change;
+  surf::StorageImpl* get_impl() { return pimpl_; }
 
-  Host* attached_to_              = nullptr;
+  // Deprecated functions
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::by_name()") Storage* byName(std::string name)
+  {
+    return by_name(name);
+  }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_name()") std::string const& getName() const { return get_name(); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_cname()") const char* getCname() const { return get_cname(); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_type()") const char* getType() { return get_type(); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_host()") Host* getHost() { return get_host(); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_property()") const char* getProperty(const char* key)
+  {
+    return get_property(key);
+  }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::set_property()") void setProperty(std::string key, std::string value)
+  {
+    set_property(key, value);
+  }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::set_data()") void setUserdata(void* data) { set_data(data); }
+  XBT_ATTRIB_DEPRECATED_v323("Please use Storage::get_data()") void* getUserdata() { return get_data(); }
 
 private:
+  Host* attached_to_              = nullptr;
   surf::StorageImpl* const pimpl_ = nullptr;
   std::string name_;
   void* userdata_ = nullptr;
index 15fedd9..1ade9fc 100644 (file)
@@ -166,7 +166,7 @@ Java_org_simgrid_msg_Storage_setProperty(JNIEnv *env, jobject jstorage, jobject
   const char *name = env->GetStringUTFChars((jstring) jname, 0);
   const char *value_java = env->GetStringUTFChars((jstring) jvalue, 0);
 
-  storage->setProperty(name, std::string(value_java));
+  storage->set_property(name, std::string(value_java));
 
   env->ReleaseStringUTFChars((jstring) jvalue, value_java);
   env->ReleaseStringUTFChars((jstring) jname, name);
index 401e3a7..34efc84 100644 (file)
@@ -41,7 +41,7 @@ EngineImpl::~EngineImpl()
 
   for (auto const& kv : storages_)
     if (kv.second)
-      kv.second->getImpl()->destroy();
+      kv.second->get_impl()->destroy();
 
   for (auto const& kv : links_)
     if (kv.second)
index 5957459..0dd3287 100644 (file)
@@ -87,7 +87,7 @@ void File::dump()
            "\t\tStorage Id: '%s'\n"
            "\t\tStorage Type: '%s'\n"
            "\t\tFile Descriptor Id: %d",
-           get_path(), size_, mount_point_.c_str(), local_storage_->get_cname(), local_storage_->getType(), desc_id);
+           get_path(), size_, mount_point_.c_str(), local_storage_->get_cname(), local_storage_->get_type(), desc_id);
 }
 
 sg_size_t File::read(sg_size_t size)
@@ -96,7 +96,7 @@ sg_size_t File::read(sg_size_t size)
     return 0;
 
   /* Find the host where the file is physically located and read it */
-  Host* host = local_storage_->getHost();
+  Host* host = local_storage_->get_host();
   XBT_DEBUG("READ %s on disk '%s'", get_path(), local_storage_->get_cname());
   // if the current position is close to the end of the file, we may not be able to read the requested size
   sg_size_t read_size = local_storage_->read(std::min(size, size_ - current_position_));
@@ -127,7 +127,7 @@ sg_size_t File::write(sg_size_t size)
     return 0;
 
   /* Find the host where the file is physically located (remote or local)*/
-  Host* host = local_storage_->getHost();
+  Host* host = local_storage_->get_host();
 
   if (strcmp(host->get_cname(), Host::current()->get_cname())) {
     /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
@@ -234,7 +234,7 @@ int File::remote_copy(sg_host_t host, const char* fullpath)
 {
   /* Find the host where the file is physically located and read it */
   Storage* storage_src = local_storage_;
-  Host* src_host       = storage_src->getHost();
+  Host* src_host       = storage_src->get_host();
   seek(0, SEEK_SET);
   XBT_DEBUG("READ %s on disk '%s'", get_path(), local_storage_->get_cname());
   // if the current position is close to the end of the file, we may not be able to read the requested size
@@ -257,14 +257,14 @@ int File::remote_copy(sg_host_t host, const char* fullpath)
 
   if (storage_dest != nullptr) {
     /* Mount point found, retrieve the host the storage is attached to */
-    dst_host = storage_dest->getHost();
+    dst_host = storage_dest->get_host();
   } else {
     XBT_WARN("Can't find mount point for '%s' on destination host '%s'", fullpath, host->get_cname());
     return -1;
   }
 
   XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, src_host->get_cname(),
-            storage_dest->getHost()->get_cname());
+            storage_dest->get_host()->get_cname());
   Host* m_host_list[]     = {src_host, dst_host};
   double* flops_amount    = new double[2]{0, 0};
   double* bytes_amount    = new double[4]{0, static_cast<double>(read_size), 0, 0};
@@ -289,8 +289,8 @@ int File::remote_move(sg_host_t host, const char* fullpath)
 
 FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr)
 {
-  content_ = parse_content(ptr->getImpl()->content_name);
-  size_    = ptr->getImpl()->size_;
+  content_ = parse_content(ptr->get_impl()->content_name);
+  size_    = ptr->get_impl()->size_;
 }
 
 FileSystemStorageExt::~FileSystemStorageExt()
index aa0904d..cf8b3ca 100644 (file)
@@ -30,7 +30,7 @@ Storage::Storage(std::string name, surf::StorageImpl* pimpl) : pimpl_(pimpl), na
   simgrid::s4u::Engine::get_instance()->storage_register(name, this);
 }
 
-Storage* Storage::byName(std::string name)
+Storage* Storage::by_name(std::string name)
 {
   return Engine::get_instance()->storage_by_name_or_null(name);
 }
@@ -45,27 +45,22 @@ const char* Storage::get_cname() const
   return name_.c_str();
 }
 
-const char* Storage::getType()
+const char* Storage::get_type()
 {
   return pimpl_->typeId_.c_str();
 }
 
-Host* Storage::getHost()
-{
-  return attached_to_;
-}
-
 std::map<std::string, std::string>* Storage::getProperties()
 {
   return simgrid::simix::simcall([this] { return pimpl_->get_properties(); });
 }
 
-const char* Storage::getProperty(std::string key)
+const char* Storage::get_property(std::string key)
 {
   return this->pimpl_->get_property(key);
 }
 
-void Storage::setProperty(std::string key, std::string value)
+void Storage::set_property(std::string key, std::string value)
 {
   simgrid::simix::simcall([this, key, value] { this->pimpl_->set_property(key, value); });
 }
@@ -111,7 +106,7 @@ const char* sg_storage_get_name(sg_storage_t storage)
 const char* sg_storage_get_host(sg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters");
-  return storage->getHost()->get_cname();
+  return storage->get_host()->get_cname();
 }
 
 /** \ingroup sg_storage_management
@@ -141,7 +136,7 @@ xbt_dict_t sg_storage_get_properties(sg_storage_t storage)
  */
 void sg_storage_set_property_value(sg_storage_t storage, const char* name, const char* value)
 {
-  storage->setProperty(name, value);
+  storage->set_property(name, value);
 }
 
 /** \ingroup sg_storage_management
@@ -153,7 +148,7 @@ void sg_storage_set_property_value(sg_storage_t storage, const char* name, const
  */
 const char* sg_storage_get_property_value(sg_storage_t storage, const char* name)
 {
-  return storage->getProperty(name);
+  return storage->get_property(name);
 }
 
 /** \ingroup sg_storage_management
@@ -163,7 +158,7 @@ const char* sg_storage_get_property_value(sg_storage_t storage, const char* name
  */
 sg_storage_t sg_storage_get_by_name(const char* name)
 {
-  return simgrid::s4u::Storage::byName(name);
+  return simgrid::s4u::Storage::by_name(name);
 }
 
 /** \ingroup sg_storage_management
@@ -181,12 +176,12 @@ xbt_dynar_t sg_storages_as_dynar()
 void* sg_storage_get_data(sg_storage_t storage)
 {
   xbt_assert((storage != nullptr), "Invalid parameters");
-  return storage->getUserdata();
+  return storage->get_data();
 }
 
 void sg_storage_set_data(sg_storage_t storage, void* data)
 {
-  storage->setUserdata(data);
+  storage->set_data(data);
 }
 
 sg_size_t sg_storage_read(sg_storage_t storage, sg_size_t size)
index 667e50a..4f05ede 100644 (file)
@@ -216,7 +216,7 @@ void SIMIX_global_init(int *argc, char **argv)
     });
 
     simgrid::s4u::Storage::on_creation.connect([](simgrid::s4u::Storage& storage) {
-      sg_storage_t s = simgrid::s4u::Storage::byName(storage.get_cname());
+      sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_cname());
       xbt_assert(s != nullptr, "Storage not found for name %s", storage.get_cname());
     });
   }
index 2f0997c..6498e13 100644 (file)
@@ -393,7 +393,7 @@ void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount)
 
   if (mount_list.empty())
     XBT_DEBUG("Create a Mount list for %s", A_surfxml_host_id);
-  mount_list.insert({mount->name, simgrid::s4u::Engine::get_instance()->storage_by_name(mount->storageId)->getImpl()});
+  mount_list.insert({mount->name, simgrid::s4u::Engine::get_instance()->storage_by_name(mount->storageId)->get_impl()});
 }
 
 void sg_platf_new_route(simgrid::kernel::routing::RouteCreationArgs* route)
index c9bcc38..78ac82e 100644 (file)
@@ -20,12 +20,12 @@ extern std::map<std::string, simgrid::surf::StorageType*> storage_types;
 void check_disk_attachment()
 {
   for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) {
-    simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s->getImpl()->getHost().c_str());
+    simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s->get_impl()->getHost().c_str());
     if (not host_elm)
       surf_parse_error(std::string("Unable to attach storage ") + s->get_cname() + ": host " +
-                       s->getImpl()->getHost().c_str() + " does not exist.");
+                       s->get_impl()->getHost().c_str() + " does not exist.");
     else
-      s->attached_to_ = sg_host_by_name(s->getImpl()->getHost().c_str());
+      s->set_host(sg_host_by_name(s->get_impl()->getHost().c_str()));
   }
 }
 
index de5f855..66fbe1e 100644 (file)
@@ -9,7 +9,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u test");
 
 static void host()
 {
-  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk1");
+  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name("Disk1");
   int id                         = simgrid::s4u::this_actor::get_pid();
   XBT_INFO("process %d is writing!", id);
   storage->write(3000000);
index 813b037..b91d2cc 100644 (file)
@@ -72,19 +72,19 @@ static void display_storage_content(simgrid::s4u::Storage* storage)
 static void dump_storage_by_name(const std::string& name)
 {
   XBT_INFO("*** Dump a storage element ***");
-  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName(name);
+  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name(name);
   display_storage_content(storage);
 }
 
 static void get_set_storage_data(const std::string& storage_name)
 {
   XBT_INFO("*** GET/SET DATA for storage element: %s ***", storage_name.c_str());
-  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName(storage_name);
+  simgrid::s4u::Storage* storage = simgrid::s4u::Storage::by_name(storage_name);
 
-  std::string* data = static_cast<std::string*>(storage->getUserdata());
+  std::string* data = static_cast<std::string*>(storage->get_data());
   XBT_INFO("Get data: '%s'", data ? data->c_str() : "No User Data");
-  storage->setUserdata(new std::string("Some data"));
-  data = static_cast<std::string*>(storage->getUserdata());
+  storage->set_data(new std::string("Some data"));
+  data = static_cast<std::string*>(storage->get_data());
   XBT_INFO("\tSet and get data: '%s'", data->c_str());
   delete data;
 }
@@ -94,8 +94,8 @@ static void dump_platform_storages()
   std::vector<simgrid::s4u::Storage*> storages = simgrid::s4u::Engine::get_instance()->get_all_storages();
 
   for (auto const& s : storages) {
-    XBT_INFO("Storage %s is attached to %s", s->get_cname(), s->getHost()->get_cname());
-    s->setProperty("other usage", "gpfs");
+    XBT_INFO("Storage %s is attached to %s", s->get_cname(), s->get_host()->get_cname());
+    s->set_property("other usage", "gpfs");
   }
 }