X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5b3677b425b9cc6949c1573d59ac772540cbf4b2..11e9d5c661bff9c0a31a60760520a6cd9172907c:/teshsuite/msg/storage/storage_basic.c diff --git a/teshsuite/msg/storage/storage_basic.c b/teshsuite/msg/storage/storage_basic.c index ae427ad1e9..38e07ee6a1 100644 --- a/teshsuite/msg/storage/storage_basic.c +++ b/teshsuite/msg/storage/storage_basic.c @@ -12,9 +12,8 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); void storage_info(msg_host_t host); void display_storage_properties(msg_storage_t storage); int hsm_put(const char *remote_host, const char *src, const char *dest); -sg_size_t write_local_file(char *dest, sg_size_t file_size); +sg_size_t write_local_file(const char *dest, sg_size_t file_size); sg_size_t read_local_file(const char *src); -void display_storage_info(msg_host_t host); void dump_storage_by_name(char *name); void display_storage_content(msg_storage_t storage); void get_set_storage_data(const char *storage_name); @@ -24,27 +23,28 @@ int server(int argc, char *argv[]); void storage_info(msg_host_t host) { const char* host_name = MSG_host_get_name(host); - XBT_INFO("*** Storage info on %s ***:", host_name); + XBT_INFO("*** Storage info on %s ***", host_name); xbt_dict_cursor_t cursor = NULL; char* mount_name; char* storage_name; msg_storage_t storage; - xbt_dict_t storage_list = MSG_host_get_storage_list(MSG_host_self()); + xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self()); xbt_dict_foreach(storage_list,cursor,mount_name,storage_name) { - XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name); + XBT_INFO("\tStorage name: %s, mount name: %s", storage_name, mount_name); sg_size_t free_size = MSG_storage_get_free_size(mount_name); sg_size_t used_size = MSG_storage_get_used_size(mount_name); - XBT_INFO("Free size: %llu bytes", free_size); - XBT_INFO("Used size: %llu bytes", used_size); + XBT_INFO("\t\tFree size: %llu bytes", free_size); + XBT_INFO("\t\tUsed size: %llu bytes", used_size); storage = MSG_storage_get_by_name(storage_name); display_storage_properties(storage); + dump_storage_by_name(storage_name); } xbt_dict_free(&storage_list); } @@ -53,12 +53,12 @@ void display_storage_properties(msg_storage_t storage){ xbt_dict_cursor_t cursor = NULL; char *key, *data; xbt_dict_t props = MSG_storage_get_properties(storage); - if (props){ - XBT_INFO("Properties of mounted storage: %s", MSG_storage_get_name(storage)); + if (xbt_dict_length(props) > 0){ + XBT_INFO("\tProperties of mounted storage: %s", MSG_storage_get_name(storage)); xbt_dict_foreach(props, cursor, key, data) - XBT_INFO("'%s' -> '%s'", key, data); + XBT_INFO("\t\t'%s' -> '%s'", key, data); }else{ - XBT_INFO("No property attached."); + XBT_INFO("\tNo property attached."); } } @@ -72,23 +72,24 @@ int hsm_put(const char *remote_host, const char *src, const char *dest){ XBT_INFO("%s sends %llu to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host); msg_task_t to_execute = MSG_task_create((const char*)"hsm_put", 0, (double) read_size, (void*)dest); MSG_task_send(to_execute, remote_host); - + MSG_process_sleep(.4); return 1; } -sg_size_t write_local_file(char *dest, sg_size_t file_size) +sg_size_t write_local_file(const char *dest, sg_size_t file_size) { - sg_size_t write; - msg_file_t file = MSG_file_open("/sd1",dest, NULL); - write = MSG_file_write(file, file_size); + sg_size_t written; + msg_file_t file = MSG_file_open(dest, NULL); + written = MSG_file_write(file, file_size); + XBT_INFO("%llu bytes on %llu bytes have been written by %s on /sd1",written, file_size, MSG_host_get_name(MSG_host_self())); MSG_file_close(file); - return write; + return written; } sg_size_t read_local_file(const char *src) { sg_size_t read, file_size; - msg_file_t file = MSG_file_open("/sd1",src, NULL); + msg_file_t file = MSG_file_open(src, NULL); file_size = MSG_file_get_size(file); read = MSG_file_read(file, file_size); @@ -98,24 +99,6 @@ sg_size_t read_local_file(const char *src) return read; } -void display_storage_info(msg_host_t host) -{ - const char* host_name = MSG_host_get_name(host); - XBT_INFO("*** Storage info of: %s ***", host_name); - - xbt_dict_cursor_t cursor = NULL; - char* mount_name; - char* storage_name; - - xbt_dict_t storage_list = MSG_host_get_storage_list(host); - - xbt_dict_foreach(storage_list,cursor,mount_name,storage_name) - { - dump_storage_by_name(storage_name); - } - xbt_dict_free(&storage_list); -} - void dump_storage_by_name(char *name){ XBT_INFO("*** Dump a storage element ***"); msg_storage_t storage = MSG_storage_get_by_name(name); @@ -136,9 +119,9 @@ void display_storage_content(msg_storage_t storage){ xbt_dict_t content = MSG_storage_get_content(storage); if (content){ xbt_dict_foreach(content, cursor, file, psize) - XBT_INFO("%s size: %llu bytes", file, *psize); + XBT_INFO("\t%s size: %llu bytes", file, *psize); } else { - XBT_INFO("No content."); + XBT_INFO("\tNo content."); } xbt_dict_free(&content); } @@ -149,22 +132,22 @@ void get_set_storage_data(const char *storage_name){ char *data = MSG_storage_get_data(storage); XBT_INFO("Get data: '%s'", data); - MSG_storage_set_data(storage,strdup("Some data")); + MSG_storage_set_data(storage, xbt_strdup("Some data")); data = MSG_storage_get_data(storage); - XBT_INFO("Set and get data: '%s'", data); + XBT_INFO("\tSet and get data: '%s'", data); + xbt_free(data); } int client(int argc, char *argv[]) { - hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx","./scratch/toto.xml"); - hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml","./scratch/titi.cxx"); - hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/Slave.cxx","./scratch/tata.cxx"); + hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx","/sd2/scratch/toto.cxx"); + hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml","/sd2/scratch/titi.xml"); + hsm_put("server","/sd1/doc/simgrid/examples/cxx/autoDestination/Slave.cxx","/sd2/scratch/tata.cxx"); msg_task_t finalize = MSG_task_create("finalize", 0, 0, NULL); MSG_task_send(finalize, "server"); get_set_storage_data("cdisk"); - display_storage_info(MSG_host_self()); return 1; } @@ -174,9 +157,9 @@ int server(int argc, char *argv[]) msg_task_t to_execute = NULL; _XBT_GNUC_UNUSED int res; - display_storage_info(MSG_host_self()); + storage_info(MSG_host_self()); - XBT_INFO("Server waiting for transfers"); + XBT_INFO("Server waiting for transfers ..."); while(1){ res = MSG_task_receive(&(to_execute), MSG_host_get_name(MSG_host_self())); xbt_assert(res == MSG_OK, "MSG_task_get failed"); @@ -199,7 +182,7 @@ int server(int argc, char *argv[]) to_execute = NULL; } - display_storage_info(MSG_host_self()); + storage_info(MSG_host_self()); return 1; }