{"Vivaldi", "Vivaldi routing", model_rulebased_create,
model_rulebased_load, model_rulebased_unload, model_rulebased_end},
{"Cluster", "Cluster routing", model_cluster_create,
- model_cluster_load, model_cluster_unload, model_cluster_end},
+ model_rulebased_load, model_rulebased_unload, model_rulebased_end},
{NULL, NULL, NULL, NULL, NULL, NULL}
};
char *availability_file = xbt_strdup(A_surfxml_cluster_availability_file);
char *state_file = xbt_strdup(A_surfxml_cluster_state_file);
- if(xbt_dict_size(patterns)==0)
- patterns = xbt_dict_new();
+ if( !strcmp(A_surfxml_cluster_state_file,"") || !strcmp(A_surfxml_cluster_availability_file,"") ){
+ if(xbt_dict_size(patterns)==0)
+ patterns = xbt_dict_new();
- xbt_dict_set(patterns,"id",struct_cluster->V_cluster_id,NULL);
- xbt_dict_set(patterns,"prefix",struct_cluster->V_cluster_prefix,NULL);
- xbt_dict_set(patterns,"suffix",struct_cluster->V_cluster_suffix,NULL);
+ xbt_dict_set(patterns,"id",struct_cluster->V_cluster_id,NULL);
+ xbt_dict_set(patterns,"prefix",struct_cluster->V_cluster_prefix,NULL);
+ xbt_dict_set(patterns,"suffix",struct_cluster->V_cluster_suffix,NULL);
+ }
char *route_src_dst;
unsigned int iter;
surf_parse_get_int(&start, xbt_dynar_get_as(radical_ends, 0, char *));
host_id = bprintf("%s%d%s", struct_cluster->V_cluster_prefix, start, struct_cluster->V_cluster_suffix);
link_id = bprintf("%s_link_%d", struct_cluster->V_cluster_id, start);
- xbt_dict_set(patterns, "radical", bprintf("%d", start), xbt_free);
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, struct_cluster->S_cluster_power);
struct_host = xbt_new0(s_hostSG_t, 1);
struct_host->V_host_id = host_id;
if(!strcmp(A_surfxml_cluster_availability_file,"")){
+ xbt_dict_set(patterns, "radical", bprintf("%d", start), xbt_free);
char* tmp_availability_file = xbt_strdup(availability_file);
xbt_str_varsubst(tmp_availability_file,patterns);
XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file);
for (i = start; i <= end; i++) {
host_id = bprintf("%s%d%s", struct_cluster->V_cluster_prefix, i, struct_cluster->V_cluster_suffix);
link_id = bprintf("%s_link_%d", struct_cluster->V_cluster_id, i);
- xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
+
A_surfxml_host_state = A_surfxml_host_state_ON;
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, struct_cluster->S_cluster_power);
struct_host = xbt_new0(s_hostSG_t, 1);
struct_host->V_host_id = host_id;
if(!strcmp(A_surfxml_cluster_availability_file,"")){
+ xbt_dict_set(patterns, "radical", bprintf("%d", i), xbt_free);
char* tmp_availability_file = xbt_strdup(availability_file);
xbt_str_varsubst(tmp_availability_file,patterns);
XBT_DEBUG("\tavailability_file=\"%s\"",tmp_availability_file);
xbt_free(availability_file);
xbt_free(state_file);
- xbt_dict_free(&patterns);
+ if( !strcmp(A_surfxml_cluster_state_file,"") || !strcmp(A_surfxml_cluster_availability_file,"") )
+ xbt_dict_free(&patterns);
XBT_DEBUG("</AS>");
SURFXML_END_TAG(AS);
/* Parse routing model functions */
-static void model_cluster_set_processing_unit(routing_component_t rc,
- const char *name)
-{
- routing_component_cluster_t routing =
- (routing_component_cluster_t) rc;
- xbt_dict_set(routing->dict_processing_units, name, (void *) (-1), NULL);
-}
-
-static void model_cluster_set_autonomous_system(routing_component_t rc,
- const char *name)
-{
- routing_component_cluster_t routing =
- (routing_component_cluster_t) rc;
- xbt_dict_set(routing->dict_autonomous_systems, name, (void *) (-1),
- NULL);
-}
-
-static void model_cluster_set_bypassroute(routing_component_t rc,
- const char *src,
- const char *dst,
- route_extended_t e_route)
-{
- xbt_die("bypass routing not supported for Route-Based model");
-}
-
-static void model_cluster_set_route(routing_component_t rc,
- const char *src, const char *dst,
- name_route_extended_t route)
-{
- xbt_die("routing not supported for Route-Based model");
-}
-
-static void model_cluster_set_ASroute(routing_component_t rc,
- const char *src, const char *dst,
- name_route_extended_t route)
-{
- xbt_die("AS routing not supported for Route-Based model");
-}
-
-#define BUFFER_SIZE 4096 /* result buffer size */
-#define OVECCOUNT 30 /* should be a multiple of 3 */
-
static route_extended_t cluster_get_route(routing_component_t rc,
const char *src,
const char *dst);
-static xbt_dynar_t cluster_get_onelink_routes(routing_component_t rc)
-{
- xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free);
-
- //We have already bypass cluster routes with network NS3
- if(!strcmp(surf_network_model->name,"network NS3"))
- return ret;
-
- routing_component_cluster_t routing = (routing_component_cluster_t)rc;
-
- xbt_dict_cursor_t c1 = NULL;
- char *k1, *d1;
-
- //find router
- char *router = NULL;
- xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
- if (rc->get_network_element_type(k1) == SURF_NETWORK_ELEMENT_ROUTER){
- router = k1;
- }
- }
-
- if (!router){
- xbt_die ("cluster_get_onelink_routes works only if the AS is a cluster, sorry.");
- }
-
- xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
- route_extended_t route = cluster_get_route (rc, router, k1);
-
- int number_of_links = xbt_dynar_length(route->generic_route.link_list);
-
- if(number_of_links == 1) {
- //loopback
- }
- else{
- if (number_of_links != 2) {
- xbt_die ("cluster_get_onelink_routes works only if the AS is a cluster, sorry.");
- }
-
- void *link_ptr;
- xbt_dynar_get_cpy (route->generic_route.link_list, 1, &link_ptr);
- onelink_t onelink = xbt_new0 (s_onelink_t, 1);
- onelink->src = xbt_strdup (k1);
- onelink->dst = xbt_strdup (router);
- onelink->link_ptr = link_ptr;
- xbt_dynar_push (ret, &onelink);
- }
- }
- return ret;
-}
/* Business methods */
static route_extended_t cluster_get_route(routing_component_t rc,
return new_e_route;
}
-static route_extended_t cluster_get_bypass_route(routing_component_t rc,
- const char *src,
- const char *dst)
-{
- return NULL;
-}
-
-static void cluster_finalize(routing_component_t rc)
-{
- routing_component_cluster_t routing =
- (routing_component_cluster_t) rc;
- if (routing) {
- xbt_dict_free(&routing->dict_processing_units);
- xbt_dict_free(&routing->dict_autonomous_systems);
- /* Delete structure */
- xbt_free(routing);
- }
-}
-
/* Creation routing model functions */
void *model_cluster_create(void)
{
- routing_component_cluster_t new_component =
- xbt_new0(s_routing_component_cluster_t, 1);
- new_component->generic_routing.set_processing_unit =
- model_cluster_set_processing_unit;
- new_component->generic_routing.set_autonomous_system =
- model_cluster_set_autonomous_system;
- new_component->generic_routing.set_route = model_cluster_set_route;
- new_component->generic_routing.set_ASroute = model_cluster_set_ASroute;
- new_component->generic_routing.set_bypassroute = model_cluster_set_bypassroute;
- new_component->generic_routing.get_onelink_routes = cluster_get_onelink_routes;
+ routing_component_cluster_t new_component = model_rulebased_create();
new_component->generic_routing.get_route = cluster_get_route;
- new_component->generic_routing.get_latency = generic_get_link_latency;
- new_component->generic_routing.get_bypass_route = cluster_get_bypass_route;
- new_component->generic_routing.finalize = cluster_finalize;
- new_component->generic_routing.get_network_element_type = get_network_element_type;
- /* initialization of internal structures */
- new_component->dict_processing_units = xbt_dict_new();
- new_component->dict_autonomous_systems = xbt_dict_new();
return new_component;
}
-
-void model_cluster_load(void)
-{
- /* use "surfxml_add_callback" to add a parse function call */
-}
-
-void model_cluster_unload(void)
-{
- /* use "surfxml_del_callback" to remove a parse function call */
-}
-
-void model_cluster_end(void)
-{
-}