diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-18 23:02:11 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-18 23:02:11 +0000 |
commit | c66253b7387b21d6243bbbbd9829aab61f2b5291 (patch) | |
tree | 1eb82083ac5101331e4c9a34d79b12ae7610b6c9 /src | |
parent | e7e8a8b46aae6e5b704bc2b46df494d08d88798a (diff) | |
download | gnunet-c66253b7387b21d6243bbbbd9829aab61f2b5291.tar.gz gnunet-c66253b7387b21d6243bbbbd9829aab61f2b5291.zip |
parameterized how many failures to tolerate
Diffstat (limited to 'src')
-rw-r--r-- | src/testbed/gnunet-testbed-profiler.c | 74 |
1 files changed, 63 insertions, 11 deletions
diff --git a/src/testbed/gnunet-testbed-profiler.c b/src/testbed/gnunet-testbed-profiler.c index 3a62ee9bd..3e7960481 100644 --- a/src/testbed/gnunet-testbed-profiler.c +++ b/src/testbed/gnunet-testbed-profiler.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #define LOG(kind,...) \ | 35 | #define LOG(kind,...) \ |
36 | GNUNET_log (kind, __VA_ARGS__) | 36 | GNUNET_log (kind, __VA_ARGS__) |
37 | 37 | ||
38 | |||
38 | /** | 39 | /** |
39 | * DLL of operations | 40 | * DLL of operations |
40 | */ | 41 | */ |
@@ -156,6 +157,11 @@ struct GNUNET_TESTBED_Operation *topology_op; | |||
156 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; | 157 | static GNUNET_SCHEDULER_TaskIdentifier abort_task; |
157 | 158 | ||
158 | /** | 159 | /** |
160 | * Shutdown task identifier | ||
161 | */ | ||
162 | static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | ||
163 | |||
164 | /** | ||
159 | * Host registration task identifier | 165 | * Host registration task identifier |
160 | */ | 166 | */ |
161 | static GNUNET_SCHEDULER_TaskIdentifier register_hosts_task; | 167 | static GNUNET_SCHEDULER_TaskIdentifier register_hosts_task; |
@@ -196,6 +202,21 @@ static unsigned int num_hosts; | |||
196 | static unsigned int num_links; | 202 | static unsigned int num_links; |
197 | 203 | ||
198 | /** | 204 | /** |
205 | * Number of timeout failures to tolerate | ||
206 | */ | ||
207 | static unsigned int num_cont_fails; | ||
208 | |||
209 | /** | ||
210 | * Number of times we try overlay connect operations | ||
211 | */ | ||
212 | static unsigned int retry_links; | ||
213 | |||
214 | /** | ||
215 | * Continuous failures during overlay connect operations | ||
216 | */ | ||
217 | static unsigned int cont_fails; | ||
218 | |||
219 | /** | ||
199 | * Global testing status | 220 | * Global testing status |
200 | */ | 221 | */ |
201 | static int result; | 222 | static int result; |
@@ -218,6 +239,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
218 | struct DLLOperation *dll_op; | 239 | struct DLLOperation *dll_op; |
219 | unsigned int nhost; | 240 | unsigned int nhost; |
220 | 241 | ||
242 | shutdown_task = GNUNET_SCHEDULER_NO_TASK; | ||
221 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) | 243 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) |
222 | GNUNET_SCHEDULER_cancel (abort_task); | 244 | GNUNET_SCHEDULER_cancel (abort_task); |
223 | if (GNUNET_SCHEDULER_NO_TASK != register_hosts_task) | 245 | if (GNUNET_SCHEDULER_NO_TASK != register_hosts_task) |
@@ -258,7 +280,9 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
258 | LOG (GNUNET_ERROR_TYPE_WARNING, "Aborting\n"); | 280 | LOG (GNUNET_ERROR_TYPE_WARNING, "Aborting\n"); |
259 | abort_task = GNUNET_SCHEDULER_NO_TASK; | 281 | abort_task = GNUNET_SCHEDULER_NO_TASK; |
260 | result = GNUNET_SYSERR; | 282 | result = GNUNET_SYSERR; |
261 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 283 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) |
284 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
285 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
262 | } | 286 | } |
263 | 287 | ||
264 | 288 | ||
@@ -297,10 +321,11 @@ peer_churn_cb (void *cls, const char *emsg) | |||
297 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 321 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
298 | printf ("%u peers started successfully in %.2f seconds\n", | 322 | printf ("%u peers started successfully in %.2f seconds\n", |
299 | num_peers, ((double) prof_time.rel_value) / 1000.00); | 323 | num_peers, ((double) prof_time.rel_value) / 1000.00); |
324 | fflush (stdout); | ||
300 | result = GNUNET_OK; | 325 | result = GNUNET_OK; |
301 | if (0 == num_links) | 326 | if (0 == num_links) |
302 | { | 327 | { |
303 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 328 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
304 | return; | 329 | return; |
305 | } | 330 | } |
306 | state = STATE_PEERS_LINKING; | 331 | state = STATE_PEERS_LINKING; |
@@ -309,6 +334,7 @@ peer_churn_cb (void *cls, const char *emsg) | |||
309 | topology_op = | 334 | topology_op = |
310 | GNUNET_TESTBED_overlay_configure_topology (NULL, num_peers, peers, | 335 | GNUNET_TESTBED_overlay_configure_topology (NULL, num_peers, peers, |
311 | GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, | 336 | GNUNET_TESTBED_TOPOLOGY_ERDOS_RENYI, |
337 | |||
312 | num_links); | 338 | num_links); |
313 | } | 339 | } |
314 | } | 340 | } |
@@ -353,6 +379,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
353 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 379 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); |
354 | printf ("%u peers created successfully in %.2f seconds\n", | 380 | printf ("%u peers created successfully in %.2f seconds\n", |
355 | num_peers, ((double) prof_time.rel_value) / 1000.00); | 381 | num_peers, ((double) prof_time.rel_value) / 1000.00); |
382 | fflush (stdout); | ||
356 | /* Now peers are to be started */ | 383 | /* Now peers are to be started */ |
357 | state = STATE_PEERS_STARTING; | 384 | state = STATE_PEERS_STARTING; |
358 | prof_start_time = GNUNET_TIME_absolute_get (); | 385 | prof_start_time = GNUNET_TIME_absolute_get (); |
@@ -368,6 +395,21 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
368 | 395 | ||
369 | 396 | ||
370 | /** | 397 | /** |
398 | * Function to print summary about how many overlay links we have made and how | ||
399 | * many failed | ||
400 | */ | ||
401 | static void | ||
402 | print_overlay_links_summary () | ||
403 | { | ||
404 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | ||
405 | printf ("\n%u links established in %.2f seconds\n", | ||
406 | num_links, ((double) prof_time.rel_value) / 1000.00); | ||
407 | printf ("Overlay link operations have been retried %u times upon timeouts\n", | ||
408 | retry_links); | ||
409 | } | ||
410 | |||
411 | |||
412 | /** | ||
371 | * Controller event callback | 413 | * Controller event callback |
372 | * | 414 | * |
373 | * @param cls NULL | 415 | * @param cls NULL |
@@ -408,6 +450,7 @@ controller_event_cb (void *cls, | |||
408 | if (++slaves_started == num_hosts - 1) | 450 | if (++slaves_started == num_hosts - 1) |
409 | { | 451 | { |
410 | printf ("%u controllers started successfully\n", num_hosts); | 452 | printf ("%u controllers started successfully\n", num_hosts); |
453 | fflush (stdout); | ||
411 | state = STATE_PEERS_CREATING; | 454 | state = STATE_PEERS_CREATING; |
412 | prof_start_time = GNUNET_TIME_absolute_get (); | 455 | prof_start_time = GNUNET_TIME_absolute_get (); |
413 | peers = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) | 456 | peers = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) |
@@ -452,27 +495,33 @@ controller_event_cb (void *cls, | |||
452 | { | 495 | { |
453 | LOG (GNUNET_ERROR_TYPE_WARNING, | 496 | LOG (GNUNET_ERROR_TYPE_WARNING, |
454 | _("An operation has failed while linking\n")); | 497 | _("An operation has failed while linking\n")); |
455 | /* GNUNET_SCHEDULER_cancel (abort_task); */ | ||
456 | /* abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); */ | ||
457 | printf ("F"); | 498 | printf ("F"); |
458 | fflush (stdout); | 499 | fflush (stdout); |
500 | retry_links++; | ||
501 | if (++cont_fails > num_cont_fails) | ||
502 | { | ||
503 | printf ("\nAborting due to very high failure rate"); | ||
504 | print_overlay_links_summary (); | ||
505 | GNUNET_SCHEDULER_cancel (abort_task); | ||
506 | abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); | ||
507 | } | ||
459 | } | 508 | } |
460 | break; | 509 | break; |
461 | case GNUNET_TESTBED_ET_CONNECT: | 510 | case GNUNET_TESTBED_ET_CONNECT: |
462 | { | 511 | { |
463 | static unsigned int established_links; | 512 | static unsigned int established_links; |
464 | 513 | ||
514 | if (0 != cont_fails) | ||
515 | cont_fails--; | ||
465 | if (0 == established_links) | 516 | if (0 == established_links) |
466 | printf ("Establishing links. Please wait\n"); | 517 | printf ("Establishing links. Please wait\n"); |
467 | printf ("."); | 518 | printf ("."); |
468 | fflush (stdout); | 519 | fflush (stdout); |
469 | if (++established_links == num_links) | 520 | if (++established_links == num_links) |
470 | { | 521 | { |
471 | prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); | 522 | print_overlay_links_summary (); |
472 | printf ("\n%u links established in %.2f seconds\n", | ||
473 | num_links, ((double) prof_time.rel_value) / 1000.00); | ||
474 | result = GNUNET_OK; | 523 | result = GNUNET_OK; |
475 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 524 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
476 | } | 525 | } |
477 | } | 526 | } |
478 | break; | 527 | break; |
@@ -632,14 +681,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
632 | if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost])) | 681 | if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost])) |
633 | { | 682 | { |
634 | fprintf (stderr, _("Host %s cannot start testbed\n"), | 683 | fprintf (stderr, _("Host %s cannot start testbed\n"), |
635 | GNUNET_TESTBED_host_get_hostname_ (hosts[nhost])); | 684 | GNUNET_TESTBED_host_get_hostname_ (hosts[nhost])); |
636 | break; | 685 | break; |
637 | } | 686 | } |
638 | } | 687 | } |
639 | if (num_hosts != nhost) | 688 | if (num_hosts != nhost) |
640 | { | 689 | { |
641 | fprintf (stderr, _("Exiting\n")); | 690 | fprintf (stderr, _("Exiting\n")); |
642 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 691 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
643 | return; | 692 | return; |
644 | } | 693 | } |
645 | cfg = GNUNET_CONFIGURATION_dup (config); | 694 | cfg = GNUNET_CONFIGURATION_dup (config); |
@@ -672,6 +721,9 @@ main (int argc, char *const *argv) | |||
672 | { 'n', "num-links", "COUNT", | 721 | { 'n', "num-links", "COUNT", |
673 | gettext_noop ("create COUNT number of random links"), | 722 | gettext_noop ("create COUNT number of random links"), |
674 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_links }, | 723 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_links }, |
724 | { 'e', "num-errors", "COUNT", | ||
725 | gettext_noop ("tolerate COUNT number of continious timeout failures"), | ||
726 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_cont_fails }, | ||
675 | GNUNET_GETOPT_OPTION_END | 727 | GNUNET_GETOPT_OPTION_END |
676 | }; | 728 | }; |
677 | int ret; | 729 | int ret; |