From 39856c647019b719fb32fd98f3301ed21afdd088 Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Wed, 15 May 2013 10:03:38 +0000 Subject: - distribute peers equally among island nodes on SuperMUC --- src/testbed/gnunet_testbed_mpi_spawn.c | 14 +--- src/testbed/testbed_api_hosts.c | 14 +++- src/testbed/testbed_api_testbed.c | 125 +++++++++++++++++++++------------ 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 @@ -55,11 +55,6 @@ static unsigned long child_exit_code; */ static enum GNUNET_OS_ProcessStatusType child_status; -/** - * how many IP addresses are currently assigned to us - */ -static unsigned int num_addrs; - /** * The shutdown task */ @@ -196,12 +191,6 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) size_t hostname_len; unsigned int nhosts; - if (0 == num_addrs) - { - GNUNET_break (0); - ret = GNUNET_SYSERR; - return; - } null_cfg = GNUNET_CONFIGURATION_create (); nhosts = GNUNET_TESTBED_hosts_load_from_loadleveler (null_cfg, &hosts); if (0 == nhosts) @@ -222,11 +211,12 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } if (NULL == strstr (GNUNET_TESTBED_host_get_hostname (hosts[0]), hostname)) { - LOG_DEBUG ("Exiting as we are not the lowest host\n"); + LOG_DEBUG ("Exiting as `%s' is not the lowest host\n", hostname); GNUNET_free (hostname); ret = GNUNET_OK; return; } + LOG_DEBUG ("Will be executing `%s' on host `%s'\n", argv2[0], hostname); GNUNET_free (hostname); destroy_hosts (hosts, nhosts); 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) return hostip; } +#if ENABLE_LL +static int +cmpstringp(const void *p1, const void *p2) +{ + /* The actual arguments to this function are "pointers to + pointers to char", but strcmp(3) arguments are "pointers + to char", hence the following cast plus dereference */ + + return strcmp(* (char * const *) p1, * (char * const *) p2); +} +#endif /** * Loads the set of host allocated by the LoadLeveler Job Scheduler. This @@ -689,8 +700,7 @@ GNUNET_TESTBED_hosts_load_from_loadleveler (const struct return 0; if (NULL == hosts) goto cleanup; - qsort (hostnames, nhosts, sizeof (hostnames[0]), - (int (*)(const void *, const void *))&strcmp); + qsort (hostnames, nhosts, sizeof (hostnames[0]), cmpstringp); host_list = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host *) * nhosts); for (host = 0; host < nhosts; host++) 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 create_peers (struct RunContext *rc) { struct RunContextOperation *rcop; + struct GNUNET_TESTBED_Host *host; unsigned int peer; +#if ENABLE_LL + struct Island *island; + unsigned int icnt; + unsigned int hcnt; + island = NULL; + icnt = 0; + hcnt = 0; +#endif DEBUG ("Creating peers\n"); rc->pstart_time = GNUNET_TIME_absolute_get (); rc->peers = @@ -827,12 +836,31 @@ create_peers (struct RunContext *rc) { rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); rcop->rc = rc; - rcop->op = - GNUNET_TESTBED_peer_create (rc->c, - (0 == - rc->num_hosts) ? rc->h : rc->hosts[peer % - rc->num_hosts], - rc->cfg, &peer_create_cb, rcop); +#if ENABLE_LL + if (0 != rc->nislands) + { + island = rc->islands[icnt]; + if (hcnt == island->nhosts) + { + icnt++; + if (icnt == rc->nislands) + icnt = 0; + island = rc->islands[icnt]; + hcnt = 0; + } + GNUNET_assert (icnt < rc->nislands); + GNUNET_assert (hcnt < island->nhosts); + GNUNET_assert (NULL != island->hosts[hcnt]); + host = island->hosts[hcnt]; + hcnt++; + } + else + host = rc->h; +#else + host = (0 == rc->num_hosts) ? rc->h : rc->hosts[peer % rc->num_hosts]; +#endif + rcop->op = GNUNET_TESTBED_peer_create (rc->c, host, rc->cfg, + &peer_create_cb, rcop); GNUNET_assert (NULL != rcop->op); insert_rcop (rc, rcop); } @@ -900,7 +928,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) } } if (0 != rc->reg_hosts) - return; + return; rc->state = RC_LINKED; create_peers (rc); #endif @@ -934,6 +962,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) return; rc->state = RC_LINKED; create_peers (rc); + return; default: GNUNET_break (0); shutdown_now (rc); @@ -1180,6 +1209,49 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, } +#if ENABLE_LL +#define ISLANDNAME_SIZE 4 +static void +parse_islands (struct RunContext *rc) +{ + char island_id[ISLANDNAME_SIZE]; + struct GNUNET_TESTBED_Host *host; + struct Island *island; + const char *hostname; + unsigned int nhost; + + DEBUG ("Parsing for islands\n"); + memset (island_id, 0, ISLANDNAME_SIZE); + island = NULL; + for (nhost = 0; nhost < rc->num_hosts; nhost++) + { + host = rc->hosts[nhost]; + hostname = GNUNET_TESTBED_host_get_hostname (host); + GNUNET_assert (NULL != hostname); + if (NULL == island) + { + strncpy (island_id, hostname, ISLANDNAME_SIZE - 1); + island = GNUNET_malloc (sizeof (struct Island)); + } + if (0 == strncmp (island_id, hostname, ISLANDNAME_SIZE - 1)) + { + GNUNET_array_append (island->hosts, island->nhosts, host); + continue; + } + DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts); + GNUNET_array_append (rc->islands, rc->nislands, island); + island = NULL; + } + if (NULL != island) + { + DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts); + GNUNET_array_append (rc->islands, rc->nislands, island); + } + DEBUG ("Total islands parsed: %u\n", rc->nislands); +} +#endif + + /** * Callback function invoked for each interface found. * @@ -1274,6 +1346,7 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host, GNUNET_free (rc->hosts); rc->hosts = NULL; } + parse_islands (rc); GNUNET_OS_network_interfaces_list (netint_proc, rc); if (NULL == rc->trusted_ip) rc->trusted_ip = GNUNET_strdup ("127.0.0.1"); @@ -1310,43 +1383,6 @@ timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } -#if ENABLE_LL -static void -parse_islands (struct RunContext *rc) -{ -#define ISLANDNAME_SIZE 4 - char island_id[ISLANDNAME_SIZE]; - struct GNUNET_TESTBED_Host *host; - struct Island *island; - const char *hostname; - unsigned int nhost; - - memset (island_id, 0, ISLANDNAME_SIZE); - island = NULL; - for (nhost = 0; nhost < rc->num_hosts; nhost++) - { - host = rc->hosts[nhost]; - hostname = GNUNET_TESTBED_host_get_hostname (host); - GNUNET_assert (NULL != hostname); - if (NULL == island) - { - strncpy (island_id, hostname, ISLANDNAME_SIZE - 1); - island = GNUNET_malloc (sizeof (struct Island)); - } - if (0 == strncmp (island_id, hostname, ISLANDNAME_SIZE - 1)) - { - GNUNET_array_append (island->hosts, island->nhosts, host); - continue; - } - DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts); - GNUNET_array_append (rc->islands, rc->nislands, island); - island = NULL; - } - if (NULL != island) - GNUNET_array_append (rc->islands, rc->nislands, island); -} -#endif - /** * Convenience method for running a testbed with * a single call. Underlay and overlay topology @@ -1402,7 +1438,6 @@ GNUNET_TESTBED_run (const char *host_filename, _("No hosts loaded from LoadLeveler. Need at least one host\n")); goto error_cleanup; } - parse_islands (rc); #else if (NULL != host_filename) { -- cgit v1.2.3