aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-12-13 16:13:11 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-12-13 16:13:11 +0000
commitcb35b97eda49c9cd56cc86fa9107fbd588448a27 (patch)
tree8e9fdb26a9a434e6475b1b9a3a3f7adc106f522a /src
parent2f079fe3c7619685ed1170d9a4a6eb07ebc77749 (diff)
downloadgnunet-cb35b97eda49c9cd56cc86fa9107fbd588448a27.tar.gz
gnunet-cb35b97eda49c9cd56cc86fa9107fbd588448a27.zip
statistics for solver
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-service-ats_addresses_simplistic.c64
1 files changed, 61 insertions, 3 deletions
diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c
index 581994c8c..ddadcb55c 100644
--- a/src/ats/gnunet-service-ats_addresses_simplistic.c
+++ b/src/ats/gnunet-service-ats_addresses_simplistic.c
@@ -61,13 +61,40 @@
61 */ 61 */
62struct GAS_SIMPLISTIC_Handle 62struct GAS_SIMPLISTIC_Handle
63{ 63{
64 /**
65 * Statistics handle
66 */
67
68 struct GNUNET_STATISTICS_Handle *stats;
69
70 /**
71 * Total number of addresses for solver
72 */
64 unsigned int total_addresses; 73 unsigned int total_addresses;
74
75 /**
76 * Number of active addresses for solver
77 */
65 unsigned int active_addresses; 78 unsigned int active_addresses;
66 79
80 /**
81 * Networks array
82 */
67 struct Network *network_entries; 83 struct Network *network_entries;
68 84
85 /**
86 * Number of networks
87 */
69 unsigned int networks; 88 unsigned int networks;
89
90 /**
91 * Callback
92 */
70 GAS_bandwidth_changed_cb bw_changed; 93 GAS_bandwidth_changed_cb bw_changed;
94
95 /**
96 * Callback cls
97 */
71 void *bw_changed_cls; 98 void *bw_changed_cls;
72}; 99};
73 100
@@ -105,6 +132,16 @@ struct Network
105 */ 132 */
106 unsigned int total_addresses; 133 unsigned int total_addresses;
107 134
135 /**
136 * String for statistics total addresses
137 */
138 char *stat_total;
139
140 /**
141 * String for statistics active addresses
142 */
143 char *stat_active;
144
108 struct AddressWrapper *head; 145 struct AddressWrapper *head;
109 struct AddressWrapper *tail; 146 struct AddressWrapper *tail;
110}; 147};
@@ -156,6 +193,8 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
156 struct Network * cur; 193 struct Network * cur;
157 char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString; 194 char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
158 195
196
197 s->stats = (struct GNUNET_STATISTICS_Handle *) stats;
159 s->bw_changed = bw_changed_cb; 198 s->bw_changed = bw_changed_cb;
160 s->bw_changed_cls = bw_changed_cb_cls; 199 s->bw_changed_cls = bw_changed_cb_cls;
161 s->networks = dest_length; 200 s->networks = dest_length;
@@ -172,6 +211,8 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
172 cur->total_quota_in = in_quota[c]; 211 cur->total_quota_in = in_quota[c];
173 cur->total_quota_out = out_quota[c]; 212 cur->total_quota_out = out_quota[c];
174 cur->desc = net_str[c]; 213 cur->desc = net_str[c];
214 GNUNET_asprintf (&cur->stat_total, "# ATS addresses %s total", cur->desc);
215 GNUNET_asprintf (&cur->stat_active, "# ATS active addresses %s total", cur->desc);
175 } 216 }
176 return s; 217 return s;
177} 218}
@@ -219,8 +260,9 @@ GAS_simplistic_done (void *solver)
219 s->network_entries[c].tail, 260 s->network_entries[c].tail,
220 cur); 261 cur);
221 GNUNET_free (cur); 262 GNUNET_free (cur);
222
223 } 263 }
264 GNUNET_free (s->network_entries[c].stat_total);
265 GNUNET_free (s->network_entries[c].stat_active);
224 } 266 }
225 if (s->total_addresses > 0) 267 if (s->total_addresses > 0)
226 { 268 {
@@ -298,13 +340,17 @@ addresse_increment (struct GAS_SIMPLISTIC_Handle *s,
298{ 340{
299 if (GNUNET_YES == total) 341 if (GNUNET_YES == total)
300 { 342 {
301 s->total_addresses ++; 343 s->total_addresses ++;
302 net->total_addresses ++; 344 net->total_addresses ++;
345 GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", 1, GNUNET_NO);
346 GNUNET_STATISTICS_update (s->stats, net->stat_total, 1, GNUNET_NO);
303 } 347 }
304 if (GNUNET_YES == active) 348 if (GNUNET_YES == active)
305 { 349 {
306 net->active_addresses ++; 350 net->active_addresses ++;
307 s->active_addresses ++; 351 s->active_addresses ++;
352 GNUNET_STATISTICS_update (s->stats, "# ATS active addresses total", 1, GNUNET_NO);
353 GNUNET_STATISTICS_update (s->stats, net->stat_active, 1, GNUNET_NO);
308 } 354 }
309 355
310} 356}
@@ -324,14 +370,20 @@ addresse_decrement (struct GAS_SIMPLISTIC_Handle *s,
324 res = GNUNET_SYSERR; 370 res = GNUNET_SYSERR;
325 } 371 }
326 else 372 else
373 {
327 s->total_addresses --; 374 s->total_addresses --;
375 GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1, GNUNET_NO);
376 }
328 if (net->total_addresses < 1) 377 if (net->total_addresses < 1)
329 { 378 {
330 GNUNET_break (0); 379 GNUNET_break (0);
331 res = GNUNET_SYSERR; 380 res = GNUNET_SYSERR;
332 } 381 }
333 else 382 else
383 {
334 net->total_addresses --; 384 net->total_addresses --;
385 GNUNET_STATISTICS_update (s->stats, net->stat_total, -1, GNUNET_NO);
386 }
335 } 387 }
336 388
337 if (GNUNET_YES == active) 389 if (GNUNET_YES == active)
@@ -342,14 +394,20 @@ addresse_decrement (struct GAS_SIMPLISTIC_Handle *s,
342 res = GNUNET_SYSERR; 394 res = GNUNET_SYSERR;
343 } 395 }
344 else 396 else
397 {
345 net->active_addresses --; 398 net->active_addresses --;
399 GNUNET_STATISTICS_update (s->stats, net->stat_active, -1, GNUNET_NO);
400 }
346 if (s->active_addresses < 1) 401 if (s->active_addresses < 1)
347 { 402 {
348 GNUNET_break (0); 403 GNUNET_break (0);
349 res = GNUNET_SYSERR; 404 res = GNUNET_SYSERR;
350 } 405 }
351 else 406 else
407 {
352 s->active_addresses --; 408 s->active_addresses --;
409 GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1, GNUNET_NO);
410 }
353 } 411 }
354 return res; 412 return res;
355} 413}