X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/662f44287e3fd62ebdf93b4c8173603dde9693b7..8d672f647c009c1b39898e589aeae653fe016b7d:/src/surf/surf_routing.cpp diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 455f3e8134..5c6e4509ba 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -12,9 +12,11 @@ #include "simgrid/platf_interface.h" // platform creation API internal interface #include "simgrid/sg_config.h" +#include "storage_interface.hpp" #include "surf/surfxml_parse_values.h" + /** * @ingroup SURF_build_api * @brief A library containing all known workstations @@ -138,7 +140,7 @@ static void parse_S_host_link(sg_platf_host_link_cbarg_t host) // If dynar is is greater than edge id and if the host_link is already defined if((int)xbt_dynar_length(current_routing->p_linkUpDownList) > info->getId() && xbt_dynar_get_as(current_routing->p_linkUpDownList, info->getId(), void*)) - xbt_die("Host_link for '%s' is already defined!",host->id); + surf_parse_error("Host_link for '%s' is already defined!",host->id); XBT_DEBUG("Push Host_link for host '%s' to position %d", info->getName(), info->getId()); xbt_dynar_set_as(current_routing->p_linkUpDownList, info->getId(), s_surf_parsing_link_up_down_t, link_up_down); @@ -320,7 +322,7 @@ static void routing_parse_trace_connect(sg_platf_trace_connect_cbarg_t trace_con xbt_strdup(trace_connect->element), NULL); break; default: - xbt_die("Cannot connect trace %s to %s: kind of trace unknown", + surf_parse_error("Cannot connect trace %s to %s: kind of trace unknown", trace_connect->trace, trace_connect->element); break; } @@ -399,7 +401,7 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS) /* add to the father element list */ info->setId(current_routing->parseAS(info)); } else { - THROWF(arg_error, 0, "All defined components must be belong to a AS"); + THROWF(arg_error, 0, "All defined components must belong to a AS"); } xbt_lib_set(as_router_lib, info->getName(), ROUTING_ASR_LEVEL, @@ -1239,6 +1241,22 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) // } // } +static void check_disk_attachment() +{ + xbt_lib_cursor_t cursor; + char *key; + void **data; + RoutingEdgePtr host_elm; + xbt_lib_foreach(storage_lib, cursor, key, data) { + if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) { + StoragePtr storage = static_cast(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL)); + host_elm = sg_routing_edge_by_name_or_null(storage->p_attach); + if(!host_elm) + surf_parse_error("Unable to attach storage %s: host %s doesn't exist.", storage->getName(), storage->p_attach); + } + } +} + void routing_register_callbacks() { sg_platf_host_add_cb(parse_S_host); @@ -1254,6 +1272,7 @@ void routing_register_callbacks() sg_platf_peer_add_cb(routing_parse_peer); sg_platf_postparse_add_cb(routing_parse_postparse); + sg_platf_postparse_add_cb(check_disk_attachment); /* we care about the ASes while parsing the platf. Incredible, isnt it? */ sg_platf_AS_end_add_cb(routing_AS_end); @@ -1306,6 +1325,32 @@ const char *surf_AS_get_name(AsPtr as) { return as->p_name; } +static AsPtr surf_AS_recursive_get_by_name(AsPtr current, const char * name) { + xbt_dict_cursor_t cursor = NULL; + char *key; + AS_t elem; + AsPtr tmp = NULL; + + if(!strcmp(current->p_name, name)) + return current; + + xbt_dict_foreach(current->p_routingSons, cursor, key, elem) { + tmp = surf_AS_recursive_get_by_name(elem, name); + if(tmp != NULL ) { + break; + } + } + return tmp; +} + + +AsPtr surf_AS_get_by_name(const char * name) { + AsPtr as = surf_AS_recursive_get_by_name(routing_platf->p_root, name); + if(as == NULL) + XBT_WARN("Impossible to find an AS with name %s, please check your input", name); + return as; +} + xbt_dict_t surf_AS_get_routing_sons(AsPtr as) { return as->p_routingSons; }