X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5f2a4ce9af1e71cd806e254c7b8c677c1ca7720b..f4ed74ca6d4a744d2956a4f2906c897e1886cefd:/teshsuite/msg/storage/storage_basic.c diff --git a/teshsuite/msg/storage/storage_basic.c b/teshsuite/msg/storage/storage_basic.c index c386966d46..8252c9e838 100644 --- a/teshsuite/msg/storage/storage_basic.c +++ b/teshsuite/msg/storage/storage_basic.c @@ -4,7 +4,7 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "msg/msg.h" +#include "simgrid/msg.h" #include "xbt/log.h" XBT_LOG_NEW_DEFAULT_CATEGORY(storage,"Messages specific for this simulation"); @@ -12,11 +12,12 @@ 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 dump_storage_by_name(char *name); void display_storage_content(msg_storage_t storage); void get_set_storage_data(const char *storage_name); +void dump_platform_storages(void); int client(int argc, char *argv[]); int server(int argc, char *argv[]); @@ -30,19 +31,20 @@ void storage_info(msg_host_t host) 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("\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); + storage = MSG_storage_get_by_name(storage_name); + + sg_size_t free_size = MSG_storage_get_free_size(storage); + sg_size_t used_size = MSG_storage_get_used_size(storage); 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); } @@ -76,10 +78,10 @@ int hsm_put(const char *remote_host, const char *src, const char *dest){ 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 written; - msg_file_t file = MSG_file_open("/sd1",dest, NULL); + 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); @@ -89,7 +91,7 @@ sg_size_t write_local_file(char *dest, sg_size_t file_size) 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); @@ -132,21 +134,33 @@ 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("\tSet and get data: '%s'", data); + xbt_free(data); +} + +void dump_platform_storages(void){ + unsigned int cursor; + xbt_dynar_t storages = MSG_storages_as_dynar(); + msg_storage_t storage; + xbt_dynar_foreach(storages, cursor, storage){ + XBT_INFO("Storage %s is attached to %s", MSG_storage_get_name(storage), MSG_storage_get_host(storage)); + MSG_storage_set_property_value(storage, "other usage", xbt_strdup("gpfs"), xbt_free_f); + } + xbt_dynar_free(&storages); } int client(int argc, char *argv[]) { - hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/FinalizeTask.cxx","./scratch/toto.cxx"); - hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/autoDestination_deployment.xml","./scratch/titi.xml"); - hsm_put("server","./doc/simgrid/examples/cxx/autoDestination/Slave.cxx","./scratch/tata.cxx"); + hsm_put("alice","/home/doc/simgrid/examples/msg/icomms/small_platform.xml","c:\\Windows\\toto.cxx"); + hsm_put("alice","/home/doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml","c:\\Windows\\titi.xml"); + hsm_put("alice","/home/doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c","c:\\Windows\\tata.c"); msg_task_t finalize = MSG_task_create("finalize", 0, 0, NULL); - MSG_task_send(finalize, "server"); + MSG_task_send(finalize, "alice"); - get_set_storage_data("cdisk"); + get_set_storage_data("Disk1"); return 1; } @@ -173,15 +187,16 @@ int server(int argc, char *argv[]) else if(!strcmp(task_name,"hsm_put")){// Receive file to save // Write file on local disk char *dest = MSG_task_get_data(to_execute); - sg_size_t size_to_write = (sg_size_t)MSG_task_get_data_size(to_execute); + sg_size_t size_to_write = (sg_size_t)MSG_task_get_bytes_amount(to_execute); write_local_file(dest, size_to_write); - } + } MSG_task_destroy(to_execute); to_execute = NULL; } storage_info(MSG_host_self()); + dump_platform_storages(); return 1; }