Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename the Storage fields to follow our naming conventions
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 19 Aug 2016 13:12:34 +0000 (15:12 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 19 Aug 2016 21:30:34 +0000 (23:30 +0200)
src/surf/HostImpl.cpp
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp
src/surf/storage_n11.cpp
src/surf/surf_c_bindings.cpp
src/surf/surf_routing.cpp

index eef8795..66c97a6 100644 (file)
@@ -215,7 +215,7 @@ xbt_dynar_t HostImpl::getAttachedStorageList()
   xbt_lib_foreach(storage_lib, cursor, key, data) {
     if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) {
     simgrid::surf::Storage *storage = static_cast<simgrid::surf::Storage*>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
   xbt_lib_foreach(storage_lib, cursor, key, data) {
     if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) {
     simgrid::surf::Storage *storage = static_cast<simgrid::surf::Storage*>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
-    if(!strcmp((const char*)storage->p_attach,this->getName())){
+    if(!strcmp((const char*)storage->attach_,this->getName())){
       xbt_dynar_push_as(result, void *, (void*)storage->getName());
     }
   }
       xbt_dynar_push_as(result, void *, (void*)storage->getName());
     }
   }
@@ -293,16 +293,16 @@ int HostImpl::unlink(surf_file_t fd) {
 
     simgrid::surf::Storage *st = findStorageOnMountList(fd->mount);
     /* Check if the file is on this storage */
 
     simgrid::surf::Storage *st = findStorageOnMountList(fd->mount);
     /* Check if the file is on this storage */
-    if (!xbt_dict_get_or_null(st->p_content, fd->name)){
+    if (!xbt_dict_get_or_null(st->content_, fd->name)){
       XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
           st->getName());
       return -1;
     } else {
       XBT_DEBUG("UNLINK %s on disk '%s'",fd->name, st->getName());
       XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
           st->getName());
       return -1;
     } else {
       XBT_DEBUG("UNLINK %s on disk '%s'",fd->name, st->getName());
-      st->m_usedSize -= fd->size;
+      st->usedSize_ -= fd->size;
 
       // Remove the file from storage
 
       // Remove the file from storage
-      xbt_dict_remove(st->p_content, fd->name);
+      xbt_dict_remove(st->content_, fd->name);
 
       xbt_free(fd->name);
       xbt_free(fd->mount);
 
       xbt_free(fd->name);
       xbt_free(fd->mount);
@@ -325,8 +325,8 @@ xbt_dynar_t HostImpl::getInfo( surf_file_t fd)
   xbt_dynar_push_as(info, sg_size_t *, psize);
   xbt_dynar_push_as(info, void *, fd->mount);
   xbt_dynar_push_as(info, void *, (void *)st->getName());
   xbt_dynar_push_as(info, sg_size_t *, psize);
   xbt_dynar_push_as(info, void *, fd->mount);
   xbt_dynar_push_as(info, void *, (void *)st->getName());
-  xbt_dynar_push_as(info, void *, st->p_typeId);
-  xbt_dynar_push_as(info, void *, st->p_contentType);
+  xbt_dynar_push_as(info, void *, st->typeId_);
+  xbt_dynar_push_as(info, void *, st->contentType_);
 
   return info;
 }
 
   return info;
 }
