diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-06-10 14:53:59 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-06-10 14:53:59 +0000 |
commit | 71c05c26d10a51f38df8ee19302cbd0b8c6f4453 (patch) | |
tree | 4a8e64aba31863e7be32ae87603cae9b63f03e60 /src/testbed/testbed_api_testbed.c | |
parent | 7f61d08dcf2e6e895bf01a8c647372c4ef6d04fc (diff) | |
download | gnunet-71c05c26d10a51f38df8ee19302cbd0b8c6f4453.tar.gz gnunet-71c05c26d10a51f38df8ee19302cbd0b8c6f4453.zip |
- remove island handling code (we are restricted to 1 island anyway)
Diffstat (limited to 'src/testbed/testbed_api_testbed.c')
-rw-r--r-- | src/testbed/testbed_api_testbed.c | 248 |
1 files changed, 17 insertions, 231 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 98b8eaad1..8e3a1073e 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -87,13 +87,6 @@ enum State | |||
87 | */ | 87 | */ |
88 | RC_INIT = 0, | 88 | RC_INIT = 0, |
89 | 89 | ||
90 | #if ENABLE_LL | ||
91 | /** | ||
92 | * Island level controllers are started and linked | ||
93 | */ | ||
94 | RC_ISLANDS_LINKED, | ||
95 | #endif | ||
96 | |||
97 | /** | 90 | /** |
98 | * Controllers on given hosts started and linked | 91 | * Controllers on given hosts started and linked |
99 | */ | 92 | */ |
@@ -149,23 +142,6 @@ struct CompatibilityCheckContext | |||
149 | unsigned int index; | 142 | unsigned int index; |
150 | }; | 143 | }; |
151 | 144 | ||
152 | #if ENABLE_LL | ||
153 | /** | ||
154 | * Structure to represent an island of SuperMUC's nodes | ||
155 | */ | ||
156 | struct Island | ||
157 | { | ||
158 | /** | ||
159 | * Array of nodes in this island | ||
160 | */ | ||
161 | struct GNUNET_TESTBED_Host **hosts; | ||
162 | |||
163 | /** | ||
164 | * Number of nodes in the above array | ||
165 | */ | ||
166 | unsigned int nhosts; | ||
167 | }; | ||
168 | #endif | ||
169 | 145 | ||
170 | /** | 146 | /** |
171 | * Testbed Run Handle | 147 | * Testbed Run Handle |
@@ -229,13 +205,6 @@ struct RunContext | |||
229 | */ | 205 | */ |
230 | struct GNUNET_TESTBED_Host **hosts; | 206 | struct GNUNET_TESTBED_Host **hosts; |
231 | 207 | ||
232 | #if ENABLE_LL | ||
233 | /** | ||
234 | * Array of SuperMUC islands | ||
235 | */ | ||
236 | struct Island **islands; | ||
237 | #endif | ||
238 | |||
239 | /** | 208 | /** |
240 | * Array of compatibility check contexts | 209 | * Array of compatibility check contexts |
241 | */ | 210 | */ |
@@ -253,8 +222,7 @@ struct RunContext | |||
253 | struct GNUNET_TESTBED_Operation *topology_operation; | 222 | struct GNUNET_TESTBED_Operation *topology_operation; |
254 | 223 | ||
255 | /** | 224 | /** |
256 | * The file containing topology data. Only used if the topology is set to | 225 | * The file containing topology data. Only used if the topology is set to 'FROM_FILE' |
257 | * 'FROM_FILE' | ||
258 | */ | 226 | */ |
259 | char *topo_file; | 227 | char *topo_file; |
260 | 228 | ||
@@ -350,12 +318,6 @@ struct RunContext | |||
350 | */ | 318 | */ |
351 | unsigned int links_failed; | 319 | unsigned int links_failed; |
352 | 320 | ||
353 | #if ENABLE_LL | ||
354 | /** | ||
355 | * Number of SuperMUC islands we are running on | ||
356 | */ | ||
357 | unsigned int nislands; | ||
358 | #endif | ||
359 | }; | 321 | }; |
360 | 322 | ||
361 | 323 | ||
@@ -474,25 +436,6 @@ remove_rcop (struct RunContext *rc, struct RunContextOperation *rcop) | |||
474 | rcop)); | 436 | rcop)); |
475 | } | 437 | } |
476 | 438 | ||
477 | #if ENABLE_LL | ||
478 | static void | ||
479 | cleanup_islands (struct RunContext *rc) | ||
480 | { | ||
481 | struct Island *island; | ||
482 | unsigned int cnt; | ||
483 | |||
484 | GNUNET_assert (NULL != rc->islands); | ||
485 | for (cnt = 0; cnt < rc->nislands; cnt++) | ||
486 | { | ||
487 | island = rc->islands[cnt]; | ||
488 | GNUNET_free (island->hosts); | ||
489 | GNUNET_free (island); | ||
490 | } | ||
491 | GNUNET_free (rc->islands); | ||
492 | rc->islands = NULL; | ||
493 | } | ||
494 | #endif | ||
495 | |||
496 | /** | 439 | /** |
497 | * Assuming all peers have been destroyed cleanup run handle | 440 | * Assuming all peers have been destroyed cleanup run handle |
498 | * | 441 | * |
@@ -503,7 +446,7 @@ static void | |||
503 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 446 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
504 | { | 447 | { |
505 | struct RunContext *rc = cls; | 448 | struct RunContext *rc = cls; |
506 | unsigned int cnt; | 449 | unsigned int hid; |
507 | 450 | ||
508 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rc->register_hosts_task); | 451 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rc->register_hosts_task); |
509 | GNUNET_assert (NULL == rc->reg_handle); | 452 | GNUNET_assert (NULL == rc->reg_handle); |
@@ -518,12 +461,8 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
518 | GNUNET_TESTBED_controller_stop (rc->cproc); | 461 | GNUNET_TESTBED_controller_stop (rc->cproc); |
519 | if (NULL != rc->h) | 462 | if (NULL != rc->h) |
520 | GNUNET_TESTBED_host_destroy (rc->h); | 463 | GNUNET_TESTBED_host_destroy (rc->h); |
521 | #if ENABLE_LL | 464 | for (hid = 0; hid < rc->num_hosts; hid++) |
522 | if (NULL != rc->islands) | 465 | GNUNET_TESTBED_host_destroy (rc->hosts[hid]); |
523 | cleanup_islands (rc); | ||
524 | #endif | ||
525 | for (cnt = 0; cnt < rc->num_hosts; cnt++) | ||
526 | GNUNET_TESTBED_host_destroy (rc->hosts[cnt]); | ||
527 | GNUNET_free_non_null (rc->hosts); | 466 | GNUNET_free_non_null (rc->hosts); |
528 | if (NULL != rc->cfg) | 467 | if (NULL != rc->cfg) |
529 | GNUNET_CONFIGURATION_destroy (rc->cfg); | 468 | GNUNET_CONFIGURATION_destroy (rc->cfg); |
@@ -815,17 +754,8 @@ static void | |||
815 | create_peers (struct RunContext *rc) | 754 | create_peers (struct RunContext *rc) |
816 | { | 755 | { |
817 | struct RunContextOperation *rcop; | 756 | struct RunContextOperation *rcop; |
818 | struct GNUNET_TESTBED_Host *host; | ||
819 | unsigned int peer; | 757 | unsigned int peer; |
820 | #if ENABLE_LL | ||
821 | struct Island *island; | ||
822 | unsigned int icnt; | ||
823 | unsigned int hcnt; | ||
824 | 758 | ||
825 | island = NULL; | ||
826 | icnt = 0; | ||
827 | hcnt = 0; | ||
828 | #endif | ||
829 | DEBUG ("Creating peers\n"); | 759 | DEBUG ("Creating peers\n"); |
830 | rc->pstart_time = GNUNET_TIME_absolute_get (); | 760 | rc->pstart_time = GNUNET_TIME_absolute_get (); |
831 | rc->peers = | 761 | rc->peers = |
@@ -836,33 +766,12 @@ create_peers (struct RunContext *rc) | |||
836 | { | 766 | { |
837 | rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); | 767 | rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); |
838 | rcop->rc = rc; | 768 | rcop->rc = rc; |
839 | #if ENABLE_LL | 769 | rcop->op = |
840 | if (0 != rc->nislands) | 770 | GNUNET_TESTBED_peer_create (rc->c, |
841 | { | 771 | (0 == |
842 | island = rc->islands[icnt]; | 772 | rc->num_hosts) ? rc->h : rc->hosts[peer % |
843 | if (hcnt == island->nhosts) | 773 | rc->num_hosts], |
844 | { | 774 | rc->cfg, &peer_create_cb, rcop); |
845 | icnt++; | ||
846 | if (icnt == rc->nislands) | ||
847 | icnt = 0; | ||
848 | island = rc->islands[icnt]; | ||
849 | hcnt = 0; | ||
850 | } | ||
851 | if ( (0 == hcnt) && (1 < island->nhosts) ) | ||
852 | hcnt = 1; | ||
853 | GNUNET_assert (icnt < rc->nislands); | ||
854 | GNUNET_assert (hcnt < island->nhosts); | ||
855 | GNUNET_assert (NULL != island->hosts[hcnt]); | ||
856 | host = island->hosts[hcnt]; | ||
857 | hcnt++; | ||
858 | } | ||
859 | else | ||
860 | host = rc->h; | ||
861 | #else | ||
862 | host = (0 == rc->num_hosts) ? rc->h : rc->hosts[peer % rc->num_hosts]; | ||
863 | #endif | ||
864 | rcop->op = GNUNET_TESTBED_peer_create (rc->c, host, rc->cfg, | ||
865 | &peer_create_cb, rcop); | ||
866 | GNUNET_assert (NULL != rcop->op); | 775 | GNUNET_assert (NULL != rcop->op); |
867 | insert_rcop (rc, rcop); | 776 | insert_rcop (rc, rcop); |
868 | } | 777 | } |
@@ -899,71 +808,11 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
899 | remove_rcop (rc, rcop); | 808 | remove_rcop (rc, rcop); |
900 | GNUNET_TESTBED_operation_done (rcop->op); | 809 | GNUNET_TESTBED_operation_done (rcop->op); |
901 | GNUNET_free (rcop); | 810 | GNUNET_free (rcop); |
902 | #if !ENABLE_LL | 811 | if (rc->reg_hosts == rc->num_hosts) |
903 | if (rc->reg_hosts != rc->num_hosts) | ||
904 | return; | ||
905 | rc->state = RC_LINKED; | ||
906 | create_peers (rc); | ||
907 | #else | ||
908 | if (rc->reg_hosts != rc->nislands) | ||
909 | return; | ||
910 | struct Island *island; | ||
911 | struct GNUNET_TESTBED_Host *host; | ||
912 | unsigned int cnt; | ||
913 | unsigned int cnt2; | ||
914 | rc->state = RC_ISLANDS_LINKED; | ||
915 | rc->reg_hosts = 0; | ||
916 | for (cnt = 0; cnt < rc->nislands; cnt++) | ||
917 | { | ||
918 | island = rc->islands[cnt]; | ||
919 | for (cnt2 = 1; cnt2 < island->nhosts; cnt2++) | ||
920 | { | ||
921 | host = island->hosts[cnt2]; | ||
922 | rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); | ||
923 | rcop->rc = rc; | ||
924 | rcop->op = | ||
925 | GNUNET_TESTBED_controller_link (rcop, rc->c, host, | ||
926 | island->hosts[0], GNUNET_YES); | ||
927 | GNUNET_assert (NULL != rcop->op); | ||
928 | insert_rcop (rc, rcop); | ||
929 | rc->reg_hosts++; | ||
930 | } | ||
931 | } | ||
932 | if (0 != rc->reg_hosts) | ||
933 | return; | ||
934 | rc->state = RC_LINKED; | ||
935 | create_peers (rc); | ||
936 | #endif | ||
937 | return; | ||
938 | default: | ||
939 | GNUNET_break (0); | ||
940 | shutdown_now (rc); | ||
941 | return; | ||
942 | } | ||
943 | } | ||
944 | #if ENABLE_LL | ||
945 | if (RC_ISLANDS_LINKED == rc->state) | ||
946 | { | ||
947 | switch (event->type) | ||
948 | { | ||
949 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | ||
950 | rcop = event->op_cls; | ||
951 | if (NULL != event->details.operation_finished.emsg) | ||
952 | { | 812 | { |
953 | LOG (GNUNET_ERROR_TYPE_ERROR, | 813 | rc->state = RC_LINKED; |
954 | "Linking 2nd level controllers failed. Exiting"); | 814 | create_peers (rc); |
955 | shutdown_now (rc); | ||
956 | } | 815 | } |
957 | else | ||
958 | rc->reg_hosts--; | ||
959 | GNUNET_assert (event->op == rcop->op); | ||
960 | remove_rcop (rc, rcop); | ||
961 | GNUNET_TESTBED_operation_done (rcop->op); | ||
962 | GNUNET_free (rcop); | ||
963 | if (0 != rc->reg_hosts) | ||
964 | return; | ||
965 | rc->state = RC_LINKED; | ||
966 | create_peers (rc); | ||
967 | return; | 816 | return; |
968 | default: | 817 | default: |
969 | GNUNET_break (0); | 818 | GNUNET_break (0); |
@@ -971,7 +820,6 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
971 | return; | 820 | return; |
972 | } | 821 | } |
973 | } | 822 | } |
974 | #endif | ||
975 | if (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type) | 823 | if (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type) |
976 | goto call_cc; | 824 | goto call_cc; |
977 | if (NULL == (rcop = search_rcop (rc, event->op))) | 825 | if (NULL == (rcop = search_rcop (rc, event->op))) |
@@ -1112,39 +960,23 @@ register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1112 | { | 960 | { |
1113 | struct RunContext *rc = cls; | 961 | struct RunContext *rc = cls; |
1114 | struct RunContextOperation *rcop; | 962 | struct RunContextOperation *rcop; |
1115 | unsigned int cnt; | 963 | unsigned int slave; |
1116 | 964 | ||
1117 | rc->register_hosts_task = GNUNET_SCHEDULER_NO_TASK; | 965 | rc->register_hosts_task = GNUNET_SCHEDULER_NO_TASK; |
1118 | if (rc->reg_hosts == rc->num_hosts) | 966 | if (rc->reg_hosts == rc->num_hosts) |
1119 | { | 967 | { |
1120 | DEBUG ("All hosts successfully registered\n"); | 968 | DEBUG ("All hosts successfully registered\n"); |
1121 | /* Start cnts */ | 969 | /* Start slaves */ |
1122 | #if !ENABLE_LL | 970 | for (slave = 0; slave < rc->num_hosts; slave++) |
1123 | for (cnt = 0; cnt < rc->num_hosts; cnt++) | ||
1124 | { | ||
1125 | rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); | ||
1126 | rcop->rc = rc; | ||
1127 | rcop->op = | ||
1128 | GNUNET_TESTBED_controller_link (rcop, rc->c, rc->hosts[cnt], | ||
1129 | rc->h, GNUNET_YES); | ||
1130 | GNUNET_assert (NULL != rcop->op); | ||
1131 | insert_rcop (rc, rcop); | ||
1132 | } | ||
1133 | #else | ||
1134 | struct Island *island; | ||
1135 | for (cnt = 0; cnt < rc->nislands; cnt++) | ||
1136 | { | 971 | { |
1137 | island = rc->islands[cnt]; | ||
1138 | GNUNET_assert (0 < island->nhosts); | ||
1139 | rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); | 972 | rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); |
1140 | rcop->rc = rc; | 973 | rcop->rc = rc; |
1141 | rcop->op = | 974 | rcop->op = |
1142 | GNUNET_TESTBED_controller_link (rcop, rc->c, island->hosts[0], | 975 | GNUNET_TESTBED_controller_link (rcop, rc->c, rc->hosts[slave], |
1143 | rc->h, GNUNET_YES); | 976 | rc->h, GNUNET_YES); |
1144 | GNUNET_assert (NULL != rcop->op); | 977 | GNUNET_assert (NULL != rcop->op); |
1145 | insert_rcop (rc, rcop); | 978 | insert_rcop (rc, rcop); |
1146 | } | 979 | } |
1147 | #endif | ||
1148 | rc->reg_hosts = 0; | 980 | rc->reg_hosts = 0; |
1149 | return; | 981 | return; |
1150 | } | 982 | } |
@@ -1211,49 +1043,6 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1211 | } | 1043 | } |
1212 | 1044 | ||
1213 | 1045 | ||
1214 | #if ENABLE_LL | ||
1215 | #define ISLANDNAME_SIZE 4 | ||
1216 | static void | ||
1217 | parse_islands (struct RunContext *rc) | ||
1218 | { | ||
1219 | char island_id[ISLANDNAME_SIZE]; | ||
1220 | struct GNUNET_TESTBED_Host *host; | ||
1221 | struct Island *island; | ||
1222 | const char *hostname; | ||
1223 | unsigned int nhost; | ||
1224 | |||
1225 | DEBUG ("Parsing for islands\n"); | ||
1226 | memset (island_id, 0, ISLANDNAME_SIZE); | ||
1227 | island = NULL; | ||
1228 | for (nhost = 0; nhost < rc->num_hosts; nhost++) | ||
1229 | { | ||
1230 | host = rc->hosts[nhost]; | ||
1231 | hostname = GNUNET_TESTBED_host_get_hostname (host); | ||
1232 | GNUNET_assert (NULL != hostname); | ||
1233 | if (NULL == island) | ||
1234 | { | ||
1235 | strncpy (island_id, hostname, ISLANDNAME_SIZE - 1); | ||
1236 | island = GNUNET_malloc (sizeof (struct Island)); | ||
1237 | } | ||
1238 | if (0 == strncmp (island_id, hostname, ISLANDNAME_SIZE - 1)) | ||
1239 | { | ||
1240 | GNUNET_array_append (island->hosts, island->nhosts, host); | ||
1241 | continue; | ||
1242 | } | ||
1243 | DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts); | ||
1244 | GNUNET_array_append (rc->islands, rc->nislands, island); | ||
1245 | island = NULL; | ||
1246 | } | ||
1247 | if (NULL != island) | ||
1248 | { | ||
1249 | DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts); | ||
1250 | GNUNET_array_append (rc->islands, rc->nislands, island); | ||
1251 | } | ||
1252 | DEBUG ("Total islands parsed: %u\n", rc->nislands); | ||
1253 | } | ||
1254 | #endif | ||
1255 | |||
1256 | |||
1257 | /** | 1046 | /** |
1258 | * Callback function invoked for each interface found. | 1047 | * Callback function invoked for each interface found. |
1259 | * | 1048 | * |
@@ -1348,9 +1137,6 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host, | |||
1348 | GNUNET_free (rc->hosts); | 1137 | GNUNET_free (rc->hosts); |
1349 | rc->hosts = NULL; | 1138 | rc->hosts = NULL; |
1350 | } | 1139 | } |
1351 | #if ENABLE_LL | ||
1352 | parse_islands (rc); | ||
1353 | #endif | ||
1354 | GNUNET_TESTBED_host_resolve_ (rc->h); | 1140 | GNUNET_TESTBED_host_resolve_ (rc->h); |
1355 | for (nhost = 0; nhost < rc->num_hosts; nhost++) | 1141 | for (nhost = 0; nhost < rc->num_hosts; nhost++) |
1356 | GNUNET_TESTBED_host_resolve_ (rc->hosts[nhost]); | 1142 | GNUNET_TESTBED_host_resolve_ (rc->hosts[nhost]); |