Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add SD_storage_get_host() and MSG_storage_get_host()
authorPierre Veyre <pierre.veyre@cc.in2p3.fr>
Mon, 10 Mar 2014 11:42:56 +0000 (12:42 +0100)
committerPierre Veyre <pierre.veyre@cc.in2p3.fr>
Mon, 10 Mar 2014 11:42:56 +0000 (12:42 +0100)
include/msg/datatypes.h
include/msg/msg.h
include/simdag/simdag.h
include/simgrid/simix.h
src/include/surf/surf.h
src/msg/msg_io.c
src/simdag/private.h
src/simdag/sd_workstation.c
src/simix/smx_io.c
src/simix/smx_io_private.h
src/surf/surf_c_bindings.cpp

index fc63fc4..7a4bd0f 100644 (file)
@@ -138,8 +138,7 @@ typedef xbt_dictelm_t msg_storage_t;
 typedef s_xbt_dictelm_t s_msg_storage_t;
 
 typedef struct msg_storage_priv  {
 typedef s_xbt_dictelm_t s_msg_storage_t;
 
 typedef struct msg_storage_priv  {
-  // TODO PV: fill it (or not) !
-  void * dummy;
+  const char *host;
 } s_msg_storage_priv_t, *msg_storage_priv_t;
 
 static inline msg_storage_priv_t MSG_storage_priv(msg_storage_t storage){
 } s_msg_storage_priv_t, *msg_storage_priv_t;
 
 static inline msg_storage_priv_t MSG_storage_priv(msg_storage_t storage){
index 1c19a5c..e3e5bee 100644 (file)
@@ -112,6 +112,7 @@ XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage);
 XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage);
 XBT_PUBLIC(msg_error_t) MSG_storage_file_move(msg_file_t fd, msg_host_t dest, char* mount, char* fullname);
 XBT_PUBLIC(msg_error_t) MSG_storage_file_rename(msg_storage_t storage, const char* src,  const char* dest);
 XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage);
 XBT_PUBLIC(msg_error_t) MSG_storage_file_move(msg_file_t fd, msg_host_t dest, char* mount, char* fullname);
 XBT_PUBLIC(msg_error_t) MSG_storage_file_rename(msg_storage_t storage, const char* src,  const char* dest);
+XBT_PUBLIC(const char *) MSG_storage_get_host(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);
 /************************** 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 7bccbbb..eee8f60 100644 (file)
@@ -109,6 +109,7 @@ XBT_PUBLIC(xbt_dict_t)
     SD_workstation_get_mounted_storage_list(SD_workstation_t workstation);
 XBT_PUBLIC(xbt_dynar_t)
     SD_workstation_get_attached_storage_list(SD_workstation_t workstation);
     SD_workstation_get_mounted_storage_list(SD_workstation_t workstation);
 XBT_PUBLIC(xbt_dynar_t)
     SD_workstation_get_attached_storage_list(SD_workstation_t workstation);
+XBT_PUBLIC(const char*) SD_storage_get_host(SD_storage_t storage);
 /** @} */
 
 /************************** Task handling ************************************/
 /** @} */
 
 /************************** Task handling ************************************/
index c63d21b..623f761 100644 (file)
@@ -506,6 +506,7 @@ XBT_PUBLIC(xbt_dict_t) simcall_storage_get_content(smx_storage_t storage);
 XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_storage_t storage);
 XBT_PUBLIC(sg_size_t) SIMIX_storage_get_size(smx_storage_t storage);
 XBT_PUBLIC(void) simcall_storage_file_rename(smx_storage_t storage, const char* src,  const char* dest);
 XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_storage_t storage);
 XBT_PUBLIC(sg_size_t) SIMIX_storage_get_size(smx_storage_t storage);
 XBT_PUBLIC(void) simcall_storage_file_rename(smx_storage_t storage, const char* src,  const char* dest);
+XBT_PUBLIC(const char*) SIMIX_storage_get_host(smx_storage_t storage);
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
 /************************** AS router simcalls ***************************/
 /************************** AS router   **********************************/
 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
 /************************** AS router simcalls ***************************/
index 1ec1f94..e83c9fa 100644 (file)
@@ -906,6 +906,15 @@ XBT_PUBLIC(surf_file_t) surf_storage_action_get_file(surf_action_t action);
  */
 XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action);
 
  */
 XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action);
 
+
+/**
+ * @brief Get the host the storage is attached to
+ *
+ * @param resource The surf storage
+ * @return The host name
+ */
+XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource);
+
 XBT_PUBLIC(surf_model_t) surf_resource_model(const void *host, int level);
 
 /** @} */
 XBT_PUBLIC(surf_model_t) surf_resource_model(const void *host, int level);
 
 /** @} */
index 26b45ed..c2b108e 100644 (file)
@@ -263,7 +263,9 @@ void __MSG_file_destroy(msg_file_priv_t file) {
 msg_storage_t __MSG_storage_create(smx_storage_t storage)
 {
   const char *name = SIMIX_storage_get_name(storage);
 msg_storage_t __MSG_storage_create(smx_storage_t storage)
 {
   const char *name = SIMIX_storage_get_name(storage);
+  const char *host = SIMIX_storage_get_host(storage);
   msg_storage_priv_t storage_private = xbt_new0(s_msg_storage_priv_t, 1);
   msg_storage_priv_t storage_private = xbt_new0(s_msg_storage_priv_t, 1);
+  storage_private->host = host;
   xbt_lib_set(storage_lib,name,MSG_STORAGE_LEVEL,storage_private);
   return xbt_lib_get_elm_or_null(storage_lib, name);
 }
   xbt_lib_set(storage_lib,name,MSG_STORAGE_LEVEL,storage_private);
   return xbt_lib_get_elm_or_null(storage_lib, name);
 }
@@ -423,3 +425,15 @@ msg_error_t MSG_storage_file_move (msg_file_t fd, msg_host_t dest, char* mount,
   THROW_UNIMPLEMENTED;
   return MSG_OK;
 }
   THROW_UNIMPLEMENTED;
   return MSG_OK;
 }
