diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-11 13:28:06 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-02-11 13:28:06 +0000 |
commit | a5b4af52529d598adc78ae86621f8803d12eef8f (patch) | |
tree | 4a99ade1ed3571ac8044db9e2d698001df7efe41 /src/ats/gnunet-ats-solver-eval.c | |
parent | 10bc3b99a7d8a19d8a924e93da842c1aba40cfe4 (diff) | |
download | gnunet-a5b4af52529d598adc78ae86621f8803d12eef8f.tar.gz gnunet-a5b4af52529d598adc78ae86621f8803d12eef8f.zip |
properties
Diffstat (limited to 'src/ats/gnunet-ats-solver-eval.c')
-rw-r--r-- | src/ats/gnunet-ats-solver-eval.c | 105 |
1 files changed, 52 insertions, 53 deletions
diff --git a/src/ats/gnunet-ats-solver-eval.c b/src/ats/gnunet-ats-solver-eval.c index 0e0c5bb9f..234492962 100644 --- a/src/ats/gnunet-ats-solver-eval.c +++ b/src/ats/gnunet-ats-solver-eval.c | |||
@@ -274,7 +274,8 @@ set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
274 | { | 274 | { |
275 | GNUNET_break (0); | 275 | GNUNET_break (0); |
276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 276 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
277 | "Setting property generation for unknown address %u\n", pg->address_id); | 277 | "Setting property generation for unknown address [%u:%u]\n", |
278 | pg->peer, pg->address_id); | ||
278 | return; | 279 | return; |
279 | } | 280 | } |
280 | 281 | ||
@@ -286,8 +287,8 @@ set_prop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
286 | GNUNET_ATS_print_property_type (pg->ats_property), pref_value); | 287 | GNUNET_ATS_print_property_type (pg->ats_property), pref_value); |
287 | 288 | ||
288 | 289 | ||
289 | atsi.type = pg->ats_property; | 290 | atsi.type = htonl (pg->ats_property); |
290 | atsi.value = (uint32_t) pref_value; | 291 | atsi.value = htonl ((uint32_t) pref_value); |
291 | 292 | ||
292 | /* set performance here! */ | 293 | /* set performance here! */ |
293 | sh->env.sf.s_bulk_start (sh->solver); | 294 | sh->env.sf.s_bulk_start (sh->solver); |
@@ -701,8 +702,6 @@ create_experiment () | |||
701 | struct Experiment *e; | 702 | struct Experiment *e; |
702 | e = GNUNET_new (struct Experiment); | 703 | e = GNUNET_new (struct Experiment); |
703 | e->name = NULL; | 704 | e->name = NULL; |
704 | e->num_masters = 0; | ||
705 | e->num_slaves = 0; | ||
706 | e->start = NULL; | 705 | e->start = NULL; |
707 | e->total_duration = GNUNET_TIME_UNIT_ZERO; | 706 | e->total_duration = GNUNET_TIME_UNIT_ZERO; |
708 | return e; | 707 | return e; |
@@ -1545,6 +1544,7 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1545 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, | 1544 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, |
1546 | sec_name, "duration", &e_duration)) | 1545 | sec_name, "duration", &e_duration)) |
1547 | { | 1546 | { |
1547 | fprintf (stderr, "Missing duration in episode %u \n",e_counter); | ||
1548 | GNUNET_free (sec_name); | 1548 | GNUNET_free (sec_name); |
1549 | break; | 1549 | break; |
1550 | } | 1550 | } |
@@ -1571,7 +1571,7 @@ load_episodes (struct Experiment *e, struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1571 | if (NULL == last) | 1571 | if (NULL == last) |
1572 | e->start = cur; | 1572 | e->start = cur; |
1573 | else | 1573 | else |
1574 | last->next = cur; | 1574 | last->next = cur; |
1575 | 1575 | ||
1576 | GNUNET_free (sec_name); | 1576 | GNUNET_free (sec_name); |
1577 | e_counter ++; | 1577 | e_counter ++; |
@@ -2018,28 +2018,6 @@ GNUNET_ATS_solvers_experimentation_load (char *filename) | |||
2018 | 2018 | ||
2019 | } | 2019 | } |
2020 | 2020 | ||
2021 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | ||
2022 | "masters", &e->num_masters)) | ||
2023 | { | ||
2024 | fprintf (stderr, "Invalid %s", "masters"); | ||
2025 | free_experiment (e); | ||
2026 | return NULL; | ||
2027 | } | ||
2028 | else | ||
2029 | fprintf (stderr, "Experiment masters: `%llu'\n", | ||
2030 | e->num_masters); | ||
2031 | |||
2032 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number(cfg, "experiment", | ||
2033 | "slaves", &e->num_slaves)) | ||
2034 | { | ||
2035 | fprintf (stderr, "Invalid %s", "slaves"); | ||
2036 | free_experiment (e); | ||
2037 | return NULL; | ||
2038 | } | ||
2039 | else | ||
2040 | fprintf (stderr, "Experiment slaves: `%llu'\n", | ||
2041 | e->num_slaves); | ||
2042 | |||
2043 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", | 2021 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time(cfg, "experiment", |
2044 | "log_freq", &e->log_freq)) | 2022 | "log_freq", &e->log_freq)) |
2045 | { | 2023 | { |
@@ -2078,16 +2056,31 @@ GNUNET_ATS_solvers_experimentation_load (char *filename) | |||
2078 | return e; | 2056 | return e; |
2079 | } | 2057 | } |
2080 | 2058 | ||
2059 | |||
2060 | |||
2081 | /** | 2061 | /** |
2082 | * Solver | 2062 | * Solver |
2083 | */ | 2063 | */ |
2084 | 2064 | ||
2065 | static int | ||
2066 | free_all_it (void *cls, | ||
2067 | const struct GNUNET_PeerIdentity *key, | ||
2068 | void *value) | ||
2069 | { | ||
2070 | struct ATS_Address *address = value; | ||
2071 | GNUNET_CONTAINER_multipeermap_remove (sh->env.addresses, key, value); | ||
2072 | GNUNET_free (address); | ||
2073 | |||
2074 | return GNUNET_OK; | ||
2075 | } | ||
2076 | |||
2085 | void | 2077 | void |
2086 | GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh) | 2078 | GNUNET_ATS_solvers_solver_stop (struct SolverHandle *sh) |
2087 | { | 2079 | { |
2088 | GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) sh->env.stats, | 2080 | GNUNET_STATISTICS_destroy ((struct GNUNET_STATISTICS_Handle *) sh->env.stats, |
2089 | GNUNET_NO); | 2081 | GNUNET_NO); |
2090 | GNUNET_PLUGIN_unload (sh->plugin, sh->solver); | 2082 | GNUNET_PLUGIN_unload (sh->plugin, sh->solver); |
2083 | GNUNET_CONTAINER_multipeermap_iterate (sh->addresses, &free_all_it, NULL); | ||
2091 | GNUNET_CONTAINER_multipeermap_destroy(sh->addresses); | 2084 | GNUNET_CONTAINER_multipeermap_destroy(sh->addresses); |
2092 | GNUNET_free (sh->plugin); | 2085 | GNUNET_free (sh->plugin); |
2093 | GNUNET_free (sh); | 2086 | GNUNET_free (sh); |
@@ -2330,10 +2323,15 @@ get_property_cb (void *cls, const struct ATS_Address *address) | |||
2330 | } | 2323 | } |
2331 | 2324 | ||
2332 | static void | 2325 | static void |
2333 | normalized_property_changed_cb (void *cls, struct ATS_Address *peer, | 2326 | normalized_property_changed_cb (void *cls, struct ATS_Address *address, |
2334 | uint32_t type, double prop_rel) | 2327 | uint32_t type, double prop_rel) |
2335 | { | 2328 | { |
2336 | /* TODO */ | 2329 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
2330 | "Normalized property %s for peer `%s' changed to %.3f \n", | ||
2331 | GNUNET_ATS_print_property_type (type), GNUNET_i2s (&address->peer), | ||
2332 | prop_rel); | ||
2333 | |||
2334 | sh->env.sf.s_address_update_property (sh->solver, address, type, 0, prop_rel); | ||
2337 | } | 2335 | } |
2338 | 2336 | ||
2339 | 2337 | ||
@@ -2402,27 +2400,25 @@ GNUNET_ATS_solvers_solver_start (enum GNUNET_ATS_Solvers type) | |||
2402 | return sh; | 2400 | return sh; |
2403 | } | 2401 | } |
2404 | 2402 | ||
2405 | static int | ||
2406 | free_all_it (void *cls, | ||
2407 | const struct GNUNET_PeerIdentity *key, | ||
2408 | void *value) | ||
2409 | { | ||
2410 | struct ATS_Address *address = value; | ||
2411 | GNUNET_CONTAINER_multipeermap_remove (sh->env.addresses, key, value); | ||
2412 | GNUNET_free (address); | ||
2413 | |||
2414 | return GNUNET_OK; | ||
2415 | } | ||
2416 | |||
2417 | static void | 2403 | static void |
2418 | done () | 2404 | done () |
2419 | { | 2405 | { |
2420 | struct TestPeer *cur; | 2406 | struct TestPeer *cur; |
2421 | struct TestPeer *next; | 2407 | struct TestPeer *next; |
2422 | /* Clean up experiment */ | 2408 | |
2409 | struct TestAddress *cur_a; | ||
2410 | struct TestAddress *next_a; | ||
2411 | |||
2412 | /* Stop logging */ | ||
2413 | GNUNET_ATS_solver_logging_stop (l); | ||
2414 | |||
2415 | /* Stop all preference generation */ | ||
2423 | GNUNET_ATS_solver_generate_preferences_stop_all (); | 2416 | GNUNET_ATS_solver_generate_preferences_stop_all (); |
2417 | |||
2418 | /* Stop all property generation */ | ||
2424 | GNUNET_ATS_solver_generate_property_stop_all (); | 2419 | GNUNET_ATS_solver_generate_property_stop_all (); |
2425 | 2420 | ||
2421 | /* Clean up experiment */ | ||
2426 | if (NULL != e) | 2422 | if (NULL != e) |
2427 | { | 2423 | { |
2428 | GNUNET_ATS_solvers_experimentation_stop (e); | 2424 | GNUNET_ATS_solvers_experimentation_stop (e); |
@@ -2440,10 +2436,21 @@ done () | |||
2440 | { | 2436 | { |
2441 | next = cur->next; | 2437 | next = cur->next; |
2442 | GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, cur); | 2438 | GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, cur); |
2443 | GNUNET_CONTAINER_multipeermap_iterate (sh->env.addresses, &free_all_it, NULL); | 2439 | next_a = cur->addr_head; |
2444 | 2440 | while (NULL != (cur_a = next_a)) | |
2441 | { | ||
2442 | next_a = cur_a->next; | ||
2443 | GNUNET_CONTAINER_DLL_remove (cur->addr_head, cur->addr_tail, cur_a); | ||
2444 | GNUNET_free (cur_a); | ||
2445 | } | ||
2445 | GNUNET_free (cur); | 2446 | GNUNET_free (cur); |
2446 | } | 2447 | } |
2448 | |||
2449 | if (NULL != sh) | ||
2450 | { | ||
2451 | GNUNET_ATS_solvers_solver_stop (sh); | ||
2452 | sh = NULL; | ||
2453 | } | ||
2447 | /* Shutdown */ | 2454 | /* Shutdown */ |
2448 | end_now(); | 2455 | end_now(); |
2449 | 2456 | ||
@@ -2458,14 +2465,6 @@ experiment_done_cb (struct Experiment *e, struct GNUNET_TIME_Relative duration,i | |||
2458 | else | 2465 | else |
2459 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); | 2466 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Experiment failed \n"); |
2460 | 2467 | ||
2461 | /* Stop logging */ | ||
2462 | GNUNET_ATS_solver_logging_stop (l); | ||
2463 | |||
2464 | /* Stop traffic generation */ | ||
2465 | // GNUNET_ATS_TEST_generate_traffic_stop_all(); | ||
2466 | |||
2467 | /* Stop all preference generations */ | ||
2468 | GNUNET_ATS_solver_generate_preferences_stop_all (); | ||
2469 | 2468 | ||
2470 | /* | 2469 | /* |
2471 | evaluate (duration); | 2470 | evaluate (duration); |