1 /* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "surf_routing_private.h"
9 extern routing_global_t global_routing;
11 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
13 /* This routing is specifically setup to represent clusters, aka homogeneous sets of machines
14 * Note that a router is created, easing the interconnexion with the rest of the world.
17 static xbt_dict_t cluster_host_link = NULL; /* for tag cluster */
20 s_routing_component_t generic_routing;
21 xbt_dict_t dict_processing_units;
22 xbt_dict_t dict_autonomous_systems;
23 } s_routing_component_cluster_t, *routing_component_cluster_t;
25 /* Business methods */
26 static route_extended_t cluster_get_route(routing_component_t rc,
30 xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link, NULL);
32 surf_parsing_link_up_down_t info;
34 info = xbt_dict_get_or_null(cluster_host_link,src);
35 if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_up
37 info = xbt_dict_get_or_null(cluster_host_link,rc->name);
38 if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_bb
40 info = xbt_dict_get_or_null(cluster_host_link,dst);
41 if(info) xbt_dynar_push_as(links_list,void*,info->link_down); //link_down
43 route_extended_t new_e_route = NULL;
44 new_e_route = xbt_new0(s_route_extended_t, 1);
45 new_e_route->generic_route.link_list = links_list;
50 /* Creation routing model functions */
51 routing_component_t model_cluster_create(void)
53 routing_component_t new_component = model_rulebased_create();
54 new_component->get_route = cluster_get_route;
56 return (routing_component_t) new_component;
58 void model_cluster_unload(void) {
59 // xbt_dict_free(&cluster_host_link); //FIXME: do it once the module management is clean in routing
62 void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info) {
63 if(!cluster_host_link)
64 cluster_host_link = xbt_dict_new();
66 xbt_dict_set(cluster_host_link,host_id,info,xbt_free);