diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-12-18 16:40:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-12-18 16:40:06 +0000 |
commit | d964273f5167433a465742cc54a4aa16945924fa (patch) | |
tree | 5a835f6486b79d41341454e0314287aa9a2ee073 /src/datastore | |
parent | 2698214da18ededa4823cd239f4d882665d92cb2 (diff) | |
download | gnunet-d964273f5167433a465742cc54a4aa16945924fa.tar.gz gnunet-d964273f5167433a465742cc54a4aa16945924fa.zip |
-track utilization by datastore plugin type
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 8555fad3a..0f2e0c209 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -48,8 +48,10 @@ | |||
48 | */ | 48 | */ |
49 | #define MIN_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 49 | #define MIN_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
50 | 50 | ||
51 | 51 | /** | |
52 | #define QUOTA_STAT_NAME gettext_noop ("# bytes used in file-sharing datastore") | 52 | * Name under which we store current space consumption. |
53 | */ | ||
54 | static char *quota_stat_name; | ||
53 | 55 | ||
54 | /** | 56 | /** |
55 | * After how many payload-changing operations | 57 | * After how many payload-changing operations |
@@ -205,7 +207,8 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
205 | static void | 207 | static void |
206 | sync_stats () | 208 | sync_stats () |
207 | { | 209 | { |
208 | GNUNET_STATISTICS_set (stats, QUOTA_STAT_NAME, payload, GNUNET_YES); | 210 | GNUNET_STATISTICS_set (stats, quota_stat_name, payload, GNUNET_YES); |
211 | GNUNET_STATISTICS_set (stats, "# utilization by current datastore", payload, GNUNET_NO); | ||
209 | lastSync = 0; | 212 | lastSync = 0; |
210 | } | 213 | } |
211 | 214 | ||
@@ -1296,6 +1299,9 @@ load_plugin () | |||
1296 | "DATASTORE"); | 1299 | "DATASTORE"); |
1297 | return NULL; | 1300 | return NULL; |
1298 | } | 1301 | } |
1302 | GNUNET_asprintf ("a_stat_name, | ||
1303 | _("# bytes used in file-sharing datastore `%s'"), | ||
1304 | name); | ||
1299 | ret = GNUNET_malloc (sizeof (struct DatastorePlugin)); | 1305 | ret = GNUNET_malloc (sizeof (struct DatastorePlugin)); |
1300 | ret->env.cfg = cfg; | 1306 | ret->env.cfg = cfg; |
1301 | ret->env.duc = &disk_utilization_change_cb; | 1307 | ret->env.duc = &disk_utilization_change_cb; |
@@ -1336,6 +1342,8 @@ unload_plugin (struct DatastorePlugin *plug) | |||
1336 | GNUNET_free (plug->lib_name); | 1342 | GNUNET_free (plug->lib_name); |
1337 | GNUNET_free (plug->short_name); | 1343 | GNUNET_free (plug->short_name); |
1338 | GNUNET_free (plug); | 1344 | GNUNET_free (plug); |
1345 | GNUNET_free (quota_stat_name); | ||
1346 | quota_stat_name = NULL; | ||
1339 | } | 1347 | } |
1340 | 1348 | ||
1341 | 1349 | ||
@@ -1346,6 +1354,8 @@ unload_plugin (struct DatastorePlugin *plug) | |||
1346 | static void | 1354 | static void |
1347 | unload_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1355 | unload_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1348 | { | 1356 | { |
1357 | if (lastSync > 0) | ||
1358 | sync_stats (); | ||
1349 | if (GNUNET_YES == do_drop) | 1359 | if (GNUNET_YES == do_drop) |
1350 | plugin->api->drop (plugin->api->cls); | 1360 | plugin->api->drop (plugin->api->cls); |
1351 | unload_plugin (plugin); | 1361 | unload_plugin (plugin); |
@@ -1355,8 +1365,6 @@ unload_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1355 | GNUNET_CONTAINER_bloomfilter_free (filter); | 1365 | GNUNET_CONTAINER_bloomfilter_free (filter); |
1356 | filter = NULL; | 1366 | filter = NULL; |
1357 | } | 1367 | } |
1358 | if (lastSync > 0) | ||
1359 | sync_stats (); | ||
1360 | if (stat_get != NULL) | 1368 | if (stat_get != NULL) |
1361 | { | 1369 | { |
1362 | GNUNET_STATISTICS_get_cancel (stat_get); | 1370 | GNUNET_STATISTICS_get_cancel (stat_get); |
@@ -1605,7 +1613,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1605 | return; | 1613 | return; |
1606 | } | 1614 | } |
1607 | stat_get = | 1615 | stat_get = |
1608 | GNUNET_STATISTICS_get (stats, "datastore", QUOTA_STAT_NAME, | 1616 | GNUNET_STATISTICS_get (stats, "datastore", quota_stat_name, |
1609 | GNUNET_TIME_UNIT_SECONDS, &process_stat_done, | 1617 | GNUNET_TIME_UNIT_SECONDS, &process_stat_done, |
1610 | &process_stat_in, plugin); | 1618 | &process_stat_in, plugin); |
1611 | GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL); | 1619 | GNUNET_SERVER_disconnect_notify (server, &cleanup_reservations, NULL); |