+
+/** \ingroup msg_storage_management
+ *
+ * \brief Returns the host name the storage is attached to
+ *
+ * This functions checks whether a storage is a valid pointer or not and return its name.
+ */
+const char *MSG_storage_get_host(msg_storage_t storage) {
+  xbt_assert((storage != NULL), "Invalid parameters");
+  msg_storage_priv_t priv = MSG_storage_priv(storage);
+  return priv->host;
+}
index 513dd1e..ada782b 100644 (file)
@@ -73,8 +73,12 @@ static inline SD_workstation_priv_t SD_workstation_priv(SD_workstation_t host){
 typedef s_xbt_dictelm_t s_SD_storage_t;
 typedef struct SD_storage {
   void *data;                   /* user data */
 typedef s_xbt_dictelm_t s_SD_storage_t;
 typedef struct SD_storage {
   void *data;                   /* user data */
+  const char *host;
 } s_SD_storage_priv_t, *SD_storage_priv_t;
 
 } s_SD_storage_priv_t, *SD_storage_priv_t;
 
+static inline SD_storage_priv_t SD_storage_priv(SD_storage_t storage){
+  return xbt_lib_get_level(storage, SD_STORAGE_LEVEL);
+}
 
 /* Task */
 typedef struct SD_task {
 
 /* Task */
 typedef struct SD_task {
index 4c7aa38..7474bba 100644 (file)
@@ -45,7 +45,7 @@ SD_storage_t __SD_storage_create(void *surf_storage, void *data)
 
   storage = xbt_new(s_SD_storage_priv_t, 1);
   storage->data = data;     /* user data */
 
   storage = xbt_new(s_SD_storage_priv_t, 1);
   storage->data = data;     /* user data */
-
+  storage->host = surf_storage_get_host(surf_storage);
   name = surf_resource_name(surf_storage);
   xbt_lib_set(storage_lib,name, SD_STORAGE_LEVEL, storage);
   return xbt_lib_get_elm_or_null(storage_lib, name);
   name = surf_resource_name(surf_storage);
   xbt_lib_set(storage_lib,name, SD_STORAGE_LEVEL, storage);
   return xbt_lib_get_elm_or_null(storage_lib, name);
@@ -490,6 +490,16 @@ xbt_dynar_t SD_workstation_get_attached_storage_list(SD_workstation_t workstatio
   return surf_workstation_get_attached_storage_list(workstation);
 }
 
   return surf_workstation_get_attached_storage_list(workstation);
 }
 
+/**
+ * \brief Returns the host name the storage is attached to
+ *
+ * This functions checks whether a storage is a valid pointer or not and return its name.
+ */
+const char *SD_storage_get_host(msg_storage_t storage) {
+  xbt_assert((storage != NULL), "Invalid parameters");
+  SD_storage_priv_t priv = SD_storage_priv(storage);
+  return priv->host;
+}
 
 /* Returns whether a task can start now on a workstation*/
 /*
 
 /* Returns whether a task can start now on a workstation*/
 /*
index 7e86d4b..6833b8a 100644 (file)
@@ -395,6 +395,15 @@ sg_size_t SIMIX_storage_get_size(smx_storage_t storage){
   return surf_storage_get_size(storage);
 }
 
   return surf_storage_get_size(storage);
 }
 
+const char* SIMIX_pre_storage_get_host(smx_simcall_t simcall, smx_storage_t storage){
+   return SIMIX_storage_get_host(storage);
+}
+
+const char* SIMIX_storage_get_host(smx_storage_t storage){
+  xbt_assert((storage != NULL), "Invalid parameters");
+  return surf_storage_get_host(storage);
+}
+
 void SIMIX_post_io(smx_action_t action)
 {
   xbt_fifo_item_t i;
 void SIMIX_post_io(smx_action_t action)
 {
   xbt_fifo_item_t i;
index 6bd066e..f3f1058 100644 (file)
@@ -70,7 +70,7 @@ xbt_dict_t SIMIX_pre_storage_get_content(smx_simcall_t simcall, smx_storage_t st
 xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage);
 
 const char* SIMIX_pre_storage_get_name(smx_simcall_t simcall, smx_storage_t storage);
 xbt_dict_t SIMIX_storage_get_content(smx_storage_t storage);
 
 const char* SIMIX_pre_storage_get_name(smx_simcall_t simcall, smx_storage_t storage);
-
+const char* SIMIX_pre_storage_get_host(smx_simcall_t simcall, 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);
 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 7f8d40f..9d364aa 100644 (file)
@@ -476,6 +476,10 @@ sg_size_t surf_storage_get_size(surf_resource_t resource){
   return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->getSize();
 }
 
   return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->getSize();
 }
 
+const char* surf_storage_get_host(surf_resource_t resource){
+  return static_cast<StoragePtr>(surf_storage_resource_priv(resource))->p_attach;
+}
+
 void surf_storage_rename(surf_resource_t resource, const char* src, const char* dest){
   static_cast<StoragePtr>(surf_storage_resource_priv(resource))->rename(src, dest);
 }
 void surf_storage_rename(surf_resource_t resource, const char* src, const char* dest){
   static_cast<StoragePtr>(surf_storage_resource_priv(resource))->rename(src, dest);
 }