aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-10-21 12:44:37 +0000
committerChristian Grothoff <christian@grothoff.org>2009-10-21 12:44:37 +0000
commit244acf03bb6313c3e8a900c940f1eed5536c7aa9 (patch)
tree02b7b8c5741a7b57332338055ee2e902eab21e0e
parent8ee36bffa3c4afdb4d41ee9cd9565bac2ead9d2c (diff)
downloadgnunet-244acf03bb6313c3e8a900c940f1eed5536c7aa9.tar.gz
gnunet-244acf03bb6313c3e8a900c940f1eed5536c7aa9.zip
extra debug for datastore, stats api fix
-rw-r--r--src/datastore/Makefile.am1
-rw-r--r--src/datastore/gnunet-service-datastore.c13
-rw-r--r--src/datastore/plugin_datastore_sqlite.c39
-rw-r--r--src/hostlist/hostlist-client.c4
-rw-r--r--src/include/gnunet_statistics_service.h6
-rw-r--r--src/statistics/gnunet-statistics.c8
-rw-r--r--src/statistics/statistics_api.c8
7 files changed, 58 insertions, 21 deletions
diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am
index 1ca588926..608fb7770 100644
--- a/src/datastore/Makefile.am
+++ b/src/datastore/Makefile.am
@@ -44,6 +44,7 @@ libgnunet_plugin_datastore_sqlite_la_SOURCES = \
44 plugin_datastore_sqlite.c 44 plugin_datastore_sqlite.c
45libgnunet_plugin_datastore_sqlite_la_LIBADD = \ 45libgnunet_plugin_datastore_sqlite_la_LIBADD = \
46 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 46 $(top_builddir)/src/statistics/libgnunetstatistics.la \
47 $(top_builddir)/src/arm/libgnunetarm.la \
47 $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 48 $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3
48libgnunet_plugin_datastore_sqlite_la_LDFLAGS = \ 49libgnunet_plugin_datastore_sqlite_la_LDFLAGS = \
49 $(GN_PLUGIN_LDFLAGS) 50 $(GN_PLUGIN_LDFLAGS)
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c
index 0fe1263ce..c895bb1c8 100644
--- a/src/datastore/gnunet-service-datastore.c
+++ b/src/datastore/gnunet-service-datastore.c
@@ -134,11 +134,10 @@ static int reservation_gen;
134static unsigned long long quota; 134static unsigned long long quota;
135 135
136/** 136/**
137 * How much space are we using for the cache? 137 * How much space are we using for the cache? (space available for
138 * (space available for insertions that will be 138 * insertions that will be instantly reclaimed by discarding less
139 * instantly reclaimed by discarding less 139 * important content --- or possibly whatever we just inserted into
140 * important content --- or possibly whatever 140 * the "cache").
141 * we just inserted into the "cache").
142 */ 141 */
143static unsigned long long cache_size; 142static unsigned long long cache_size;
144 143
@@ -354,7 +353,7 @@ manage (void *cls,
354 (0 == *need) ? GNUNET_YES : GNUNET_NO); 353 (0 == *need) ? GNUNET_YES : GNUNET_NO);
355#if DEBUG_DATASTORE 354#if DEBUG_DATASTORE
356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 355 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
357 "Deleting %llu bytes of low-priority content (still trying to recover %llu bytes)\n", 356 "Deleting %llu bytes of low-priority content (still trying to free another %llu bytes)\n",
358 size + GNUNET_DATASTORE_ENTRY_OVERHEAD, 357 size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
359 *need); 358 *need);
360#endif 359#endif
@@ -383,7 +382,7 @@ manage_space (unsigned long long need)
383 382
384#if DEBUG_DATASTORE 383#if DEBUG_DATASTORE
385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 384 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
386 "Asked to recover %llu bytes of cache space\n", 385 "Asked to free up %llu bytes of cache space\n",
387 need); 386 need);
388#endif 387#endif
389 n = GNUNET_malloc (sizeof(unsigned long long)); 388 n = GNUNET_malloc (sizeof(unsigned long long));
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c
index 2223dd6eb..b5d5990c6 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -25,11 +25,12 @@
25 */ 25 */
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_arm_service.h"
28#include "gnunet_statistics_service.h" 29#include "gnunet_statistics_service.h"
29#include "plugin_datastore.h" 30#include "plugin_datastore.h"
30#include <sqlite3.h> 31#include <sqlite3.h>
31 32
32#define DEBUG_SQLITE GNUNET_NO 33#define DEBUG_SQLITE GNUNET_YES
33 34
34/** 35/**
35 * After how many payload-changing operations 36 * After how many payload-changing operations
@@ -614,11 +615,28 @@ sqlite_next_request_cont (void *cls,
614 nc->end_it = GNUNET_YES; 615 nc->end_it = GNUNET_YES;
615 return; 616 return;
616 } 617 }
618#if DEBUG_SQLITE
619 if (ret == GNUNET_NO)
620 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
621 "sqlite",
622 "Asked to remove entry %llu (%u bytes)\n",
623 (unsigned long long) rowid,
624 size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
625#endif
617 if ( (ret == GNUNET_NO) && 626 if ( (ret == GNUNET_NO) &&
618 (GNUNET_OK == delete_by_rowid (plugin, rowid)) ) 627 (GNUNET_OK == delete_by_rowid (plugin, rowid)) )
619 { 628 {
620 plugin->payload -= (size + GNUNET_DATASTORE_ENTRY_OVERHEAD); 629 plugin->payload -= (size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
621 plugin->lastSync++; 630 plugin->lastSync++;
631#if DEBUG_SQLITE
632 if (ret == GNUNET_NO)
633 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
634 "sqlite",
635 "Removed entry %llu (%u bytes), new payload is %llu\n",
636 (unsigned long long) rowid,
637 size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
638 (unsigned long long) plugin->payload);
639#endif
622 if (plugin->lastSync >= MAX_STAT_SYNC_LAG) 640 if (plugin->lastSync >= MAX_STAT_SYNC_LAG)
623 sync_stats (plugin); 641 sync_stats (plugin);
624 } 642 }
@@ -741,6 +759,13 @@ sqlite_plugin_put (void *cls,
741 GNUNET_ERROR_TYPE_BULK, "sqlite3_reset"); 759 GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
742 plugin->lastSync++; 760 plugin->lastSync++;
743 plugin->payload += size + GNUNET_DATASTORE_ENTRY_OVERHEAD; 761 plugin->payload += size + GNUNET_DATASTORE_ENTRY_OVERHEAD;
762#if DEBUG_SQLITE
763 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
764 "sqlite",
765 "Stored new entry (%u bytes), new payload is %llu\n",
766 size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
767 (unsigned long long) plugin->payload);
768#endif
744 if (plugin->lastSync >= MAX_STAT_SYNC_LAG) 769 if (plugin->lastSync >= MAX_STAT_SYNC_LAG)
745 sync_stats (plugin); 770 sync_stats (plugin);
746 return GNUNET_OK; 771 return GNUNET_OK;
@@ -1522,11 +1547,18 @@ static int
1522process_stat_in (void *cls, 1547process_stat_in (void *cls,
1523 const char *subsystem, 1548 const char *subsystem,
1524 const char *name, 1549 const char *name,
1525 unsigned long long value, 1550 uint64_t value,
1526 int is_persistent) 1551 int is_persistent)
1527{ 1552{
1528 struct Plugin *plugin = cls; 1553 struct Plugin *plugin = cls;
1529 plugin->payload += value; 1554 plugin->payload += value;
1555#if DEBUG_SQLITE
1556 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
1557 "sqlite",
1558 "Notification from statistics about existing payload (%llu), new payload is %llu\n",
1559 value,
1560 (unsigned long long) plugin->payload);
1561#endif
1530 return GNUNET_OK; 1562 return GNUNET_OK;
1531} 1563}
1532 1564
@@ -1548,6 +1580,7 @@ libgnunet_plugin_datastore_sqlite_init (void *cls)
1548 return NULL; /* can only initialize once! */ 1580 return NULL; /* can only initialize once! */
1549 memset (&plugin, 0, sizeof(struct Plugin)); 1581 memset (&plugin, 0, sizeof(struct Plugin));
1550 plugin.env = env; 1582 plugin.env = env;
1583 GNUNET_ARM_start_services (env->cfg, env->sched, "statistics");
1551 plugin.statistics = GNUNET_STATISTICS_create (env->sched, 1584 plugin.statistics = GNUNET_STATISTICS_create (env->sched,
1552 "sqlite", 1585 "sqlite",
1553 env->cfg); 1586 env->cfg);
@@ -1562,6 +1595,7 @@ libgnunet_plugin_datastore_sqlite_init (void *cls)
1562 database_setup (env->cfg, &plugin)) 1595 database_setup (env->cfg, &plugin))
1563 { 1596 {
1564 database_shutdown (&plugin); 1597 database_shutdown (&plugin);
1598 GNUNET_ARM_stop_services (env->cfg, env->sched, "statistics");
1565 return NULL; 1599 return NULL;
1566 } 1600 }
1567 api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions)); 1601 api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions));
@@ -1603,6 +1637,7 @@ libgnunet_plugin_datastore_sqlite_done (void *cls)
1603 plugin->env = NULL; 1637 plugin->env = NULL;
1604 plugin->payload = 0; 1638 plugin->payload = 0;
1605 GNUNET_STATISTICS_destroy (plugin->statistics); 1639 GNUNET_STATISTICS_destroy (plugin->statistics);
1640 GNUNET_ARM_stop_services (plugin->env->cfg, plugin->env->sched, "statistics");
1606 GNUNET_free (api); 1641 GNUNET_free (api);
1607 if (fn != NULL) 1642 if (fn != NULL)
1608 { 1643 {
diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c
index db7d1c586..e0ff1f5a2 100644
--- a/src/hostlist/hostlist-client.c
+++ b/src/hostlist/hostlist-client.c
@@ -607,10 +607,10 @@ static int
607process_stat (void *cls, 607process_stat (void *cls,
608 const char *subsystem, 608 const char *subsystem,
609 const char *name, 609 const char *name,
610 unsigned long long value, 610 uint64_t value,
611 int is_persistent) 611 int is_persistent)
612{ 612{
613 hostlist_delay.value = (uint64_t) value; 613 hostlist_delay.value = value;
614 return GNUNET_OK; 614 return GNUNET_OK;
615} 615}
616 616
diff --git a/src/include/gnunet_statistics_service.h b/src/include/gnunet_statistics_service.h
index 2496f4091..d8f17b8a1 100644
--- a/src/include/gnunet_statistics_service.h
+++ b/src/include/gnunet_statistics_service.h
@@ -64,7 +64,7 @@ struct GNUNET_STATISTICS_Handle;
64typedef int (*GNUNET_STATISTICS_Iterator) (void *cls, 64typedef int (*GNUNET_STATISTICS_Iterator) (void *cls,
65 const char *subsystem, 65 const char *subsystem,
66 const char *name, 66 const char *name,
67 unsigned long long value, 67 uint64_t value,
68 int is_persistent); 68 int is_persistent);
69 69
70/** 70/**
@@ -129,7 +129,7 @@ GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle,
129void 129void
130GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, 130GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
131 const char *name, 131 const char *name,
132 unsigned long long value, int make_persistent); 132 uint64_t value, int make_persistent);
133 133
134/** 134/**
135 * Set statistic value for the peer. Will always use our 135 * Set statistic value for the peer. Will always use our
@@ -143,7 +143,7 @@ GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
143void 143void
144GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, 144GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
145 const char *name, 145 const char *name,
146 long long delta, int make_persistent); 146 int64_t delta, int make_persistent);
147 147
148 148
149 149
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c
index bea9ca0ca..dd9850418 100644
--- a/src/statistics/gnunet-statistics.c
+++ b/src/statistics/gnunet-statistics.c
@@ -65,11 +65,13 @@ static int persistent;
65static int 65static int
66printer (void *cls, 66printer (void *cls,
67 const char *subsystem, 67 const char *subsystem,
68 const char *name, unsigned long long value, int is_persistent) 68 const char *name,
69 uint64_t value, int is_persistent)
69{ 70{
70 FPRINTF (stdout, 71 FPRINTF (stdout,
71 "%s%-20s %-40s: %16llu\n", 72 "%s%-20s %-40s: %16llu\n",
72 is_persistent ? "!" : " ", subsystem, _(name), value); 73 is_persistent ? "!" : " ", subsystem, _(name),
74 (unsigned long long) value);
73 return GNUNET_OK; 75 return GNUNET_OK;
74} 76}
75 77
@@ -127,7 +129,7 @@ run (void *cls,
127 ret = 1; 129 ret = 1;
128 return; 130 return;
129 } 131 }
130 GNUNET_STATISTICS_set (h, name, val, persistent); 132 GNUNET_STATISTICS_set (h, name, (uint64_t) val, persistent);
131 GNUNET_STATISTICS_destroy (h); 133 GNUNET_STATISTICS_destroy (h);
132 return; 134 return;
133 } 135 }
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c
index 335cd4165..21b8ecd8a 100644
--- a/src/statistics/statistics_api.c
+++ b/src/statistics/statistics_api.c
@@ -88,7 +88,7 @@ struct ActionItem
88 /** 88 /**
89 * Associated value. 89 * Associated value.
90 */ 90 */
91 unsigned long long value; 91 uint64_t value;
92 92
93 /** 93 /**
94 * Flag for SET/UPDATE actions. 94 * Flag for SET/UPDATE actions.
@@ -630,7 +630,7 @@ static void
630add_setter_action (struct GNUNET_STATISTICS_Handle *h, 630add_setter_action (struct GNUNET_STATISTICS_Handle *h,
631 const char *name, 631 const char *name,
632 int make_persistent, 632 int make_persistent,
633 unsigned long long value, enum ActionType type) 633 uint64_t value, enum ActionType type)
634{ 634{
635 struct ActionItem *ai; 635 struct ActionItem *ai;
636 size_t slen; 636 size_t slen;
@@ -674,7 +674,7 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h,
674void 674void
675GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle, 675GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
676 const char *name, 676 const char *name,
677 unsigned long long value, int make_persistent) 677 uint64_t value, int make_persistent)
678{ 678{
679 add_setter_action (handle, name, make_persistent, value, ACTION_SET); 679 add_setter_action (handle, name, make_persistent, value, ACTION_SET);
680} 680}
@@ -692,7 +692,7 @@ GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
692void 692void
693GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle, 693GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
694 const char *name, 694 const char *name,
695 long long delta, int make_persistent) 695 int64_t delta, int make_persistent)
696{ 696{
697 add_setter_action (handle, name, make_persistent, 697 add_setter_action (handle, name, make_persistent,
698 (unsigned long long) delta, ACTION_UPDATE); 698 (unsigned long long) delta, ACTION_UPDATE);