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());
}
}
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);
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;
}
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);
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();
}
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);
- 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;
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);
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_;
}
/**********
* @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,
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
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*/
};
/**********
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;
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);
}
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)) {
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;
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("\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();
- it = p_writeActions.erase(it);
+ it = writeActions_.erase(it);
} else {
++it;
}
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;
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;
}
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) {
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)
- 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_);
}
}
}