diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-18 15:49:57 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-04-18 15:49:57 +0000 |
commit | 8f3820b6244a0ac7fa28956413e17a6d3feb860c (patch) | |
tree | 592d6cdbf4f1f3239a2b834754ccfe056076eba9 /src/ats | |
parent | cc8cf22281f1f9d77fb498664ad8f847dccee17e (diff) | |
download | gnunet-8f3820b6244a0ac7fa28956413e17a6d3feb860c.tar.gz gnunet-8f3820b6244a0ac7fa28956413e17a6d3feb860c.zip |
- remove statistics use return values
Diffstat (limited to 'src/ats')
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.c | 46 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses_mlp.h | 10 | ||||
-rw-r--r-- | src/ats/perf_ats_mlp.c | 124 |
3 files changed, 61 insertions, 119 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.c b/src/ats/gnunet-service-ats_addresses_mlp.c index dfb62e665..85113ea8e 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.c +++ b/src/ats/gnunet-service-ats_addresses_mlp.c | |||
@@ -807,13 +807,6 @@ mlp_create_problem (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHas | |||
807 | } | 807 | } |
808 | 808 | ||
809 | 809 | ||
810 | struct SolveContext | ||
811 | { | ||
812 | struct GNUNET_TIME_Relative lp_duration; | ||
813 | struct GNUNET_TIME_Relative mlp_duration; | ||
814 | }; | ||
815 | |||
816 | |||
817 | /** | 810 | /** |
818 | * Solves the LP problem | 811 | * Solves the LP problem |
819 | * | 812 | * |
@@ -822,7 +815,7 @@ struct SolveContext | |||
822 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure | 815 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure |
823 | */ | 816 | */ |
824 | static int | 817 | static int |
825 | mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx) | 818 | mlp_solve_lp_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *s_ctx) |
826 | { | 819 | { |
827 | int res; | 820 | int res; |
828 | struct GNUNET_TIME_Relative duration; | 821 | struct GNUNET_TIME_Relative duration; |
@@ -916,7 +909,7 @@ lp_solv: | |||
916 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure | 909 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure |
917 | */ | 910 | */ |
918 | int | 911 | int |
919 | mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx) | 912 | mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *s_ctx) |
920 | { | 913 | { |
921 | int res; | 914 | int res; |
922 | struct GNUNET_TIME_Relative duration; | 915 | struct GNUNET_TIME_Relative duration; |
@@ -981,23 +974,23 @@ mlp_solve_mlp_problem (struct GAS_MLP_Handle *mlp, struct SolveContext *s_ctx) | |||
981 | return GNUNET_OK; | 974 | return GNUNET_OK; |
982 | } | 975 | } |
983 | 976 | ||
984 | int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp); | 977 | int GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx); |
985 | 978 | ||
986 | static void | 979 | static void |
987 | mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 980 | mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
988 | { | 981 | { |
989 | struct GAS_MLP_Handle *mlp = cls; | 982 | struct GAS_MLP_Handle *mlp = cls; |
983 | struct GAS_MLP_SolutionContext ctx; | ||
990 | 984 | ||
991 | mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK; | 985 | mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK; |
992 | 986 | ||
993 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 987 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
994 | return; | 988 | return; |
995 | 989 | ||
996 | |||
997 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n"); | 990 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduled problem solving\n"); |
998 | 991 | ||
999 | if (mlp->addr_in_problem != 0) | 992 | if (mlp->addr_in_problem != 0) |
1000 | GAS_mlp_solve_problem(mlp); | 993 | GAS_mlp_solve_problem(mlp, &ctx); |
1001 | } | 994 | } |
1002 | 995 | ||
1003 | /** | 996 | /** |
@@ -1007,12 +1000,16 @@ mlp_scheduler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1007 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure | 1000 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure |
1008 | */ | 1001 | */ |
1009 | int | 1002 | int |
1010 | GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) | 1003 | GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx) |
1011 | { | 1004 | { |
1012 | int res; | 1005 | int res; |
1013 | struct SolveContext s_ctx; | ||
1014 | mlp->last_execution = GNUNET_TIME_absolute_get (); | 1006 | mlp->last_execution = GNUNET_TIME_absolute_get (); |
1015 | 1007 | ||
1008 | ctx->lp_result = GNUNET_SYSERR; | ||
1009 | ctx->mlp_result = GNUNET_SYSERR; | ||
1010 | ctx->lp_duration = GNUNET_TIME_relative_get_forever(); | ||
1011 | ctx->mlp_duration = GNUNET_TIME_relative_get_forever(); | ||
1012 | |||
1016 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n"); | 1013 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve LP problem\n"); |
1017 | #if WRITE_MLP | 1014 | #if WRITE_MLP |
1018 | char * name; | 1015 | char * name; |
@@ -1023,12 +1020,14 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) | |||
1023 | GNUNET_free (name); | 1020 | GNUNET_free (name); |
1024 | # endif | 1021 | # endif |
1025 | 1022 | ||
1026 | res = mlp_solve_lp_problem (mlp, &s_ctx); | 1023 | res = mlp_solve_lp_problem (mlp, ctx); |
1024 | ctx->lp_result = res; | ||
1027 | if (res != GNUNET_OK) | 1025 | if (res != GNUNET_OK) |
1028 | { | 1026 | { |
1029 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "LP Problem solving failed\n"); | 1027 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "LP Problem solving failed\n"); |
1030 | return GNUNET_SYSERR; | 1028 | return GNUNET_SYSERR; |
1031 | } | 1029 | } |
1030 | |||
1032 | #if WRITE_MLP | 1031 | #if WRITE_MLP |
1033 | GNUNET_asprintf(&name, "problem_%i_lp_solution", i); | 1032 | GNUNET_asprintf(&name, "problem_%i_lp_solution", i); |
1034 | glp_print_sol (mlp->prob, name); | 1033 | glp_print_sol (mlp->prob, name); |
@@ -1037,7 +1036,8 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) | |||
1037 | 1036 | ||
1038 | 1037 | ||
1039 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve MLP problem\n"); | 1038 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Solve MLP problem\n"); |
1040 | res = mlp_solve_mlp_problem (mlp, &s_ctx); | 1039 | res = mlp_solve_mlp_problem (mlp, ctx); |
1040 | ctx->mlp_result = res; | ||
1041 | if (res != GNUNET_OK) | 1041 | if (res != GNUNET_OK) |
1042 | { | 1042 | { |
1043 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n"); | 1043 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MLP Problem solving failed\n"); |
@@ -1050,7 +1050,7 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) | |||
1050 | # endif | 1050 | # endif |
1051 | 1051 | ||
1052 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved %s (LP duration %llu / MLP duration %llu)\n", | 1052 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved %s (LP duration %llu / MLP duration %llu)\n", |
1053 | (GNUNET_OK == res) ? "successfully" : "failed", s_ctx.lp_duration, s_ctx.mlp_duration); | 1053 | (GNUNET_OK == res) ? "successfully" : "failed", ctx->lp_duration.rel_value, ctx->mlp_duration.rel_value); |
1054 | /* Process result */ | 1054 | /* Process result */ |
1055 | struct ATS_Peer *p = NULL; | 1055 | struct ATS_Peer *p = NULL; |
1056 | struct ATS_Address *a = NULL; | 1056 | struct ATS_Address *a = NULL; |
@@ -1085,7 +1085,7 @@ GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp) | |||
1085 | GNUNET_SCHEDULER_cancel(mlp->mlp_task); | 1085 | GNUNET_SCHEDULER_cancel(mlp->mlp_task); |
1086 | mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK; | 1086 | mlp->mlp_task = GNUNET_SCHEDULER_NO_TASK; |
1087 | } | 1087 | } |
1088 | mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp); | 1088 | //mlp->mlp_task = GNUNET_SCHEDULER_add_delayed (mlp->exec_interval, &mlp_scheduler, mlp); |
1089 | return res; | 1089 | return res; |
1090 | } | 1090 | } |
1091 | 1091 | ||
@@ -1427,7 +1427,7 @@ update_quality (struct GAS_MLP_Handle *mlp, struct ATS_Address * address) | |||
1427 | c3 ++; | 1427 | c3 ++; |
1428 | } | 1428 | } |
1429 | } | 1429 | } |
1430 | if (c3 > 0) | 1430 | if ((c3 > 0) && (avg > 0)) |
1431 | /* avg = 1 / ((q[0] + ... + q[l]) /c3) => c3 / avg*/ | 1431 | /* avg = 1 / ((q[0] + ... + q[l]) /c3) => c3 / avg*/ |
1432 | mlpi->q_averaged[c] = (double) c3 / avg; | 1432 | mlpi->q_averaged[c] = (double) c3 / avg; |
1433 | else | 1433 | else |
@@ -1452,7 +1452,7 @@ update_quality (struct GAS_MLP_Handle *mlp, struct ATS_Address * address) | |||
1452 | c3 ++; | 1452 | c3 ++; |
1453 | } | 1453 | } |
1454 | } | 1454 | } |
1455 | if (c3 > 0) | 1455 | if ((c3 > 0) && (avg > 0)) |
1456 | /* avg = 1 / ((q[0] + ... + q[l]) /c3) => c3 / avg*/ | 1456 | /* avg = 1 / ((q[0] + ... + q[l]) /c3) => c3 / avg*/ |
1457 | mlpi->q_averaged[c] = (double) c3 / avg; | 1457 | mlpi->q_averaged[c] = (double) c3 / avg; |
1458 | else | 1458 | else |
@@ -1540,6 +1540,7 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult | |||
1540 | { | 1540 | { |
1541 | int new; | 1541 | int new; |
1542 | struct MLP_information *mlpi; | 1542 | struct MLP_information *mlpi; |
1543 | struct GAS_MLP_SolutionContext ctx; | ||
1543 | 1544 | ||
1544 | GNUNET_STATISTICS_update (mlp->stats, "# MLP address updates", 1, GNUNET_NO); | 1545 | GNUNET_STATISTICS_update (mlp->stats, "# MLP address updates", 1, GNUNET_NO); |
1545 | 1546 | ||
@@ -1624,7 +1625,7 @@ GAS_mlp_address_update (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult | |||
1624 | mlp->presolver_required = GNUNET_YES; | 1625 | mlp->presolver_required = GNUNET_YES; |
1625 | } | 1626 | } |
1626 | if (mlp->auto_solve == GNUNET_YES) | 1627 | if (mlp->auto_solve == GNUNET_YES) |
1627 | GAS_mlp_solve_problem (mlp); | 1628 | GAS_mlp_solve_problem (mlp, &ctx); |
1628 | } | 1629 | } |
1629 | 1630 | ||
1630 | /** | 1631 | /** |
@@ -1641,6 +1642,7 @@ void | |||
1641 | GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) | 1642 | GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_MultiHashMap * addresses, struct ATS_Address *address) |
1642 | { | 1643 | { |
1643 | GNUNET_STATISTICS_update (mlp->stats,"# LP address deletions", 1, GNUNET_NO); | 1644 | GNUNET_STATISTICS_update (mlp->stats,"# LP address deletions", 1, GNUNET_NO); |
1645 | struct GAS_MLP_SolutionContext ctx; | ||
1644 | 1646 | ||
1645 | /* Free resources */ | 1647 | /* Free resources */ |
1646 | if (address->mlp_information != NULL) | 1648 | if (address->mlp_information != NULL) |
@@ -1682,7 +1684,7 @@ GAS_mlp_address_delete (struct GAS_MLP_Handle *mlp, struct GNUNET_CONTAINER_Mult | |||
1682 | /* Recalculate */ | 1684 | /* Recalculate */ |
1683 | mlp->presolver_required = GNUNET_YES; | 1685 | mlp->presolver_required = GNUNET_YES; |
1684 | if (mlp->auto_solve == GNUNET_YES) | 1686 | if (mlp->auto_solve == GNUNET_YES) |
1685 | GAS_mlp_solve_problem (mlp); | 1687 | GAS_mlp_solve_problem (mlp, &ctx); |
1686 | } | 1688 | } |
1687 | } | 1689 | } |
1688 | 1690 | ||
diff --git a/src/ats/gnunet-service-ats_addresses_mlp.h b/src/ats/gnunet-service-ats_addresses_mlp.h index e8db35c27..14684d3ba 100644 --- a/src/ats/gnunet-service-ats_addresses_mlp.h +++ b/src/ats/gnunet-service-ats_addresses_mlp.h | |||
@@ -73,6 +73,14 @@ struct ATS_PreferedAddress | |||
73 | struct ATS_Address *address; | 73 | struct ATS_Address *address; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | struct GAS_MLP_SolutionContext | ||
77 | { | ||
78 | int lp_result; | ||
79 | int mlp_result; | ||
80 | struct GNUNET_TIME_Relative lp_duration; | ||
81 | struct GNUNET_TIME_Relative mlp_duration; | ||
82 | }; | ||
83 | |||
76 | /** | 84 | /** |
77 | * MLP Handle | 85 | * MLP Handle |
78 | */ | 86 | */ |
@@ -324,7 +332,7 @@ GAS_mlp_init (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
324 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure | 332 | * @return GNUNET_OK if could be solved, GNUNET_SYSERR on failure |
325 | */ | 333 | */ |
326 | int | 334 | int |
327 | GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp); | 335 | GAS_mlp_solve_problem (struct GAS_MLP_Handle *mlp, struct GAS_MLP_SolutionContext *ctx); |
328 | 336 | ||
329 | 337 | ||
330 | /** | 338 | /** |
diff --git a/src/ats/perf_ats_mlp.c b/src/ats/perf_ats_mlp.c index 623f187ea..63dce8b37 100644 --- a/src/ats/perf_ats_mlp.c +++ b/src/ats/perf_ats_mlp.c | |||
@@ -47,15 +47,12 @@ struct ATS_Address *a; | |||
47 | 47 | ||
48 | static int ret; | 48 | static int ret; |
49 | 49 | ||
50 | struct GNUNET_STATISTICS_Handle * stats; | ||
51 | |||
52 | struct GNUNET_CONTAINER_MultiHashMap * amap; | 50 | struct GNUNET_CONTAINER_MultiHashMap * amap; |
53 | 51 | ||
54 | struct GAS_MLP_Handle *mlp; | 52 | struct GAS_MLP_Handle *mlp; |
55 | 53 | ||
56 | struct GNUNET_STATISTICS_Handle * stats; | ||
57 | 54 | ||
58 | struct GNUNET_OS_Process *stats_proc; | 55 | |
59 | 56 | ||
60 | GNUNET_SCHEDULER_TaskIdentifier shutdown_task; | 57 | GNUNET_SCHEDULER_TaskIdentifier shutdown_task; |
61 | 58 | ||
@@ -107,70 +104,27 @@ do_shutdown (void *cls, | |||
107 | GNUNET_CONTAINER_multihashmap_destroy(amap); | 104 | GNUNET_CONTAINER_multihashmap_destroy(amap); |
108 | GNUNET_free_non_null (a); | 105 | GNUNET_free_non_null (a); |
109 | GNUNET_free_non_null (p); | 106 | GNUNET_free_non_null (p); |
110 | if (stats != NULL) | ||
111 | GNUNET_STATISTICS_destroy (stats,GNUNET_NO); | ||
112 | 107 | ||
113 | if (NULL != stats_proc) | ||
114 | { | ||
115 | if (0 != GNUNET_OS_process_kill (stats_proc, SIGTERM)) | ||
116 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | ||
117 | if (GNUNET_OS_process_wait (stats_proc) != GNUNET_OK) | ||
118 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); | ||
119 | GNUNET_OS_process_close (stats_proc); | ||
120 | stats_proc = NULL; | ||
121 | } | ||
122 | } | 108 | } |
123 | 109 | ||
124 | int stat_lp_it (void *cls, const char *subsystem, | ||
125 | const char *name, uint64_t value, | ||
126 | int is_persistent) | ||
127 | { | ||
128 | static long long unsigned lp_time; | ||
129 | static long long unsigned mlp_time; | ||
130 | static long long unsigned lp_time_set; | ||
131 | static long long unsigned mlp_time_set; | ||
132 | |||
133 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received: `%s' : %u \n", name, value); | ||
134 | |||
135 | if (0 == strcmp (name, "# LP execution time (ms)")) | ||
136 | { | ||
137 | lp_time = value; | ||
138 | lp_time_set = GNUNET_YES; | ||
139 | } | ||
140 | if (0 == strcmp (name, "# MLP execution time (ms)")) | ||
141 | { | ||
142 | mlp_time = value; | ||
143 | mlp_time_set = GNUNET_YES; | ||
144 | } | ||
145 | 110 | ||
146 | if ((GNUNET_YES == lp_time_set) && (GNUNET_YES == mlp_time_set)) | 111 | static void |
147 | { | 112 | check (void *cls, char *const *args, const char *cfgfile, |
148 | if (GNUNET_YES == numeric) | 113 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
149 | printf ("%u;%u;%llu;%llu\n",peers, addresses, lp_time, mlp_time); | ||
150 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) | ||
151 | GNUNET_SCHEDULER_cancel(shutdown_task); | ||
152 | shutdown_task = GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); | ||
153 | } | ||
154 | return GNUNET_OK; | ||
155 | } | ||
156 | |||
157 | int stat_ready_it (void *cls, const char *subsystem, | ||
158 | const char *name, uint64_t value, | ||
159 | int is_persistent) | ||
160 | { | 114 | { |
161 | unsigned int c = 0; | 115 | unsigned int c = 0; |
162 | unsigned int c2 = 0; | 116 | unsigned int c2 = 0; |
163 | unsigned int ca = 0; | 117 | unsigned int ca = 0; |
164 | struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
165 | 118 | ||
166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Statistics service ready\n"); | 119 | #if !HAVE_LIBGLPK |
167 | 120 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!"); | |
168 | GNUNET_STATISTICS_watch (stats, "ats", "# LP execution time (ms)", &stat_lp_it, NULL); | 121 | ret = 1; |
169 | GNUNET_STATISTICS_watch (stats, "ats", "# MLP execution time (ms)", &stat_lp_it, NULL); | 122 | return; |
123 | #endif | ||
170 | 124 | ||
171 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses); | 125 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up %u peers with %u addresses per peer\n", peers, addresses); |
172 | 126 | ||
173 | mlp = GAS_mlp_init (cfg, stats, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); | 127 | mlp = GAS_mlp_init (cfg, NULL, MLP_MAX_EXEC_DURATION, MLP_MAX_ITERATIONS); |
174 | if (NULL == mlp) | 128 | if (NULL == mlp) |
175 | { | 129 | { |
176 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to init MLP\n"); | 130 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to init MLP\n"); |
@@ -178,7 +132,6 @@ int stat_ready_it (void *cls, const char *subsystem, | |||
178 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) | 132 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) |
179 | GNUNET_SCHEDULER_cancel(shutdown_task); | 133 | GNUNET_SCHEDULER_cancel(shutdown_task); |
180 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 134 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
181 | return GNUNET_NO; | ||
182 | } | 135 | } |
183 | 136 | ||
184 | if (peers == 0) | 137 | if (peers == 0) |
@@ -195,7 +148,7 @@ int stat_ready_it (void *cls, const char *subsystem, | |||
195 | for (c=0; c < peers; c++) | 148 | for (c=0; c < peers; c++) |
196 | { | 149 | { |
197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up peer %u\n", c); | 150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up peer %u\n", c); |
198 | GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_WEAK, &p[c].id.hashPubKey); | 151 | GNUNET_CRYPTO_hash_create_random(GNUNET_CRYPTO_QUALITY_NONCE, &p[c].id.hashPubKey); |
199 | 152 | ||
200 | for (c2=0; c2 < addresses; c2++) | 153 | for (c2=0; c2 < addresses; c2++) |
201 | { | 154 | { |
@@ -212,9 +165,9 @@ int stat_ready_it (void *cls, const char *subsystem, | |||
212 | 165 | ||
213 | a[ca].ats = GNUNET_malloc (2 * sizeof (struct GNUNET_ATS_Information)); | 166 | a[ca].ats = GNUNET_malloc (2 * sizeof (struct GNUNET_ATS_Information)); |
214 | a[ca].ats[0].type = GNUNET_ATS_QUALITY_NET_DELAY; | 167 | a[ca].ats[0].type = GNUNET_ATS_QUALITY_NET_DELAY; |
215 | a[ca].ats[0].value = 20; | 168 | a[ca].ats[0].value = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 10); |
216 | a[ca].ats[1].type = GNUNET_ATS_QUALITY_NET_DISTANCE; | 169 | a[ca].ats[1].type = GNUNET_ATS_QUALITY_NET_DISTANCE; |
217 | a[ca].ats[1].value = 2; | 170 | a[ca].ats[1].value = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 2); |
218 | a[ca].ats_count = 2; | 171 | a[ca].ats_count = 2; |
219 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u\n", ca); | 172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up address %u\n", ca); |
220 | GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 173 | GNUNET_CONTAINER_multihashmap_put (amap, &a[ca].peer.hashPubKey, &a[ca], GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
@@ -222,51 +175,30 @@ int stat_ready_it (void *cls, const char *subsystem, | |||
222 | ca++; | 175 | ca++; |
223 | } | 176 | } |
224 | } | 177 | } |
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem); | 178 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Problem contains %u peers and %u adresses\n", mlp->c_p, mlp->addr_in_problem); |
226 | 179 | ||
227 | GNUNET_assert (peers == mlp->c_p); | 180 | GNUNET_assert (peers == mlp->c_p); |
228 | GNUNET_assert (peers * addresses == mlp->addr_in_problem); | 181 | GNUNET_assert (peers * addresses == mlp->addr_in_problem); |
229 | 182 | ||
230 | /* Solving the problem */ | 183 | /* Solving the problem */ |
231 | if (GNUNET_OK == GAS_mlp_solve_problem(mlp)) | 184 | struct GAS_MLP_SolutionContext ctx; |
232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Problem solved successfully \n"); | ||
233 | else | ||
234 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses); | ||
235 | |||
236 | GNUNET_log ( GNUNET_ERROR_TYPE_WARNING, "Waiting for statistics\n"); | ||
237 | |||
238 | 185 | ||
239 | return GNUNET_OK; | 186 | if (GNUNET_OK == GAS_mlp_solve_problem(mlp, &ctx)) |
240 | } | ||
241 | |||
242 | static void | ||
243 | check (void *cls, char *const *args, const char *cfgfile, | ||
244 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
245 | { | ||
246 | #if !HAVE_LIBGLPK | ||
247 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!"); | ||
248 | ret = 1; | ||
249 | return; | ||
250 | #endif | ||
251 | |||
252 | stats_proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics", | ||
253 | "gnunet-service-statistics", NULL); | ||
254 | |||
255 | if (NULL == stats_proc) | ||
256 | { | 187 | { |
257 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start statistics service \n"); | 188 | GNUNET_assert (GNUNET_OK == ctx.lp_result); |
258 | ret = 1; | 189 | GNUNET_assert (GNUNET_OK == ctx.mlp_result); |
259 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) | 190 | if (GNUNET_YES == numeric) |
260 | GNUNET_SCHEDULER_cancel(shutdown_task); | 191 | printf ("%u;%u;%llu;%llu\n",mlp->c_p, mlp->addr_in_problem, (long long unsigned int) ctx.lp_duration.rel_value, (long long unsigned int) ctx.mlp_duration.rel_value); |
261 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 192 | else |
262 | return; | 193 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Problem solved successfully (LP: %llu ms / MLP: %llu ms)\n", ctx.lp_duration.rel_value, ctx.mlp_duration.rel_value); |
263 | } | ||
264 | 194 | ||
265 | stats = GNUNET_STATISTICS_create("ats", cfg); | 195 | } |
196 | else | ||
197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Solving problem with %u peers and %u addresses failed\n", peers, addresses); | ||
198 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) | ||
199 | GNUNET_SCHEDULER_cancel(shutdown_task); | ||
200 | shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | ||
266 | 201 | ||
267 | GNUNET_STATISTICS_watch (stats, "ats", "watch", &stat_ready_it, (void *) cfg); | ||
268 | GNUNET_STATISTICS_set(stats, "watch", 1, GNUNET_NO); | ||
269 | return; | ||
270 | } | 202 | } |
271 | 203 | ||
272 | 204 | ||