static unsigned int num_links;
/**
- * Number of times we try overlay connect operations
+ * Number of connect operations that have failed, candidates to retry
*/
static unsigned int retry_links;
-/**
- * Continuous failures during overlay connect operations
- */
-static unsigned int cont_fails;
-
/**
* Global testing status
*/
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"String matching timed out for string %s on peer %u (%i/%i)\n",
peer->search_str, peer->id, peers_found, num_search_strings);
-
- printf ("String matching timed out for string %s on peer %u (%i/%i)\n",
- peer->search_str, peer->id, peers_found, num_search_strings);
-
peer->search_str_matched = GNUNET_SYSERR;
}
else
{
prof_time = GNUNET_TIME_absolute_get_duration (peer->prof_start_time);
- printf ("String %s successfully matched on peer %u after %s (%i/%i) (%u||)\n",
- peer->search_str, peer->id, GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
- peers_found, num_search_strings, parallel_searches);
- fflush (stdout);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "String %s found on peer %u after %s (%i/%i) (%u||)\n",
+ peer->search_str, peer->id,
+ GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
+ peers_found, num_search_strings, parallel_searches);
peer->search_str_matched = GNUNET_YES;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"All strings successfully matched in %s\n",
GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
- printf ("All strings successfully matched.\n");
- fflush (stdout);
if (GNUNET_SCHEDULER_NO_TASK != search_timeout_task)
GNUNET_SCHEDULER_cancel (search_timeout_task);
- printf ("Collecting stats and shutting down.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Collecting stats and shutting down.\n");
GNUNET_SCHEDULER_add_now (&do_collect_stats, NULL);
}
}
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.\n",
+ p->search_str,
+ p->id);
GNUNET_SCHEDULER_add_now (&find_next_string, NULL);
}
}
+
+/**
+ * Start announcing the next regex in the DHT.
+ *
+ * @param cls Index of the next peer in the peers array.
+ * @param tc TaskContext.
+ */
+void
+announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+
/**
* ARM connect adapter. Opens a connection to the ARM service.
*
{
struct RegexPeer *peer = cls;
- peer->arm_handle = GNUNET_ARM_connect (cfg, NULL);
+ peer->arm_handle = GNUNET_ARM_alloc (cfg);
+ GNUNET_ARM_connect (peer->arm_handle, NULL, NULL);
return peer->arm_handle;
}
}
}
-
-/**
- * Start announcing the next regex in the DHT.
- *
- * @param cls Index of the next peer in the peers array.
- * @param tc TaskContext.
- */
-void
-announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
-
-
-/**
- * Callback function invoked when ARM peration is complete: deamon is started.
- *
- * @param cls Closure (RegexPeer).
- * @param result Outcome of the operation.
- */
static void
-arm_start_cb (void *cls, enum GNUNET_ARM_ProcessStatus result)
+regexprofiler_start_cb (void *cls, struct GNUNET_ARM_Handle *arm,
+ enum GNUNET_ARM_RequestStatus rs, const char *service,
+ enum GNUNET_ARM_Result result)
{
struct RegexPeer *peer = (struct RegexPeer *) cls;
- static unsigned int peer_cnt;
unsigned int next_p;
- switch (result)
+ if (rs != GNUNET_ARM_REQUEST_SENT_OK)
{
- /**
- * Service is currently being started (due to client request).
- */
- case GNUNET_ARM_PROCESS_STARTING:
- GNUNET_TESTBED_operation_done (peer->op_handle);
- peer->op_handle = NULL;
-
- if (peer_cnt < (num_peers - 1))
- {
- next_p = (++peer_cnt % num_peers);
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
- GNUNET_TIME_UNIT_MILLISECONDS,
- 400),
- &announce_next_regex,
- (void *) (long) next_p);
- }
- else
- {
- printf ("All daemons started. Waiting %s to start string searches\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "ARM request was not sent: %u\n", rs);
+ GNUNET_abort ();
+ }
+ else if (result != GNUNET_ARM_RESULT_STARTING)
+ {
+ /* FIXME: maybe check for other acceptable results (already starting,
+ * already started)?
+ */
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "ARM failed to start regexprofiler: %u\n", result);
+ GNUNET_abort ();
+ }
+ GNUNET_TESTBED_operation_done (peer->op_handle);
+ peer->op_handle = NULL;
+
+ if (peer_cnt < (num_peers - 1))
+ {
+ next_p = (++peer_cnt % num_peers);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(
+ GNUNET_TIME_UNIT_MILLISECONDS,
+ 400),
+ &announce_next_regex,
+ (void *) (long) next_p);
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "All daemons started."
+ " Waiting %s to start string searches\n",
GNUNET_STRINGS_relative_time_to_string (search_delay,
GNUNET_NO));
- fflush (stdout);
- GNUNET_SCHEDULER_add_delayed (search_delay,
- do_connect_by_string,
- NULL);
- }
- break;
-
- /**
- * Service name is unknown to ARM.
- */
- case GNUNET_ARM_PROCESS_UNKNOWN:
- /**
- * Service is now down (due to client request).
- */
- case GNUNET_ARM_PROCESS_DOWN:
- /**
- * Service is already running.
- */
- case GNUNET_ARM_PROCESS_ALREADY_RUNNING:
- /**
- * Service is already being stopped by some other client.
- */
- case GNUNET_ARM_PROCESS_ALREADY_STOPPING:
- /**
- * Service is already down (no action taken)
- */
- case GNUNET_ARM_PROCESS_ALREADY_DOWN:
- /**
- * ARM is currently being shut down (no more process starts)
- */
- case GNUNET_ARM_PROCESS_SHUTDOWN:
- /**
- * Error in communication with ARM
- */
- case GNUNET_ARM_PROCESS_COMMUNICATION_ERROR:
- /**
- * Timeout in communication with ARM
- */
- case GNUNET_ARM_PROCESS_COMMUNICATION_TIMEOUT:
- /**
- * Failure to perform operation
- */
- case GNUNET_ARM_PROCESS_FAILURE:
- default:
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "ARM returned %d\n", result);
- GNUNET_abort ();
+ GNUNET_SCHEDULER_add_delayed (search_delay,
+ do_connect_by_string,
+ NULL);
}
}
-
/**
* ARM connect callback. Called when we are connected to the arm service for
* the peer in 'cls'. If successfull we start the regex deamon to start
GNUNET_assert (peer->op_handle == op);
GNUNET_assert (peer->arm_handle == ca_result);
- GNUNET_ARM_start_service (ca_result, "regexprofiler",
- GNUNET_OS_INHERIT_STD_NONE,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &arm_start_cb,
- peer);
+ GNUNET_ARM_request_service_start (ca_result, "regexprofiler",
+ GNUNET_OS_INHERIT_STD_NONE,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ regexprofiler_start_cb, cls);
}
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
- printf ("Starting daemon %ld\n", next_p);
- fflush (stdout);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting daemon %ld\n", next_p);
peers[next_p].op_handle =
GNUNET_TESTBED_service_connect (NULL,
if (++started_peers == num_peers)
{
prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
- printf("All peers started successfully in %s\n",
- GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "All peers started successfully in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
result = GNUNET_OK;
peer_handles = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * num_peers);
if (++created_peers == num_peers)
{
prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
- printf ("All peers created successfully in %s\n",
- GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "All peers created successfully in %s\n",
+ GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
/* Now peers are to be started */
state = STATE_PEERS_STARTING;
prof_start_time = GNUNET_TIME_absolute_get ();
/* Control reaches here when a peer linking operation fails */
if (NULL != event->details.operation_finished.emsg)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("An operation has failed while linking\n"));
- printf ("F%u/%u ", retry_links + 1, established_links + 1);
- printf ("\n%s\n ", event->details.operation_finished.emsg);
- fflush (stdout);
+ printf ("F%u/%u(%s)",
+ retry_links + 1, established_links + 1,
+ event->details.operation_finished.emsg);
retry_links++;
}
/* We do no retries, consider this link as established */
/* break; */
case GNUNET_TESTBED_ET_CONNECT:
{
- char output_buffer[512];
+ char output_buffer[1024];
size_t size;
if (0 == established_links)
- printf ("Establishing links .");
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Establishing links .");
else
{
printf (".");
- fflush (stdout);
}
if (++established_links == num_links)
{
- fflush (stdout);
prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
- printf ("\n%u links established in %s\n",
- num_links,
- GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "\n%u links established in %s\n",
+ num_links,
+ GNUNET_STRINGS_relative_time_to_string (prof_time,
+ GNUNET_NO));
prof_time = GNUNET_TIME_relative_divide(prof_time, num_links);
- printf ("Average of %s per connection\n",
- GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Average of %s per connection\n",
+ GNUNET_STRINGS_relative_time_to_string (prof_time,
+ GNUNET_NO));
result = GNUNET_OK;
GNUNET_free (peer_handles);
GNUNET_snprintf (output_buffer,
sizeof (output_buffer),
"# of peers: %u\n# of links established: %u\n"
- "Time to establish links: %s\nLinking failures: %u\n"
- "path compression length: %u\n# of search strings: %u\n",
+ "Time to establish links: %s\n"
+ "Linking failures: %u\n"
+ "path compression length: %u\n"
+ "# of search strings: %u\n",
num_peers,
- (established_links - cont_fails),
- GNUNET_STRINGS_relative_time_to_string (prof_time, GNUNET_NO),
- cont_fails,
+ (established_links - retry_links),
+ GNUNET_STRINGS_relative_time_to_string (prof_time,
+ GNUNET_NO),
+ retry_links,
max_path_compression,
num_search_strings);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n");
}
- printf ("\nWaiting %s before starting to announce.\n",
- GNUNET_STRINGS_relative_time_to_string (search_delay, GNUNET_NO));
- fflush (stdout);
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "\nWaiting %s before starting to announce.\n",
+ GNUNET_STRINGS_relative_time_to_string (search_delay,
+ GNUNET_NO));
state = STATE_SEARCH_REGEX;
-
search_task = GNUNET_SCHEDULER_add_delayed (search_delay,
&do_announce, NULL);
}
if (GNUNET_OK != status)
{
mc_proc = NULL;
- printf("Oh, dear!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Oh, dear!\n");
abort_task = GNUNET_SCHEDULER_add_now (&do_abort, (void*) __LINE__);
return;
}
if (NULL == args[0])
{
- fprintf (stderr, _("No hosts-file specified on command line. Exiting.\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("No hosts-file specified on command line. Exiting.\n"));
return;
}
if (NULL == args[1])
{
- fprintf (stderr, _("No policy directory specified on command line. Exiting.\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("No policy directory specified on command line. Exiting.\n"));
return;
}
num_hosts = GNUNET_TESTBED_hosts_load_from_file (args[0], config, &hosts);
if (0 == num_hosts)
{
- fprintf (stderr, _("No hosts loaded. Need at least one host\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("No hosts loaded. Need at least one host\n"));
return;
}
- printf (_("Checking whether given hosts can start testbed. Please wait\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Checking whether given hosts can start testbed."
+ "Please wait\n"));
hc_handles = GNUNET_malloc (sizeof (struct
GNUNET_TESTBED_HostHabitableCheckHandle *)
* num_hosts);
}
if (num_hosts != nhost)
{
- fprintf (stderr, _("Exiting\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Exiting\n"));
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
if (NULL == config)
{
- fprintf (stderr, _("No configuration file given. Exiting\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("No configuration file given. Exiting\n"));
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", "REGEX_PREFIX",
®ex_prefix))
{
- fprintf (stderr, _("Configuration option (regex_prefix) missing. Exiting\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Configuration option \"regex_prefix\" missing. Exiting\n"));
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
data_filename);
if (GNUNET_YES != GNUNET_DISK_directory_test (args[1], GNUNET_YES))
{
- fprintf (stderr, _("Specified policies directory does not exist. Exiting.\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Specified policies directory does not exist. Exiting.\n"));
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
policy_dir = args[1];
if (GNUNET_YES != GNUNET_DISK_file_test (args[2]))
{
- fprintf (stderr, _("No search strings file given. Exiting.\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("No search strings file given. Exiting.\n"));
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
if (num_search_strings != nsearchstrs)
{
num_search_strings = nsearchstrs;
- fprintf (stderr, _("Error loading search strings. Given file does not contain enough strings. Exiting.\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error loading search strings."
+ "Given file does not contain enough strings. Exiting.\n"));
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}
if (0 >= num_search_strings || NULL == search_strings)
{
- fprintf (stderr, _("Error loading search strings. Exiting.\n"));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Error loading search strings. Exiting.\n"));
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
return;
}