aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwachs <wachs@140774ce-b5e7-0310-ab8b-a85725594a96>2012-12-13 16:13:11 +0000
committerwachs <wachs@140774ce-b5e7-0310-ab8b-a85725594a96>2012-12-13 16:13:11 +0000
commit4e6889a6523f48c1f6f9ba773c9a7f9280086c72 (patch)
tree8e9fdb26a9a434e6475b1b9a3a3f7adc106f522a
parentb22111e7b79e9852ee12b5d797432a576c40aef2 (diff)
statistics for solver
git-svn-id: https://gnunet.org/svn/gnunet@25459 140774ce-b5e7-0310-ab8b-a85725594a96
-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 581994c8ce..ddadcb55c0 100644
--- a/src/ats/gnunet-service-ats_addresses_simplistic.c
+++ b/src/ats/gnunet-service-ats_addresses_simplistic.c
@@ -61,13 +61,40 @@
*/
struct GAS_SIMPLISTIC_Handle
{
+ /**
+ * Statistics handle
+ */
+
+ struct GNUNET_STATISTICS_Handle *stats;
+
+ /**
+ * Total number of addresses for solver
+ */
unsigned int total_addresses;
+
+ /**
+ * Number of active addresses for solver
+ */
unsigned int active_addresses;
+ /**
+ * Networks array
+ */
struct Network *network_entries;
+ /**
+ * Number of networks
+ */
unsigned int networks;
+
+ /**
+ * Callback
+ */
GAS_bandwidth_changed_cb bw_changed;
+
+ /**
+ * Callback cls
+ */
void *bw_changed_cls;
};
@@ -105,6 +132,16 @@ struct Network
*/
unsigned int total_addresses;
+ /**
+ * String for statistics total addresses
+ */
+ char *stat_total;
+
+ /**
+ * String for statistics active addresses
+ */
+ char *stat_active;
+
struct AddressWrapper *head;
struct AddressWrapper *tail;
};
@@ -156,6 +193,8 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
struct Network * cur;
char * net_str[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString;
+
+ s->stats = (struct GNUNET_STATISTICS_Handle *) stats;
s->bw_changed = bw_changed_cb;
s->bw_changed_cls = bw_changed_cb_cls;
s->networks = dest_length;
@@ -172,6 +211,8 @@ GAS_simplistic_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
cur->total_quota_in = in_quota[c];
cur->total_quota_out = out_quota[c];
cur->desc = net_str[c];
+ GNUNET_asprintf (&cur->stat_total, "# ATS addresses %s total", cur->desc);
+ GNUNET_asprintf (&cur->stat_active, "# ATS active addresses %s total", cur->desc);
}
return s;
}
@@ -219,8 +260,9 @@ GAS_simplistic_done (void *solver)
s->network_entries[c].tail,
cur);
GNUNET_free (cur);
-
}
+ GNUNET_free (s->network_entries[c].stat_total);
+ GNUNET_free (s->network_entries[c].stat_active);
}
if (s->total_addresses > 0)
{
@@ -298,13 +340,17 @@ addresse_increment (struct GAS_SIMPLISTIC_Handle *s,
{
if (GNUNET_YES == total)
{
- s->total_addresses ++;
- net->total_addresses ++;
+ s->total_addresses ++;
+ net->total_addresses ++;
+ GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (s->stats, net->stat_total, 1, GNUNET_NO);
}
if (GNUNET_YES == active)
{
net->active_addresses ++;
s->active_addresses ++;
+ GNUNET_STATISTICS_update (s->stats, "# ATS active addresses total", 1, GNUNET_NO);
+ GNUNET_STATISTICS_update (s->stats, net->stat_active, 1, GNUNET_NO);
}
}
@@ -324,14 +370,20 @@ addresse_decrement (struct GAS_SIMPLISTIC_Handle *s,
res = GNUNET_SYSERR;
}
else
+ {
s->total_addresses --;
+ GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1, GNUNET_NO);
+ }
if (net->total_addresses < 1)
{
GNUNET_break (0);
res = GNUNET_SYSERR;
}
else
+ {
net->total_addresses --;
+ GNUNET_STATISTICS_update (s->stats, net->stat_total, -1, GNUNET_NO);
+ }
}
if (GNUNET_YES == active)
@@ -342,14 +394,20 @@ addresse_decrement (struct GAS_SIMPLISTIC_Handle *s,
res = GNUNET_SYSERR;
}
else
+ {
net->active_addresses --;
+ GNUNET_STATISTICS_update (s->stats, net->stat_active, -1, GNUNET_NO);
+ }
if (s->active_addresses < 1)
{
GNUNET_break (0);
res = GNUNET_SYSERR;
}
else
+ {
s->active_addresses --;
+ GNUNET_STATISTICS_update (s->stats, "# ATS addresses total", -1, GNUNET_NO);
+ }
}
return res;
}