Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add V_cluster_availability_file and V_cluster_state_file to struct for cluster.
[simgrid.git] / src / surf / surf_routing_cluster.c
1 /* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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"
7
8 /* Global vars */
9 extern routing_global_t global_routing;
10 extern routing_component_t current_routing;
11 extern model_type_t current_routing_model;
12 extern xbt_dynar_t link_list;
13 extern xbt_dict_t cluster_host_link;
14
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
16
17 /* Routing model structure */
18
19 typedef struct {
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;
24
25 /* Parse routing model functions */
26
27 static route_extended_t cluster_get_route(routing_component_t rc,
28                                             const char *src,
29                                             const char *dst);
30
31 /* Business methods */
32 static route_extended_t cluster_get_route(routing_component_t rc,
33                                             const char *src,
34                                             const char *dst)
35 {
36           xbt_assert(rc && src
37                       && dst,
38                       "Invalid params for \"get_route\" function at AS \"%s\"",
39                       rc->name);
40
41
42           xbt_dynar_t links_list =
43               xbt_dynar_new(global_routing->size_of_link, NULL);
44
45           char *cluster_is_fd = xbt_dict_get_or_null(cluster_host_link,rc->name);
46           char *link_src,*link_bb,*link_dst,*link_src_up,*link_dst_down;
47
48           if(!cluster_is_fd){ //        NOT FULLDUPLEX
49                   link_src = xbt_dict_get_or_null(cluster_host_link,src);
50                   if( !link_src && (global_routing->get_network_element_type(src) != SURF_NETWORK_ELEMENT_ROUTER) )
51                           xbt_die("No link for '%s' found!",src);
52                   if(link_src) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_src, SURF_LINK_LEVEL)); //link_up
53
54                   link_bb = bprintf("%s_backbone",rc->name);
55                   xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_bb, SURF_LINK_LEVEL)); //link_bb
56                   free(link_bb);
57
58                   link_dst = xbt_dict_get_or_null(cluster_host_link,dst);
59                   if( !link_dst && (global_routing->get_network_element_type(dst) != SURF_NETWORK_ELEMENT_ROUTER) )
60                           xbt_die("No link for '%s' found!",dst);
61                   if(link_dst) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_dst, SURF_LINK_LEVEL)); //link_down
62           }
63           else //       FULLDUPLEX
64           {
65                   link_src = xbt_dict_get_or_null(cluster_host_link,src);
66                   if( !link_src  && (global_routing->get_network_element_type(src) != SURF_NETWORK_ELEMENT_ROUTER) )
67                           xbt_die("No link for '%s' found!",src);
68                   link_src_up = bprintf("%s_UP",link_src);
69                   if(link_src) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_src_up, SURF_LINK_LEVEL)); //link_up
70                   free(link_src_up);
71
72                   link_bb = bprintf("%s_backbone",rc->name);
73                   if(link_bb)  xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_bb, SURF_LINK_LEVEL)); //link_bb
74                   free(link_bb);
75
76                   link_dst = xbt_dict_get_or_null(cluster_host_link,dst);
77                   if(!link_dst  && (global_routing->get_network_element_type(dst) != SURF_NETWORK_ELEMENT_ROUTER))
78                           xbt_die("No link for '%s' found!",dst);
79                   link_dst_down = bprintf("%s_DOWN",link_dst);
80                   if(link_dst) xbt_dynar_push_as(links_list,void*,xbt_lib_get_or_null(link_lib, link_dst_down, SURF_LINK_LEVEL)); //link_down
81                   free(link_dst_down);
82           }
83
84           route_extended_t new_e_route = NULL;
85           new_e_route = xbt_new0(s_route_extended_t, 1);
86           new_e_route->generic_route.link_list = links_list;
87
88           return new_e_route;
89 }
90
91 /* Creation routing model functions */
92 void *model_cluster_create(void)
93 {
94   routing_component_cluster_t new_component = model_rulebased_create();
95   new_component->generic_routing.get_route = cluster_get_route;
96
97   return new_component;
98 }