@@ -357,16 +357,16 @@ int HostImpl::fileMove(surf_file_t fd, const char* fullpath){
   if(!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
     sg_size_t *psize, *new_psize;
     psize = (sg_size_t*)
   if(!strncmp((const char*)fd->mount, fullpath, strlen(fd->mount))) {
     sg_size_t *psize, *new_psize;
     psize = (sg_size_t*)
-        xbt_dict_get_or_null(findStorageOnMountList(fd->mount)->p_content,
+        xbt_dict_get_or_null(findStorageOnMountList(fd->mount)->content_,
                              fd->name);
     new_psize = xbt_new(sg_size_t, 1);
     *new_psize = *psize;
     if (psize){// src file exists
                              fd->name);
     new_psize = xbt_new(sg_size_t, 1);
     *new_psize = *psize;
     if (psize){// src file exists
-      xbt_dict_remove(findStorageOnMountList(fd->mount)->p_content, fd->name);
+      xbt_dict_remove(findStorageOnMountList(fd->mount)->content_, fd->name);
       char *path = (char *) xbt_malloc ((strlen(fullpath)-strlen(fd->mount)+1));
       strncpy(path, fullpath+strlen(fd->mount),
               strlen(fullpath)-strlen(fd->mount)+1);
       char *path = (char *) xbt_malloc ((strlen(fullpath)-strlen(fd->mount)+1));
       strncpy(path, fullpath+strlen(fd->mount),
               strlen(fullpath)-strlen(fd->mount)+1);
-      xbt_dict_set(findStorageOnMountList(fd->mount)->p_content, path,
+      xbt_dict_set(findStorageOnMountList(fd->mount)->content_, path,
                    new_psize,nullptr);
       XBT_DEBUG("Move file from %s to %s, size '%llu'",fd->name, fullpath, *psize);
       free(path);
                    new_psize,nullptr);
       XBT_DEBUG("Move file from %s to %s, size '%llu'",fd->name, fullpath, *psize);
       free(path);
index 452b993..3edbbb7 100644 (file)
@@ -53,12 +53,12 @@ Storage::Storage(Model *model, const char *name, xbt_dict_t props,
                  sg_size_t size)
  : Resource(model, name)
  , PropertyHolder(props)
                  sg_size_t size)
  : Resource(model, name)
  , PropertyHolder(props)
- , p_contentType(xbt_strdup(content_type))
- , m_size(size), m_usedSize(0)
- , p_typeId(xbt_strdup(type_id))
- , p_writeActions(std::vector<StorageAction*>())
+ , contentType_(xbt_strdup(content_type))
+ , size_(size), usedSize_(0)
+ , typeId_(xbt_strdup(type_id))
+ , writeActions_(std::vector<StorageAction*>())
 {
 {
-  p_content = parseContent(content_name);
+  content_ = parseContent(content_name);
   turnOn();
 }
 
   turnOn();
 }
 
@@ -68,30 +68,30 @@ Storage::Storage(Model *model, const char *name, xbt_dict_t props,
                  const char *content_type, sg_size_t size, const char *attach)
  : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
  , PropertyHolder(props)
                  const char *content_type, sg_size_t size, const char *attach)
  : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
  , PropertyHolder(props)
- , p_contentType(xbt_strdup(content_type))
- , m_size(size), m_usedSize(0)
- , p_typeId(xbt_strdup(type_id))
- , p_writeActions(std::vector<StorageAction*>())
+ , contentType_(xbt_strdup(content_type))
+ , size_(size), usedSize_(0)
+ , typeId_(xbt_strdup(type_id))
+ , writeActions_(std::vector<StorageAction*>())
 {
 {
-  p_content = parseContent(content_name);
-  p_attach = xbt_strdup(attach);
+  content_ = parseContent(content_name);
+  attach_ = xbt_strdup(attach);
   turnOn();
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
   turnOn();
   XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
-  p_constraintRead  = lmm_constraint_new(maxminSystem, this, bread);
-  p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
+  constraintRead_  = lmm_constraint_new(maxminSystem, this, bread);
+  constraintWrite_ = lmm_constraint_new(maxminSystem, this, bwrite);
 }
 
 Storage::~Storage(){
   storageDestructedCallbacks(this);
 }
 
 Storage::~Storage(){
   storageDestructedCallbacks(this);
-  xbt_dict_free(&p_content);
-  free(p_typeId);
-  free(p_contentType);
-  free(p_attach);
+  xbt_dict_free(&content_);
+  free(typeId_);
+  free(contentType_);
+  free(attach_);
 }
 
 xbt_dict_t Storage::parseContent(const char *filename)
 {
 }
 
 xbt_dict_t Storage::parseContent(const char *filename)
 {
-  m_usedSize = 0;
+  usedSize_ = 0;
   if ((!filename) || (strcmp(filename, "") == 0))
     return nullptr;
 
   if ((!filename) || (strcmp(filename, "") == 0))
     return nullptr;
 
@@ -110,7 +110,7 @@ xbt_dict_t Storage::parseContent(const char *filename)
     if (read){
       xbt_assert(sscanf(line,"%s %llu", path, &size) == 2, "Parse error in %s: %s",filename,line);
 
     if (read){
       xbt_assert(sscanf(line,"%s %llu", path, &size) == 2, "Parse error in %s: %s",filename,line);
 
-      m_usedSize += size;
+      usedSize_ += size;
       sg_size_t *psize = xbt_new(sg_size_t, 1);
       *psize = size;
       xbt_dict_set(parse_content,path,psize,nullptr);
       sg_size_t *psize = xbt_new(sg_size_t, 1);
       *psize = size;
       xbt_dict_set(parse_content,path,psize,nullptr);
@@ -154,22 +154,22 @@ xbt_dict_t Storage::getContent()
   char *file;
   sg_size_t *psize;
 
   char *file;
   sg_size_t *psize;
 
-  xbt_dict_foreach(p_content, cursor, file, psize){
+  xbt_dict_foreach(content_, cursor, file, psize){
     xbt_dict_set(content_dict,file,psize,nullptr);
   }
   return content_dict;
 }
 
 sg_size_t Storage::getSize(){
     xbt_dict_set(content_dict,file,psize,nullptr);
   }
   return content_dict;
 }
 
 sg_size_t Storage::getSize(){
-  return m_size;
+  return size_;
 }
 
 sg_size_t Storage::getFreeSize(){
 }
 
 sg_size_t Storage::getFreeSize(){
-  return m_size - m_usedSize;
+  return size_ - usedSize_;
 }
 
 sg_size_t Storage::getUsedSize(){
 }
 
 sg_size_t Storage::getUsedSize(){
-  return m_usedSize;
+  return usedSize_;
 }
 
 /**********
 }
 
 /**********
index e8879f9..0fcfd2b 100644 (file)
@@ -114,15 +114,6 @@ public:
    * @param model StorageModel associated to this Storage
    * @param name The name of the Storage
    * @param props Dictionary of properties associated to this Storage
    * @param model StorageModel associated to this Storage
    * @param name The name of the Storage
    * @param props Dictionary of properties associated to this Storage
-   * @param maxminSystem [description]
-   * @param bread [description]
-   * @param bwrite [description]
-   * @param bconnection [description]
-   * @param type_id [description]
-   * @param content_name [description]
-   * @param content_type [description]
-   * @param size [description]
-   * @param attach [description]
    */
   Storage(Model *model, const char *name, xbt_dict_t props,
           lmm_system_t maxminSystem, double bread, double bwrite,
    */
   Storage(Model *model, const char *name, xbt_dict_t props,
           lmm_system_t maxminSystem, double bread, double bwrite,
@@ -140,12 +131,12 @@ public:
   void turnOn() override;
   void turnOff() override;
 
   void turnOn() override;
   void turnOff() override;
 
-  xbt_dict_t p_content;
-  char* p_contentType;
-  sg_size_t m_size;
-  sg_size_t m_usedSize;
-  char * p_typeId;
-  char* p_attach; //FIXME: this is the name of the host. Use the host directly
+  xbt_dict_t content_;
+  char* contentType_;
+  sg_size_t size_;
+  sg_size_t usedSize_;
+  char * typeId_;
+  char* attach_; //FIXME: this is the name of the host. Use the host directly
 
   /**
    * @brief Open a file
 
   /**
    * @brief Open a file
@@ -214,10 +205,10 @@ public:
 
   xbt_dict_t parseContent(const char *filename);
 
 
   xbt_dict_t parseContent(const char *filename);
 
-  std::vector<StorageAction*> p_writeActions;
+  std::vector<StorageAction*> writeActions_;
 
 
-  lmm_constraint_t p_constraintWrite;    /* Constraint for maximum write bandwidth*/
-  lmm_constraint_t p_constraintRead;     /* Constraint for maximum write bandwidth*/
+  lmm_constraint_t constraintWrite_;    /* Constraint for maximum write bandwidth*/
+  lmm_constraint_t constraintRead_;     /* Constraint for maximum write bandwidth*/
 };
 
 /**********
 };
 
 /**********
index 16a3904..e23abc2 100644 (file)
@@ -121,11 +121,11 @@ double StorageN11Model::next_occuring_event(double /*now*/)
   for(auto storage: p_storageList) {
     rate = 0;
     // Foreach write action on disk
   for(auto storage: p_storageList) {
     rate = 0;
     // Foreach write action on disk
-    for (auto write_action: storage->p_writeActions) {
+    for (auto write_action: storage->writeActions_) {
       rate += lmm_variable_getvalue(write_action->getVariable());
     }
     if(rate > 0)
       rate += lmm_variable_getvalue(write_action->getVariable());
     }
     if(rate > 0)
-      min_completion = MIN(min_completion, (storage->m_size-storage->m_usedSize)/rate);
+      min_completion = MIN(min_completion, (storage->size_-storage->usedSize_)/rate);
   }
 
   return min_completion;
   }
 
   return min_completion;
@@ -161,14 +161,14 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
 
       action->progress +=current_progress;
 
 
       action->progress +=current_progress;
 
-      action->p_storage->m_usedSize += incr; // disk usage
+      action->p_storage->usedSize_ += incr; // disk usage
       action->p_file->current_position+= incr; // current_position
       //  which becomes the new file size
       action->p_file->size = action->p_file->current_position ;
 
       sg_size_t *psize = xbt_new(sg_size_t,1);
       *psize = action->p_file->size;
       action->p_file->current_position+= incr; // current_position
       //  which becomes the new file size
       action->p_file->size = action->p_file->current_position ;
 
       sg_size_t *psize = xbt_new(sg_size_t,1);
       *psize = action->p_file->size;
-      xbt_dict_t content_dict = action->p_storage->p_content;
+      xbt_dict_t content_dict = action->p_storage->content_;
       xbt_dict_set(content_dict, action->p_file->name, psize, nullptr);
     }
 
       xbt_dict_set(content_dict, action->p_file->name, psize, nullptr);
     }
 
@@ -178,7 +178,7 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta)
       action->updateMaxDuration(delta);
 
     if(action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 &&
       action->updateMaxDuration(delta);
 
     if(action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 &&
-        action->p_storage->m_usedSize == action->p_storage->m_size) {
+        action->p_storage->usedSize_ == action->p_storage->size_) {
       action->finish();
       action->setState(Action::State::failed);
     } else if ((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) {
       action->finish();
       action->setState(Action::State::failed);
     } else if ((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) {
@@ -210,7 +210,7 @@ StorageAction *StorageN11::open(const char* mount, const char* path)
   XBT_DEBUG("\tOpen file '%s'",path);
 
   sg_size_t size, *psize;
   XBT_DEBUG("\tOpen file '%s'",path);
 
   sg_size_t size, *psize;
-  psize = (sg_size_t*) xbt_dict_get_or_null(p_content, path);
+  psize = (sg_size_t*) xbt_dict_get_or_null(content_, path);
   // if file does not exist create an empty file
   if(psize)
     size = *psize;
   // if file does not exist create an empty file
   if(psize)
     size = *psize;
@@ -218,7 +218,7 @@ StorageAction *StorageN11::open(const char* mount, const char* path)
     psize = xbt_new(sg_size_t,1);
     size = 0;
     *psize = size;
     psize = xbt_new(sg_size_t,1);
     size = 0;
     *psize = size;
-    xbt_dict_set(p_content, path, psize, nullptr);
+    xbt_dict_set(content_, path, psize, nullptr);
     XBT_DEBUG("File '%s' was not found, file created.",path);
   }
   surf_file_t file = xbt_new0(s_surf_file_t,1);
     XBT_DEBUG("File '%s' was not found, file created.",path);
   }
   surf_file_t file = xbt_new0(s_surf_file_t,1);
@@ -237,11 +237,11 @@ StorageAction *StorageN11::close(surf_file_t fd)
 {
   XBT_DEBUG("\tClose file '%s' size '%llu'", fd->name, fd->size);
   // unref write actions from storage
 {
   XBT_DEBUG("\tClose file '%s' size '%llu'", fd->name, fd->size);
   // unref write actions from storage
-  for (std::vector<StorageAction*>::iterator it = p_writeActions.begin(); it != p_writeActions.end();) {
+  for (std::vector<StorageAction*>::iterator it = writeActions_.begin(); it != writeActions_.end();) {
     StorageAction *write_action = *it;
     if ((write_action->p_file) == fd) {
       write_action->unref();
     StorageAction *write_action = *it;
     if ((write_action->p_file) == fd) {
       write_action->unref();
-      it = p_writeActions.erase(it);
+      it = writeActions_.erase(it);
     } else {
       ++it;
     }
     } else {
       ++it;
     }
@@ -278,9 +278,9 @@ StorageAction *StorageN11::write(surf_file_t fd, sg_size_t size)
   StorageAction *action = new StorageN11Action(getModel(), size, isOff(), this, WRITE);
   action->p_file = fd;
   /* Substract the part of the file that might disappear from the used sized on the storage element */
   StorageAction *action = new StorageN11Action(getModel(), size, isOff(), this, WRITE);
   action->p_file = fd;
   /* Substract the part of the file that might disappear from the used sized on the storage element */
-  m_usedSize -= (fd->size - fd->current_position);
+  usedSize_ -= (fd->size - fd->current_position);
   // If the storage is full before even starting to write
   // If the storage is full before even starting to write
-  if(m_usedSize==m_size) {
+  if(usedSize_==size_) {
     action->setState(Action::State::failed);
   }
   return action;
     action->setState(Action::State::failed);
   }
   return action;
@@ -304,10 +304,10 @@ StorageN11Action::StorageN11Action(Model *model, double cost, bool failed, Stora
   case STAT:
     break;
   case READ:
   case STAT:
     break;
   case READ:
-    lmm_expand(model->getMaxminSystem(), storage->p_constraintRead, getVariable(), 1.0);
+    lmm_expand(model->getMaxminSystem(), storage->constraintRead_, getVariable(), 1.0);
     break;
   case WRITE:
     break;
   case WRITE:
-    lmm_expand(model->getMaxminSystem(), storage->p_constraintWrite, getVariable(), 1.0);
+    lmm_expand(model->getMaxminSystem(), storage->constraintWrite_, getVariable(), 1.0);
 
     //TODO there is something annoying with what's below. Have to sort it out...
     //    Action *action = this;
 
     //TODO there is something annoying with what's below. Have to sort it out...
     //    Action *action = this;
index 561dc5f..74ade32 100644 (file)
@@ -283,7 +283,7 @@ xbt_dict_t surf_storage_get_properties(surf_resource_t resource){
 }
 
 const char* surf_storage_get_host(surf_resource_t resource){
 }
 
 const char* surf_storage_get_host(surf_resource_t resource){
-  return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->p_attach;
+  return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->attach_;
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
 }
 
 void surf_cpu_action_set_bound(surf_action_t action, double bound) {
index 43f6744..e12af64 100644 (file)
@@ -149,9 +149,9 @@ static void check_disk_attachment()
   xbt_lib_foreach(storage_lib, cursor, key, data) {
     if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) {
     simgrid::surf::Storage *storage = static_cast<simgrid::surf::Storage*>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
   xbt_lib_foreach(storage_lib, cursor, key, data) {
     if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != nullptr) {
     simgrid::surf::Storage *storage = static_cast<simgrid::surf::Storage*>(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL));
-    host_elm = sg_netcard_by_name_or_null(storage->p_attach);
+    host_elm = sg_netcard_by_name_or_null(storage->attach_);
     if(!host_elm)
     if(!host_elm)
-      surf_parse_error("Unable to attach storage %s: host %s doesn't exist.", storage->getName(), storage->p_attach);
+      surf_parse_error("Unable to attach storage %s: host %s doesn't exist.", storage->getName(), storage->attach_);
     }
   }
 }
     }
   }
 }