aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testbed/testbed_api_testbed.c197
1 files changed, 186 insertions, 11 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 5e90b9045..5900a863e 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -87,6 +87,13 @@ 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
90 /** 97 /**
91 * Controllers on given hosts started and linked 98 * Controllers on given hosts started and linked
92 */ 99 */
@@ -142,6 +149,23 @@ struct CompatibilityCheckContext
142 unsigned int index; 149 unsigned int index;
143}; 150};
144 151
152#if ENABLE_LL
153/**
154 * Structure to represent an island of SuperMUC's nodes
155 */
156struct 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
145 169
146/** 170/**
147 * Testbed Run Handle 171 * Testbed Run Handle
@@ -205,6 +229,13 @@ struct RunContext
205 */ 229 */
206 struct GNUNET_TESTBED_Host **hosts; 230 struct GNUNET_TESTBED_Host **hosts;
207 231
232#if ENABLE_LL
233 /**
234 * Array of SuperMUC islands
235 */
236 struct Island **islands;
237#endif
238
208 /** 239 /**
209 * Array of compatibility check contexts 240 * Array of compatibility check contexts
210 */ 241 */
@@ -222,7 +253,8 @@ struct RunContext
222 struct GNUNET_TESTBED_Operation *topology_operation; 253 struct GNUNET_TESTBED_Operation *topology_operation;
223 254
224 /** 255 /**
225 * The file containing topology data. Only used if the topology is set to 'FROM_FILE' 256 * The file containing topology data. Only used if the topology is set to
257 * 'FROM_FILE'
226 */ 258 */
227 char *topo_file; 259 char *topo_file;
228 260
@@ -318,6 +350,12 @@ struct RunContext
318 */ 350 */
319 unsigned int links_failed; 351 unsigned int links_failed;
320 352
353#if ENABLE_LL
354 /**
355 * Number of SuperMUC islands we are running on
356 */
357 unsigned int nislands;
358#endif
321}; 359};
322 360
323 361
@@ -436,6 +474,25 @@ remove_rcop (struct RunContext *rc, struct RunContextOperation *rcop)
436 rcop)); 474 rcop));
437} 475}
438 476
477#if ENABLE_LL
478static void
479cleanup_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
439/** 496/**
440 * Assuming all peers have been destroyed cleanup run handle 497 * Assuming all peers have been destroyed cleanup run handle
441 * 498 *
@@ -446,7 +503,7 @@ static void
446cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 503cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
447{ 504{
448 struct RunContext *rc = cls; 505 struct RunContext *rc = cls;
449 unsigned int hid; 506 unsigned int cnt;
450 507
451 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rc->register_hosts_task); 508 GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rc->register_hosts_task);
452 GNUNET_assert (NULL == rc->reg_handle); 509 GNUNET_assert (NULL == rc->reg_handle);
@@ -461,8 +518,12 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
461 GNUNET_TESTBED_controller_stop (rc->cproc); 518 GNUNET_TESTBED_controller_stop (rc->cproc);
462 if (NULL != rc->h) 519 if (NULL != rc->h)
463 GNUNET_TESTBED_host_destroy (rc->h); 520 GNUNET_TESTBED_host_destroy (rc->h);
464 for (hid = 0; hid < rc->num_hosts; hid++) 521#if ENABLE_LL
465 GNUNET_TESTBED_host_destroy (rc->hosts[hid]); 522 if (NULL != rc->islands)
523 cleanup_islands (rc);
524#endif
525 for (cnt = 0; cnt < rc->num_hosts; cnt++)
526 GNUNET_TESTBED_host_destroy (rc->hosts[cnt]);
466 GNUNET_free_non_null (rc->hosts); 527 GNUNET_free_non_null (rc->hosts);
467 if (NULL != rc->cfg) 528 if (NULL != rc->cfg)
468 GNUNET_CONFIGURATION_destroy (rc->cfg); 529 GNUNET_CONFIGURATION_destroy (rc->cfg);
@@ -808,11 +869,41 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
808 remove_rcop (rc, rcop); 869 remove_rcop (rc, rcop);
809 GNUNET_TESTBED_operation_done (rcop->op); 870 GNUNET_TESTBED_operation_done (rcop->op);
810 GNUNET_free (rcop); 871 GNUNET_free (rcop);
811 if (rc->reg_hosts == rc->num_hosts) 872#if !ENABLE_LL
873 if (rc->reg_hosts != rc->num_hosts)
874 return;
875 rc->state = RC_LINKED;
876 create_peers (rc);
877#else
878 if (rc->reg_hosts != rc->nislands)
879 return;
880 struct Island *island;
881 struct GNUNET_TESTBED_Host *host;
882 unsigned int cnt;
883 unsigned int cnt2;
884 rc->state = RC_ISLANDS_LINKED;
885 rc->reg_hosts = 0;
886 for (cnt = 0; cnt < rc->nislands; cnt++)
812 { 887 {
813 rc->state = RC_LINKED; 888 island = rc->islands[cnt];
814 create_peers (rc); 889 for (cnt2 = 1; cnt2 < island->nhosts; cnt2++)
890 {
891 host = island->hosts[cnt2];
892 rcop = GNUNET_malloc (sizeof (struct RunContextOperation));
893 rcop->rc = rc;
894 rcop->op =
895 GNUNET_TESTBED_controller_link (rcop, rc->c, host,
896 island->hosts[0], GNUNET_YES);
897 GNUNET_assert (NULL != rcop->op);
898 insert_rcop (rc, rcop);
899 rc->reg_hosts++;
900 }
815 } 901 }
902 if (0 != rc->reg_hosts)
903 return;
904 rc->state = RC_LINKED;
905 create_peers (rc);
906#endif
816 return; 907 return;
817 default: 908 default:
818 GNUNET_break (0); 909 GNUNET_break (0);
@@ -820,6 +911,36 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
820 return; 911 return;
821 } 912 }
822 } 913 }
914#if ENABLE_LL
915 if (RC_ISLANDS_LINKED == rc->state)
916 {
917 switch (event->type)
918 {
919 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
920 rcop = event->op_cls;
921 if (NULL != event->details.operation_finished.emsg)
922 {
923 LOG (GNUNET_ERROR_TYPE_ERROR,
924 "Linking 2nd level controllers failed. Exiting");
925 shutdown_now (rc);
926 }
927 else
928 rc->reg_hosts--;
929 GNUNET_assert (event->op == rcop->op);
930 remove_rcop (rc, rcop);
931 GNUNET_TESTBED_operation_done (rcop->op);
932 GNUNET_free (rcop);
933 if (0 != rc->reg_hosts)
934 return;
935 rc->state = RC_LINKED;
936 create_peers (rc);
937 default:
938 GNUNET_break (0);
939 shutdown_now (rc);
940 return;
941 }
942 }
943#endif
823 if (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type) 944 if (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type)
824 goto call_cc; 945 goto call_cc;
825 if (NULL == (rcop = search_rcop (rc, event->op))) 946 if (NULL == (rcop = search_rcop (rc, event->op)))
@@ -960,23 +1081,39 @@ register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
960{ 1081{
961 struct RunContext *rc = cls; 1082 struct RunContext *rc = cls;
962 struct RunContextOperation *rcop; 1083 struct RunContextOperation *rcop;
963 unsigned int slave; 1084 unsigned int cnt;
964 1085
965 rc->register_hosts_task = GNUNET_SCHEDULER_NO_TASK; 1086 rc->register_hosts_task = GNUNET_SCHEDULER_NO_TASK;
966 if (rc->reg_hosts == rc->num_hosts) 1087 if (rc->reg_hosts == rc->num_hosts)
967 { 1088 {
968 DEBUG ("All hosts successfully registered\n"); 1089 DEBUG ("All hosts successfully registered\n");
969 /* Start slaves */ 1090 /* Start cnts */
970 for (slave = 0; slave < rc->num_hosts; slave++) 1091#if !ENABLE_LL
1092 for (cnt = 0; cnt < rc->num_hosts; cnt++)
971 { 1093 {
972 rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); 1094 rcop = GNUNET_malloc (sizeof (struct RunContextOperation));
973 rcop->rc = rc; 1095 rcop->rc = rc;
974 rcop->op = 1096 rcop->op =
975 GNUNET_TESTBED_controller_link (rcop, rc->c, rc->hosts[slave], 1097 GNUNET_TESTBED_controller_link (rcop, rc->c, rc->hosts[cnt],
976 rc->h, GNUNET_YES); 1098 rc->h, GNUNET_YES);
977 GNUNET_assert (NULL != rcop->op); 1099 GNUNET_assert (NULL != rcop->op);
978 insert_rcop (rc, rcop); 1100 insert_rcop (rc, rcop);
979 } 1101 }
1102#else
1103 struct Island *island;
1104 for (cnt = 0; cnt < rc->nislands; cnt++)
1105 {
1106 island = rc->islands[cnt];
1107 GNUNET_assert (0 < island->nhosts);
1108 rcop = GNUNET_malloc (sizeof (struct RunContextOperation));
1109 rcop->rc = rc;
1110 rcop->op =
1111 GNUNET_TESTBED_controller_link (rcop, rc->c, island->hosts[0],
1112 rc->h, GNUNET_YES);
1113 GNUNET_assert (NULL != rcop->op);
1114 insert_rcop (rc, rcop);
1115 }
1116#endif
980 rc->reg_hosts = 0; 1117 rc->reg_hosts = 0;
981 return; 1118 return;
982 } 1119 }
@@ -1173,6 +1310,43 @@ timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1173} 1310}
1174 1311
1175 1312
1313#if ENABLE_LL
1314static void
1315parse_islands (struct RunContext *rc)
1316{
1317#define ISLANDNAME_SIZE 4
1318 char island_id[ISLANDNAME_SIZE];
1319 struct GNUNET_TESTBED_Host *host;
1320 struct Island *island;
1321 const char *hostname;
1322 unsigned int nhost;
1323
1324 memset (island_id, 0, ISLANDNAME_SIZE);
1325 island = NULL;
1326 for (nhost = 0; nhost < rc->num_hosts; nhost++)
1327 {
1328 host = rc->hosts[nhost];
1329 hostname = GNUNET_TESTBED_host_get_hostname (host);
1330 GNUNET_assert (NULL != hostname);
1331 if (NULL == island)
1332 {
1333 strncpy (island_id, hostname, ISLANDNAME_SIZE - 1);
1334 island = GNUNET_malloc (sizeof (struct Island));
1335 }
1336 if (0 == strncmp (island_id, hostname, ISLANDNAME_SIZE - 1))
1337 {
1338 GNUNET_array_append (island->hosts, island->nhosts, host);
1339 continue;
1340 }
1341 DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts);
1342 GNUNET_array_append (rc->islands, rc->nislands, island);
1343 island = NULL;
1344 }
1345 if (NULL != island)
1346 GNUNET_array_append (rc->islands, rc->nislands, island);
1347}
1348#endif
1349
1176/** 1350/**
1177 * Convenience method for running a testbed with 1351 * Convenience method for running a testbed with
1178 * a single call. Underlay and overlay topology 1352 * a single call. Underlay and overlay topology
@@ -1228,6 +1402,7 @@ GNUNET_TESTBED_run (const char *host_filename,
1228 _("No hosts loaded from LoadLeveler. Need at least one host\n")); 1402 _("No hosts loaded from LoadLeveler. Need at least one host\n"));
1229 goto error_cleanup; 1403 goto error_cleanup;
1230 } 1404 }
1405 parse_islands (rc);
1231#else 1406#else
1232 if (NULL != host_filename) 1407 if (NULL != host_filename)
1233 { 1408 {