Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
do not search the cluster backbones again and again, store them in the right location
[simgrid.git] / src / surf / surf_routing_cluster.c
index a0a92d8..883b887 100644 (file)
@@ -14,18 +14,18 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"
  * Note that a router is created, easing the interconnexion with the rest of the world.
  */
 
-static xbt_dict_t cluster_host_link = NULL; /* for tag cluster */
-
 typedef struct {
-  s_routing_component_t generic_routing;
-  xbt_dict_t dict_processing_units;
-  xbt_dict_t dict_autonomous_systems;
-} s_routing_component_cluster_t, *routing_component_cluster_t;
+  s_as_t generic_routing;
+  void *backbone;
+} s_as_cluster_t, *as_cluster_t;
+
+
+static xbt_dict_t cluster_host_link = NULL;
 
 /* Business methods */
-static route_extended_t cluster_get_route(routing_component_t rc,
-                                            const char *src,
-                                            const char *dst) {
+static route_extended_t cluster_get_route(AS_t as,
+                                          const char *src,
+                                          const char *dst) {
 
          xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link, NULL);
 
@@ -34,8 +34,8 @@ static route_extended_t cluster_get_route(routing_component_t rc,
          info = xbt_dict_get_or_null(cluster_host_link,src);
          if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_up
 
-         info = xbt_dict_get_or_null(cluster_host_link,rc->name);
-         if(info)  xbt_dynar_push_as(links_list,void*,info->link_up); //link_bb
+         if ( ((as_cluster_t)as)->backbone )
+           xbt_dynar_push_as(links_list,void*, ((as_cluster_t)as)->backbone) ;
 
          info = xbt_dict_get_or_null(cluster_host_link,dst);
          if(info) xbt_dynar_push_as(links_list,void*,info->link_down); //link_down
@@ -47,13 +47,18 @@ static route_extended_t cluster_get_route(routing_component_t rc,
          return new_e_route;
 }
 
+static void model_cluster_finalize(AS_t as) {
+  xbt_dict_free(&cluster_host_link);
+  model_none_finalize(as);
+}
 /* Creation routing model functions */
-routing_component_t model_cluster_create(void)
+AS_t model_cluster_create(void)
 {
-  routing_component_t new_component = model_rulebased_create();
-  new_component->get_route = cluster_get_route;
+  AS_t result = model_none_create_sized(sizeof(s_as_cluster_t));
+  result->get_route = cluster_get_route;
+  result->finalize = model_cluster_finalize;
 
-  return (routing_component_t) new_component;
+  return (AS_t) result;
 }
 
 void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info) {
@@ -62,3 +67,7 @@ void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down
 
  xbt_dict_set(cluster_host_link,host_id,info,xbt_free);
 }
+
+void surf_routing_cluster_add_backbone(AS_t as, void* bb) {
+  ((as_cluster_t)as)->backbone = bb;
+}