Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics in Storage
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 23 Dec 2015 08:44:53 +0000 (09:44 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 23 Dec 2015 08:53:50 +0000 (09:53 +0100)
src/surf/sg_platf.cpp
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp

index 208484b..2006197 100644 (file)
@@ -140,13 +140,10 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
 void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
 {
   xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL),
 void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
 {
   xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL),
-               "Reading a storage, processing unit \"%s\" already exists", storage->id);
+               "Refusing to add a second storage named \"%s\"", storage->id);
 
 
-  // Verification of an existing type_id
-#ifndef NDEBUG
-  void* storage_type = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL);
-#endif
-  xbt_assert(storage_type,"Reading a storage, type id \"%s\" does not exists", storage->type_id);
+  void* stype = xbt_lib_get_or_null(storage_type_lib, storage->type_id,ROUTING_STORAGE_TYPE_LEVEL);
+  xbt_assert(stype,"No storage type '%s'", storage->type_id);
 
   XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'",
       storage->id,
 
   XBT_DEBUG("ROUTING Create a storage name '%s' with type_id '%s' and content '%s'",
       storage->id,
@@ -158,12 +155,7 @@ void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
       ROUTING_STORAGE_LEVEL,
       (void *) xbt_strdup(storage->type_id));
 
       ROUTING_STORAGE_LEVEL,
       (void *) xbt_strdup(storage->type_id));
 
-  void* stype = xbt_lib_get_or_null(storage_type_lib,
-                                    storage->type_id,
-                                    ROUTING_STORAGE_TYPE_LEVEL);
-  if(!stype) xbt_die("No storage type '%s'",storage->type_id);
-
-  // if storage content is not specified use the content of storage_type if exist
+  // if storage content is not specified use the content of storage_type if any
   if(!strcmp(storage->content,"") && strcmp(((storage_type_t) stype)->content,"")){
     storage->content = ((storage_type_t) stype)->content;
     storage->content_type = ((storage_type_t) stype)->content_type;
   if(!strcmp(storage->content,"") && strcmp(((storage_type_t) stype)->content,"")){
     storage->content = ((storage_type_t) stype)->content;
     storage->content_type = ((storage_type_t) stype)->content_type;
index d4479cf..4023e02 100644 (file)
@@ -56,11 +56,11 @@ StorageModel::~StorageModel(){
  ************/
 
 Storage::Storage(Model *model, const char *name, xbt_dict_t props,
  ************/
 
 Storage::Storage(Model *model, const char *name, xbt_dict_t props,
-                 const char* type_id, char *content_name, char *content_type,
+                 const char* type_id, const char *content_name, const char *content_type,
                  sg_size_t size)
  : Resource(model, name)
  , PropertyHolder(props)
                  sg_size_t size)
  : Resource(model, name)
  , PropertyHolder(props)
- , p_contentType(content_type)
+ , p_contentType(xbt_strdup(content_type))
  , m_size(size), m_usedSize(0)
  , p_typeId(xbt_strdup(type_id))
  , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL))
  , m_size(size), m_usedSize(0)
  , p_typeId(xbt_strdup(type_id))
  , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL))
@@ -71,18 +71,11 @@ Storage::Storage(Model *model, const char *name, xbt_dict_t props,
 
 Storage::Storage(Model *model, const char *name, xbt_dict_t props,
                  lmm_system_t maxminSystem, double bread, double bwrite,
 
 Storage::Storage(Model *model, const char *name, xbt_dict_t props,
                  lmm_system_t maxminSystem, double bread, double bwrite,
-                 double bconnection, const char* type_id, char *content_name,
-                 char *content_type, sg_size_t size, char *attach)
- : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
- , PropertyHolder(props)
- , p_contentType(content_type)
- , m_size(size), m_usedSize(0)
- , p_typeId(xbt_strdup(type_id))
- , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL))
+                 double bconnection, const char* type_id, const char *content_name,
+                 const char *content_type, sg_size_t size, const char *attach)
+ : Storage(model, name, props, type_id, content_name, content_type, size)
 {
 {
-  p_content = parseContent(content_name);
   p_attach = xbt_strdup(attach);
   p_attach = xbt_strdup(attach);
-  setState(SURF_RESOURCE_ON);
   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);
   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);
@@ -97,7 +90,7 @@ Storage::~Storage(){
   free(p_attach);
 }
 
   free(p_attach);
 }
 
-xbt_dict_t Storage::parseContent(char *filename)
+xbt_dict_t Storage::parseContent(const char *filename)
 {
   m_usedSize = 0;
   if ((!filename) || (strcmp(filename, "") == 0))
 {
   m_usedSize = 0;
   if ((!filename) || (strcmp(filename, "") == 0))
index a449ac9..631299e 100644 (file)
@@ -109,7 +109,7 @@ public:
    * @param size [description]
    */
   Storage(Model *model, const char *name, xbt_dict_t props,
    * @param size [description]
    */
   Storage(Model *model, const char *name, xbt_dict_t props,
-          const char* type_id, char *content_name, char *content_type,
+          const char* type_id, const char *content_name, const char *content_type,
           sg_size_t size);
 
   /**
           sg_size_t size);
 
   /**
@@ -131,8 +131,8 @@ public:
   Storage(Model *model, const char *name, xbt_dict_t props,
           lmm_system_t maxminSystem, double bread, double bwrite,
           double bconnection,
   Storage(Model *model, const char *name, xbt_dict_t props,
           lmm_system_t maxminSystem, double bread, double bwrite,
           double bconnection,
-          const char* type_id, char *content_name, char *content_type,
-          sg_size_t size, char *attach);
+          const char* type_id, const char *content_name, const char *content_type,
+          sg_size_t size, const char *attach);
 
   ~Storage();
 
 
   ~Storage();
 
@@ -155,7 +155,7 @@ public:
   sg_size_t m_size;
   sg_size_t m_usedSize;
   char * p_typeId;
   sg_size_t m_size;
   sg_size_t m_usedSize;
   char * p_typeId;
-  char* p_attach;
+  char* p_attach; //FIXME: this is the name of the host. Use the host directly
 
   /**
    * @brief Open a file
 
   /**
    * @brief Open a file
@@ -222,7 +222,7 @@ public:
   virtual sg_size_t getUsedSize();
 
 
   virtual sg_size_t getUsedSize();
 
 
-  xbt_dict_t parseContent(char *filename);
+  xbt_dict_t parseContent(const char *filename);
 
   xbt_dynar_t p_writeActions;
 
 
   xbt_dynar_t p_writeActions;