Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MSG_storage_get_content function
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Tue, 24 Sep 2013 08:44:46 +0000 (10:44 +0200)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Tue, 24 Sep 2013 08:44:46 +0000 (10:44 +0200)
include/msg/msg.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_io.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/surf/storage.c

index 55685ad..ddc962c 100644 (file)
@@ -101,6 +101,7 @@ XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
 XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar(void);
 XBT_PUBLIC(msg_error_t) MSG_storage_set_data(msg_storage_t host, void *data);
 XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage);
+XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage);
 /************************** AS Router handling ************************************/
 XBT_PUBLIC(const char *) MSG_as_router_get_property_value(const char* asr, const char *name);
 XBT_PUBLIC(xbt_dict_t) MSG_as_router_get_properties(const char* asr);
index fdd78b7..1c095a8 100644 (file)
@@ -497,6 +497,7 @@ XBT_PUBLIC(size_t) simcall_storage_get_used_size (const char* name);
 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
 XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
 XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
+XBT_PUBLIC(xbt_dict_t) SIMIX_storage_get_content(smx_storage_t storage);
 
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
index e93f43f..5bce782 100644 (file)
@@ -237,7 +237,8 @@ typedef struct surf_storage_model_extension_public {
   surf_action_t(*write) (void *storage, size_t size, surf_file_t fd);
   surf_action_t(*stat) (void *storage, surf_file_t fd);
   surf_action_t(*ls) (void *storage, const char *path);
-  xbt_dict_t(*get_properties) (const void *resource);
+  xbt_dict_t(*get_properties) (const void *storage);
+  xbt_dict_t(*get_content) (void *storage);
 } s_surf_model_extension_storage_t;
 
      /** \ingroup SURF_models
@@ -359,8 +360,8 @@ static inline void *surf_cpu_resource_priv(const void *host) {
 static inline void *surf_workstation_resource_priv(const void *host){
   return xbt_lib_get_level((void *)host, SURF_WKS_LEVEL);
 }
-static inline void *surf_storage_resource_priv(const void *host){
-  return xbt_lib_get_level((void *)host, SURF_STORAGE_LEVEL);
+static inline void *surf_storage_resource_priv(const void *storage){
+  return xbt_lib_get_level((void *)storage, SURF_STORAGE_LEVEL);
 }
 
 static inline void *surf_cpu_resource_by_name(const char *name) {
index d69d762..4cde27c 100644 (file)
@@ -290,7 +290,7 @@ msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data)
  *
  * \brief Returns the user data of a #msg_storage_t.
  *
- * This functions checks whether \a storage is a valid pointer or not and return
+ * This functions checks whether \a storage is a valid pointer or not and returns
    the user data associated to \a storage if it is possible.
  */
 void *MSG_storage_get_data(msg_storage_t storage)
@@ -298,3 +298,12 @@ void *MSG_storage_get_data(msg_storage_t storage)
   return SIMIX_storage_get_data(storage);
 }
 
+/** \ingroup msg_storage_management
+ *
+ * \brief Returns the content (file list) of a #msg_storage_t.
+ * \param storage a storage
+ */
+xbt_dict_t MSG_storage_get_content(msg_storage_t storage){
+
+       return SIMIX_storage_get_content(storage);
+}
index daa80e5..1c16b3b 100644 (file)
@@ -338,12 +338,22 @@ void SIMIX_storage_set_data(smx_storage_t storage, void *data){
 void* SIMIX_pre_storage_get_data(smx_simcall_t simcall,smx_storage_t storage){
   return SIMIX_storage_get_data(storage);
 }
+
 void* SIMIX_storage_get_data(smx_storage_t storage){
   xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
 
   return SIMIX_storage_priv(storage)->data;
 }
 
+xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t storage){
+  return SIMIX_storage_get_content(storage);
+}
+
+xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage){
+  xbt_assert((storage != NULL), "Invalid parameters (simix storage is NULL)");
+  return surf_storage_model->extension.storage.get_content(storage);
+}
+
 void SIMIX_post_io(smx_action_t action)
 {
   xbt_fifo_item_t i;
index f2496b9..7914bc8 100644 (file)
@@ -55,6 +55,9 @@ xbt_dict_t SIMIX_pre_storage_get_properties(smx_simcall_t, smx_storage_t);
 void SIMIX_pre_storage_set_data(smx_simcall_t, smx_storage_t, void*);
 void* SIMIX_pre_storage_get_data(smx_simcall_t, smx_storage_t);
 
+xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t storage);
+xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage);
+
 void SIMIX_post_io(smx_action_t action);
 void SIMIX_io_destroy(smx_action_t action);
 void SIMIX_io_finish(smx_action_t action);
index e00a721..2efa0b6 100644 (file)
@@ -197,6 +197,22 @@ static xbt_dict_t storage_get_properties(const void *storage)
   return surf_resource_properties(surf_storage_resource_priv(storage));
 }
 
+static xbt_dict_t storage_get_content(void *storage)
+{
+  /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
+  /* surf_action_t action = storage_action_execute(storage,0, LS); */
+  xbt_dict_t content_dict = xbt_dict_new();
+
+  xbt_dict_cursor_t cursor = NULL;
+  char *file;
+  size_t size;
+
+  xbt_dict_foreach(((storage_t)storage)->content,cursor,file,size)
+    xbt_dict_set(content_dict,file,&size,NULL);
+
+  return content_dict;
+}
+
 static void* storage_create_resource(const char* id, const char* model,
     const char* type_id, const char* content_name, const char* content_type, xbt_dict_t properties){
   storage_t storage = NULL;
@@ -503,8 +519,8 @@ static void surf_storage_model_init_internal(void)
   surf_storage_model->extension.storage.read = storage_action_read;
   surf_storage_model->extension.storage.write = storage_action_write;
   surf_storage_model->extension.storage.ls = storage_action_ls;
-
   surf_storage_model->extension.storage.get_properties = storage_get_properties;
+  surf_storage_model->extension.storage.get_content = storage_get_content;
 
   if (!storage_maxmin_system) {
     storage_maxmin_system = lmm_system_new(storage_selective_update);