From c96b8ddfe1c923257f43ee40334ceb820226694c Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 19 Aug 2016 15:12:34 +0200 Subject: [PATCH] rename the Storage fields to follow our naming conventions --- src/surf/HostImpl.cpp | 18 ++++++------- src/surf/storage_interface.cpp | 46 +++++++++++++++++----------------- src/surf/storage_interface.hpp | 27 +++++++------------- src/surf/storage_n11.cpp | 26 +++++++++---------- src/surf/surf_c_bindings.cpp | 2 +- src/surf/surf_routing.cpp | 4 +-- 6 files changed, 57 insertions(+), 66 deletions(-) diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index eef87951b8..66c97a69b6 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -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(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()); } } @@ -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 */ - 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()); - st->m_usedSize -= fd->size; + st->usedSize_ -= fd->size; // 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); @@ -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, 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; } @@ -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*) - 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 - 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); - 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); diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index 452b993c89..3edbbb78d6 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -53,12 +53,12 @@ Storage::Storage(Model *model, const char *name, xbt_dict_t 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()) + , contentType_(xbt_strdup(content_type)) + , size_(size), usedSize_(0) + , typeId_(xbt_strdup(type_id)) + , writeActions_(std::vector()) { - p_content = parseContent(content_name); + content_ = parseContent(content_name); 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) - , p_contentType(xbt_strdup(content_type)) - , m_size(size), m_usedSize(0) - , p_typeId(xbt_strdup(type_id)) - , p_writeActions(std::vector()) + , contentType_(xbt_strdup(content_type)) + , size_(size), usedSize_(0) + , typeId_(xbt_strdup(type_id)) + , writeActions_(std::vector()) { - 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); - 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); - 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) { - m_usedSize = 0; + usedSize_ = 0; 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); - 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); @@ -154,22 +154,22 @@ xbt_dict_t Storage::getContent() 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(){ - return m_size; + return size_; } sg_size_t Storage::getFreeSize(){ - return m_size - m_usedSize; + return size_ - usedSize_; } sg_size_t Storage::getUsedSize(){ - return m_usedSize; + return usedSize_; } /********** diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index e8879f9b09..0fcfd2b59f 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -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 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, @@ -140,12 +131,12 @@ public: 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 @@ -214,10 +205,10 @@ public: xbt_dict_t parseContent(const char *filename); - std::vector p_writeActions; + std::vector 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*/ }; /********** diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 16a3904a40..e23abc2c8a 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -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 write_action: storage->p_writeActions) { + for (auto write_action: storage->writeActions_) { 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; @@ -161,14 +161,14 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta) 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; - 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); } @@ -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->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)) { @@ -210,7 +210,7 @@ StorageAction *StorageN11::open(const char* mount, const char* path) 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; @@ -218,7 +218,7 @@ StorageAction *StorageN11::open(const char* mount, const char* path) 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); @@ -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 - for (std::vector::iterator it = p_writeActions.begin(); it != p_writeActions.end();) { + for (std::vector::iterator it = writeActions_.begin(); it != writeActions_.end();) { StorageAction *write_action = *it; if ((write_action->p_file) == fd) { write_action->unref(); - it = p_writeActions.erase(it); + it = writeActions_.erase(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 */ - m_usedSize -= (fd->size - fd->current_position); + usedSize_ -= (fd->size - fd->current_position); // 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; @@ -304,10 +304,10 @@ StorageN11Action::StorageN11Action(Model *model, double cost, bool failed, Stora 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: - 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; diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 561dc5f2ac..74ade32d2f 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -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){ - return static_cast(surf_storage_resource_priv(resource))->p_attach; + return static_cast(surf_storage_resource_priv(resource))->attach_; } void surf_cpu_action_set_bound(surf_action_t action, double bound) { diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 43f6744801..e12af64f42 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -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(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) - 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_); } } } -- 2.20.1