#include "platform.h"
#include "gnunet_applications.h"
#include "gnunet_util_lib.h"
-#include "gnunet_regex_lib.h"
+#include "regex_internal_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_dht_service.h"
#include "gnunet_testbed_service.h"
/**
* Handle to a running regex search.
*/
- struct GNUNET_REGEX_search_handle *search_handle;
+ struct REGEX_INTERNAL_Search *search_handle;
/**
* Testbed operation handle for DHT.
*/
struct GNUNET_STATISTICS_Handle *stats_handle;
- /**
- * Testbed operation handle for the statistics service.
- */
- struct GNUNET_TESTBED_Operation *stats_op_handle;
-
/**
* The starting time of a profiling step.
*/
const char *emsg);
-/**
- * Task to collect all statistics from s, will shutdown the
- * profiler, when done.
- *
- * @param cls NULL
- * @param tc the task context
- */
-static void
-do_collect_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
-
-
/**
* Start announcing the next regex in the DHT.
*
if (NULL != peers[peer_cnt].op_handle)
GNUNET_TESTBED_operation_done (peers[peer_cnt].op_handle);
- if (NULL != peers[peer_cnt].stats_op_handle)
- GNUNET_TESTBED_operation_done (peers[peer_cnt].stats_op_handle);
}
if (NULL != data_file)
return;
}
- GNUNET_assert (NULL != peer->stats_op_handle);
+ GNUNET_assert (NULL != peer->op_handle);
- GNUNET_TESTBED_operation_done (peer->stats_op_handle);
- peer->stats_op_handle = NULL;
+ GNUNET_TESTBED_operation_done (peer->op_handle);
+ peer->op_handle = NULL;
peer_cnt++;
peer = &peers[peer_cnt];
+ fprintf (stderr, "s");
if (peer_cnt == num_peers)
{
struct GNUNET_TIME_Relative delay = { 100 };
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "\nCollecting stats finished. Shutting down.\n");
shutdown_task = GNUNET_SCHEDULER_add_delayed (delay, &do_shutdown, NULL);
+ result = GNUNET_OK;
}
else
{
- peer->stats_op_handle =
+ peer->op_handle =
GNUNET_TESTBED_service_connect (NULL,
peer->peer_handle,
"statistics",
GNUNET_assert (NULL != peer->peer_handle);
- peer->stats_op_handle =
+ peer->op_handle =
GNUNET_TESTBED_service_connect (NULL,
peer->peer_handle,
"statistics",
* Method called when we've found a peer that announced a regex
* that matches our search string. Now get the statistics.
*
- * @param cls Closure provided in GNUNET_REGEX_search.
+ * @param cls Closure provided in REGEX_INTERNAL_search.
* @param id Peer providing a regex that matches the string.
* @param get_path Path of the get request.
* @param get_path_length Lenght of get_path.
if (GNUNET_YES == peer->search_str_matched)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"String %s on peer %u already matched!\n",
peer->search_str, peer->id);
return;
GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task)
+ {
GNUNET_SCHEDULER_cancel (search_timeout_task);
+ search_timeout_task = GNUNET_SCHEDULER_NO_TASK;
+ }
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats and shutting down.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats.\n");
GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL);
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Search timed out after %s."
- "Collecting stats and shutting down.\n",
+ "Collecting stats and shutting down.\n",
GNUNET_STRINGS_relative_time_to_string (search_timeout_time,
GNUNET_NO));
if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
return;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Searching for string \"%s\" on peer %d timed out."
- "Starting new search: %d.\n",
+ "Searching for string \"%s\" on peer %d timed out.\n",
p->search_str,
- p->id,
- !in_shutdown);
+ p->id);
if (GNUNET_NO == in_shutdown)
GNUNET_SCHEDULER_add_now (&announce_next_regex, NULL);
}
unsigned int search_peer = (unsigned int) (long) cls;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) ||
- search_peer >= num_peers)
+ search_peer >= num_peers ||
+ GNUNET_YES == in_shutdown)
return;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
struct RegexPeer *peer = (struct RegexPeer *) cls;
unsigned long search_peer;
unsigned int i;
- unsigned int me;
GNUNET_TESTBED_operation_done (peer->daemon_op);
peer->daemon_op = NULL;
- me = peer - peers;
if (NULL != emsg)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Failed to start/stop daemon at peer %u: %s\n", me, emsg);
+ "Failed to start/stop daemon at peer %u: %s\n", peer->id, emsg);
GNUNET_abort ();
}
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Deamon %u started successfully\n", peer->id);
+ }
/* Find a peer to look for a string matching the regex announced */
search_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
if (i > num_peers)
GNUNET_abort (); /* we ran out of peers, must be a bug */
}
- peers[search_peer].search_str = search_strings[me];
+ peers[search_peer].search_str = search_strings[peer->id];
peers[search_peer].search_str_matched = GNUNET_NO;
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
reannounce_period_max,
{
struct RegexPeer *peer;
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) ||
- next_search >= num_peers)
+ if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
+ if (next_search >= num_peers)
+ {
+ if (strings_found != num_peers)
+ {
+ struct GNUNET_TIME_Relative new_delay;
+ if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task)
+ GNUNET_SCHEDULER_cancel (search_timeout_task);
+ new_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15);
+ search_timeout_task = GNUNET_SCHEDULER_add_delayed (new_delay,
+ &search_timed_out,
+ NULL);
+ }
+ return;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %u\n", next_search);
peer = &peers[next_search];
- peer->daemon_op =
+ peer->daemon_op =
GNUNET_TESTBED_peer_manage_service (NULL,
peer->peer_handle,
"regexprofiler",
GNUNET_assert (peer->dht_handle == ca_result);
peer->search_str_matched = GNUNET_NO;
- peer->search_handle = GNUNET_REGEX_search (peer->dht_handle,
+ peer->search_handle = REGEX_INTERNAL_search (peer->dht_handle,
peer->search_str,
®ex_found_handler, peer,
NULL);
if (NULL != peer->search_handle)
{
- GNUNET_REGEX_search_cancel (peer->search_handle);
+ REGEX_INTERNAL_search_cancel (peer->search_handle);
peer->search_handle = NULL;
}
* Signature of a main function for a testcase.
*
* @param cls NULL
+ * @param h the run handle
* @param num_peers_ number of peers in 'peers'
- * @param peers handle to peers run in the testbed. NULL upon timeout (see
+ * @param testbed_peers handle to peers run in the testbed. NULL upon timeout (see
* GNUNET_TESTBED_test_run()).
* @param links_succeeded the number of overlay link connection attempts that
* succeeded
* @param links_failed the number of overlay link connection attempts that
* failed
*/
-static void
+static void
test_master (void *cls,
+ struct GNUNET_TESTBED_RunHandle *h,
unsigned int num_peers_,
struct GNUNET_TESTBED_Peer **testbed_peers,
unsigned int links_succeeded,
{
peers[i].peer_handle = testbed_peers[i];
}
- GNUNET_SCHEDULER_add_now (&do_announce, NULL);
+ if (GNUNET_NO ==
+ GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", "DISABLE_TRY_CONNECT"))
+ {
+ struct GNUNET_TIME_Relative settle_time;
+
+ settle_time =
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
+ 10 * num_peers);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Waiting for DHT for %s to settle new connections.\n\n",
+ GNUNET_STRINGS_relative_time_to_string(settle_time, GNUNET_NO));
+ GNUNET_SCHEDULER_add_delayed (settle_time, &do_announce, NULL);
+ }
+ else
+ {
+ GNUNET_SCHEDULER_add_now (&do_announce, NULL);
+ }
search_timeout_task =
GNUNET_SCHEDULER_add_delayed (search_timeout_time, &search_timed_out, NULL);
}
* @param event information on what is happening
*/
static void
-master_controller_cb (void *cls,
+master_controller_cb (void *cls,
const struct GNUNET_TESTBED_EventInformation *event)
{
switch (event->type)
{
unsigned int nsearchstrs;
unsigned int i;
+ struct GNUNET_TIME_Relative abort_time;
in_shutdown = GNUNET_NO;
"REANNOUNCE_PERIOD_MAX",
&reannounce_period_max))
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"reannounce_period_max not given. Using 10 minutes.\n");
reannounce_period_max =
GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10);
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
- if (-1 == (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL, NULL)))
+ if (0 >= (int) (num_peers = GNUNET_DISK_directory_scan (policy_dir, NULL, NULL)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("No files found in `%s'\n"),
if (num_peers != nsearchstrs)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Error loading search strings."
- "Given file does not contain enough strings. Exiting.\n"));
+ "Error loading search strings.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "File (%s) does not contain enough strings (%u/%u).\n",
+ strings_file, nsearchstrs, num_peers);
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
- if (0 >= num_peers || NULL == search_strings)
+ if ( (0 == num_peers) || (NULL == search_strings))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Error loading search strings. Exiting.\n"));
/* Initialize peers */
peers = GNUNET_malloc (sizeof (struct RegexPeer) * num_peers);
for (i = 0; i < num_peers; i++)
- {
peers[i].id = i;
- }
+ GNUNET_CONFIGURATION_set_value_number (cfg,
+ "TESTBED", "OVERLAY_RANDOM_LINKS",
+ num_peers * 20);
+ GNUNET_CONFIGURATION_set_value_number (cfg,
+ "DHT", "FORCE_NSE",
+ (long long unsigned)
+ (log (num_peers) / log (2.0)));
event_mask = 0LL;
/* For feedback about the start process activate these and pass master_cb */
event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START);
NULL, /* master_controller_cb cls */
&test_master,
NULL); /* test_master cls */
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_time (cfg, "TESTBED",
+ "SETUP_TIMEOUT",
+ &abort_time))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "SETUP_TIMEOUT not given. Using 15 minutes.\n");
+ abort_time =
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15);
+ }
+ abort_time = GNUNET_TIME_relative_add (abort_time, GNUNET_TIME_UNIT_MINUTES);
abort_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_MINUTES, 15),
+ GNUNET_SCHEDULER_add_delayed (abort_time,
&do_abort,
(void*) __LINE__);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "setup_timeout: %s\n",
+ GNUNET_STRINGS_relative_time_to_string (abort_time, GNUNET_YES));
}
GNUNET_YES, &GNUNET_GETOPT_set_filename, &strings_file},
{'H', "hosts-file", "FILENAME",
gettext_noop ("name of file with hosts' names"),
- GNUNET_NO, &GNUNET_GETOPT_set_filename, &hosts_file},
+ GNUNET_YES, &GNUNET_GETOPT_set_filename, &hosts_file},
GNUNET_GETOPT_OPTION_END
};
int ret;