aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testbed/gnunet_testbed_mpi_spawn.c14
-rw-r--r--src/testbed/testbed_api_hosts.c14
-rw-r--r--src/testbed/testbed_api_testbed.c125
3 files changed, 94 insertions, 59 deletions
diff --git a/src/testbed/gnunet_testbed_mpi_spawn.c b/src/testbed/gnunet_testbed_mpi_spawn.c
index 736cd0cca..c7b7aab0b 100644
--- a/src/testbed/gnunet_testbed_mpi_spawn.c
+++ b/src/testbed/gnunet_testbed_mpi_spawn.c
@@ -56,11 +56,6 @@ static unsigned long child_exit_code;
56static enum GNUNET_OS_ProcessStatusType child_status; 56static enum GNUNET_OS_ProcessStatusType child_status;
57 57
58/** 58/**
59 * how many IP addresses are currently assigned to us
60 */
61static unsigned int num_addrs;
62
63/**
64 * The shutdown task 59 * The shutdown task
65 */ 60 */
66static GNUNET_SCHEDULER_TaskIdentifier shutdown_task_id; 61static GNUNET_SCHEDULER_TaskIdentifier shutdown_task_id;
@@ -196,12 +191,6 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
196 size_t hostname_len; 191 size_t hostname_len;
197 unsigned int nhosts; 192 unsigned int nhosts;
198 193
199 if (0 == num_addrs)
200 {
201 GNUNET_break (0);
202 ret = GNUNET_SYSERR;
203 return;
204 }
205 null_cfg = GNUNET_CONFIGURATION_create (); 194 null_cfg = GNUNET_CONFIGURATION_create ();
206 nhosts = GNUNET_TESTBED_hosts_load_from_loadleveler (null_cfg, &hosts); 195 nhosts = GNUNET_TESTBED_hosts_load_from_loadleveler (null_cfg, &hosts);
207 if (0 == nhosts) 196 if (0 == nhosts)
@@ -222,11 +211,12 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
222 } 211 }
223 if (NULL == strstr (GNUNET_TESTBED_host_get_hostname (hosts[0]), hostname)) 212 if (NULL == strstr (GNUNET_TESTBED_host_get_hostname (hosts[0]), hostname))
224 { 213 {
225 LOG_DEBUG ("Exiting as we are not the lowest host\n"); 214 LOG_DEBUG ("Exiting as `%s' is not the lowest host\n", hostname);
226 GNUNET_free (hostname); 215 GNUNET_free (hostname);
227 ret = GNUNET_OK; 216 ret = GNUNET_OK;
228 return; 217 return;
229 } 218 }
219 LOG_DEBUG ("Will be executing `%s' on host `%s'\n", argv2[0], hostname);
230 GNUNET_free (hostname); 220 GNUNET_free (hostname);
231 destroy_hosts (hosts, nhosts); 221 destroy_hosts (hosts, nhosts);
232 tmpdir = getenv ("TMPDIR"); 222 tmpdir = getenv ("TMPDIR");
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index 0888a9032..99625cba0 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -561,6 +561,17 @@ simple_resolve (const char *host)
561 return hostip; 561 return hostip;
562} 562}
563 563
564#if ENABLE_LL
565static int
566cmpstringp(const void *p1, const void *p2)
567{
568 /* The actual arguments to this function are "pointers to
569 pointers to char", but strcmp(3) arguments are "pointers
570 to char", hence the following cast plus dereference */
571
572 return strcmp(* (char * const *) p1, * (char * const *) p2);
573}
574#endif
564 575
565/** 576/**
566 * Loads the set of host allocated by the LoadLeveler Job Scheduler. This 577 * Loads the set of host allocated by the LoadLeveler Job Scheduler. This
@@ -689,8 +700,7 @@ GNUNET_TESTBED_hosts_load_from_loadleveler (const struct
689 return 0; 700 return 0;
690 if (NULL == hosts) 701 if (NULL == hosts)
691 goto cleanup; 702 goto cleanup;
692 qsort (hostnames, nhosts, sizeof (hostnames[0]), 703 qsort (hostnames, nhosts, sizeof (hostnames[0]), cmpstringp);
693 (int (*)(const void *, const void *))&strcmp);
694 host_list = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * nhosts); 704 host_list = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * nhosts);
695 for (host = 0; host < nhosts; host++) 705 for (host = 0; host < nhosts; host++)
696 host_list[host] = GNUNET_TESTBED_host_create (hostnames[host], NULL, cfg, 0); 706 host_list[host] = GNUNET_TESTBED_host_create (hostnames[host], NULL, cfg, 0);
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 5900a863e..c4cfe59b1 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -815,8 +815,17 @@ static void
815create_peers (struct RunContext *rc) 815create_peers (struct RunContext *rc)
816{ 816{
817 struct RunContextOperation *rcop; 817 struct RunContextOperation *rcop;
818 struct GNUNET_TESTBED_Host *host;
818 unsigned int peer; 819 unsigned int peer;
820#if ENABLE_LL
821 struct Island *island;
822 unsigned int icnt;
823 unsigned int hcnt;
819 824
825 island = NULL;
826 icnt = 0;
827 hcnt = 0;
828#endif
820 DEBUG ("Creating peers\n"); 829 DEBUG ("Creating peers\n");
821 rc->pstart_time = GNUNET_TIME_absolute_get (); 830 rc->pstart_time = GNUNET_TIME_absolute_get ();
822 rc->peers = 831 rc->peers =
@@ -827,12 +836,31 @@ create_peers (struct RunContext *rc)
827 { 836 {
828 rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); 837 rcop = GNUNET_malloc (sizeof (struct RunContextOperation));
829 rcop->rc = rc; 838 rcop->rc = rc;
830 rcop->op = 839#if ENABLE_LL
831 GNUNET_TESTBED_peer_create (rc->c, 840 if (0 != rc->nislands)
832 (0 == 841 {
833 rc->num_hosts) ? rc->h : rc->hosts[peer % 842 island = rc->islands[icnt];
834 rc->num_hosts], 843 if (hcnt == island->nhosts)
835 rc->cfg, &peer_create_cb, rcop); 844 {
845 icnt++;
846 if (icnt == rc->nislands)
847 icnt = 0;
848 island = rc->islands[icnt];
849 hcnt = 0;
850 }
851 GNUNET_assert (icnt < rc->nislands);
852 GNUNET_assert (hcnt < island->nhosts);
853 GNUNET_assert (NULL != island->hosts[hcnt]);
854 host = island->hosts[hcnt];
855 hcnt++;
856 }
857 else
858 host = rc->h;
859#else
860 host = (0 == rc->num_hosts) ? rc->h : rc->hosts[peer % rc->num_hosts];
861#endif
862 rcop->op = GNUNET_TESTBED_peer_create (rc->c, host, rc->cfg,
863 &peer_create_cb, rcop);
836 GNUNET_assert (NULL != rcop->op); 864 GNUNET_assert (NULL != rcop->op);
837 insert_rcop (rc, rcop); 865 insert_rcop (rc, rcop);
838 } 866 }
@@ -900,7 +928,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
900 } 928 }
901 } 929 }
902 if (0 != rc->reg_hosts) 930 if (0 != rc->reg_hosts)
903 return; 931 return;
904 rc->state = RC_LINKED; 932 rc->state = RC_LINKED;
905 create_peers (rc); 933 create_peers (rc);
906#endif 934#endif
@@ -934,6 +962,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
934 return; 962 return;
935 rc->state = RC_LINKED; 963 rc->state = RC_LINKED;
936 create_peers (rc); 964 create_peers (rc);
965 return;
937 default: 966 default:
938 GNUNET_break (0); 967 GNUNET_break (0);
939 shutdown_now (rc); 968 shutdown_now (rc);
@@ -1180,6 +1209,49 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
1180} 1209}
1181 1210
1182 1211
1212#if ENABLE_LL
1213#define ISLANDNAME_SIZE 4
1214static void
1215parse_islands (struct RunContext *rc)
1216{
1217 char island_id[ISLANDNAME_SIZE];
1218 struct GNUNET_TESTBED_Host *host;
1219 struct Island *island;
1220 const char *hostname;
1221 unsigned int nhost;
1222
1223 DEBUG ("Parsing for islands\n");
1224 memset (island_id, 0, ISLANDNAME_SIZE);
1225 island = NULL;
1226 for (nhost = 0; nhost < rc->num_hosts; nhost++)
1227 {
1228 host = rc->hosts[nhost];
1229 hostname = GNUNET_TESTBED_host_get_hostname (host);
1230 GNUNET_assert (NULL != hostname);
1231 if (NULL == island)
1232 {
1233 strncpy (island_id, hostname, ISLANDNAME_SIZE - 1);
1234 island = GNUNET_malloc (sizeof (struct Island));
1235 }
1236 if (0 == strncmp (island_id, hostname, ISLANDNAME_SIZE - 1))
1237 {
1238 GNUNET_array_append (island->hosts, island->nhosts, host);
1239 continue;
1240 }
1241 DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts);
1242 GNUNET_array_append (rc->islands, rc->nislands, island);
1243 island = NULL;
1244 }
1245 if (NULL != island)
1246 {
1247 DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts);
1248 GNUNET_array_append (rc->islands, rc->nislands, island);
1249 }
1250 DEBUG ("Total islands parsed: %u\n", rc->nislands);
1251}
1252#endif
1253
1254
1183/** 1255/**
1184 * Callback function invoked for each interface found. 1256 * Callback function invoked for each interface found.
1185 * 1257 *
@@ -1274,6 +1346,7 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host,
1274 GNUNET_free (rc->hosts); 1346 GNUNET_free (rc->hosts);
1275 rc->hosts = NULL; 1347 rc->hosts = NULL;
1276 } 1348 }
1349 parse_islands (rc);
1277 GNUNET_OS_network_interfaces_list (netint_proc, rc); 1350 GNUNET_OS_network_interfaces_list (netint_proc, rc);
1278 if (NULL == rc->trusted_ip) 1351 if (NULL == rc->trusted_ip)
1279 rc->trusted_ip = GNUNET_strdup ("127.0.0.1"); 1352 rc->trusted_ip = GNUNET_strdup ("127.0.0.1");
@@ -1310,43 +1383,6 @@ timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1310} 1383}
1311 1384
1312 1385
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
1350/** 1386/**
1351 * Convenience method for running a testbed with 1387 * Convenience method for running a testbed with
1352 * a single call. Underlay and overlay topology 1388 * a single call. Underlay and overlay topology
@@ -1402,7 +1438,6 @@ GNUNET_TESTBED_run (const char *host_filename,
1402 _("No hosts loaded from LoadLeveler. Need at least one host\n")); 1438 _("No hosts loaded from LoadLeveler. Need at least one host\n"));
1403 goto error_cleanup; 1439 goto error_cleanup;
1404 } 1440 }
1405 parse_islands (rc);
1406#else 1441#else
1407 if (NULL != host_filename) 1442 if (NULL != host_filename)
1408 { 1443 {