gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r27140 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r27140 - gnunet/src/testbed
Date: Wed, 15 May 2013 12:03:38 +0200

Author: harsha
Date: 2013-05-15 12:03:38 +0200 (Wed, 15 May 2013)
New Revision: 27140

Modified:
   gnunet/src/testbed/gnunet_testbed_mpi_spawn.c
   gnunet/src/testbed/testbed_api_hosts.c
   gnunet/src/testbed/testbed_api_testbed.c
Log:
- distribute peers equally among island nodes on SuperMUC


Modified: gnunet/src/testbed/gnunet_testbed_mpi_spawn.c
===================================================================
--- gnunet/src/testbed/gnunet_testbed_mpi_spawn.c       2013-05-15 09:00:26 UTC 
(rev 27139)
+++ gnunet/src/testbed/gnunet_testbed_mpi_spawn.c       2013-05-15 10:03:38 UTC 
(rev 27140)
@@ -56,11 +56,6 @@
 static enum GNUNET_OS_ProcessStatusType child_status;
 
 /**
- * how many IP addresses are currently assigned to us
- */
-static unsigned int num_addrs;
-
-/**
  * The shutdown task
  */
 static GNUNET_SCHEDULER_TaskIdentifier shutdown_task_id;
@@ -196,12 +191,6 @@
   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 @@
   }
   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");

Modified: gnunet/src/testbed/testbed_api_hosts.c
===================================================================
--- gnunet/src/testbed/testbed_api_hosts.c      2013-05-15 09:00:26 UTC (rev 
27139)
+++ gnunet/src/testbed/testbed_api_hosts.c      2013-05-15 10:03:38 UTC (rev 
27140)
@@ -561,6 +561,17 @@
   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 @@
     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);

Modified: gnunet/src/testbed/testbed_api_testbed.c
===================================================================
--- gnunet/src/testbed/testbed_api_testbed.c    2013-05-15 09:00:26 UTC (rev 
27139)
+++ gnunet/src/testbed/testbed_api_testbed.c    2013-05-15 10:03:38 UTC (rev 
27140)
@@ -815,8 +815,17 @@
 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 @@
   {
     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 @@
         }
       }
       if (0 != rc->reg_hosts)
-        return;
+        return;      
       rc->state = RC_LINKED;
       create_peers (rc);
 #endif
@@ -934,6 +962,7 @@
         return;
       rc->state = RC_LINKED;
       create_peers (rc);
+      return;
     default:
       GNUNET_break (0);
       shutdown_now (rc);
@@ -1180,6 +1209,49 @@
 }
 
 
+#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 @@
     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 @@
 }
 
 
-#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 @@
            _("No hosts loaded from LoadLeveler. Need at least one host\n"));
     goto error_cleanup;
   }
-  parse_islands (rc);
 #else
   if (NULL != host_filename)
   {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]