extra debug for datastore, stats api fix
authorChristian Grothoff <christian@grothoff.org>
Wed, 21 Oct 2009 12:44:37 +0000 (12:44 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 21 Oct 2009 12:44:37 +0000 (12:44 +0000)
src/datastore/Makefile.am
src/datastore/gnunet-service-datastore.c
src/datastore/plugin_datastore_sqlite.c
src/hostlist/hostlist-client.c
src/include/gnunet_statistics_service.h
src/statistics/gnunet-statistics.c
src/statistics/statistics_api.c

index 1ca588926f871c817005af165b5d81189cd13a39..608fb7770c6cb41a91e8a3731f16745359ab9c3d 100644 (file)
@@ -44,6 +44,7 @@ libgnunet_plugin_datastore_sqlite_la_SOURCES = \
   plugin_datastore_sqlite.c
 libgnunet_plugin_datastore_sqlite_la_LIBADD = \
   $(top_builddir)/src/statistics/libgnunetstatistics.la \
+  $(top_builddir)/src/arm/libgnunetarm.la \
   $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3
 libgnunet_plugin_datastore_sqlite_la_LDFLAGS = \
  $(GN_PLUGIN_LDFLAGS)
index 0fe1263ce4263b02a108eef7197c503a44bafadd..c895bb1c845e695ec6a51b7929dccc2b39f6e137 100644 (file)
@@ -134,11 +134,10 @@ static int reservation_gen;
 static unsigned long long quota;
 
 /**
- * How much space are we using for the cache?
- * (space available for insertions that will be
- *  instantly reclaimed by discarding less 
- *  important content --- or possibly whatever
- *  we just inserted into the "cache").
+ * How much space are we using for the cache?  (space available for
+ * insertions that will be instantly reclaimed by discarding less
+ * important content --- or possibly whatever we just inserted into
+ * the "cache").
  */
 static unsigned long long cache_size;
 
@@ -354,7 +353,7 @@ manage (void *cls,
                             (0 == *need) ? GNUNET_YES : GNUNET_NO);
 #if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Deleting %llu bytes of low-priority content (still trying to recover %llu bytes)\n",
+             "Deleting %llu bytes of low-priority content (still trying to free another %llu bytes)\n",
              size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
              *need);
 #endif
@@ -383,7 +382,7 @@ manage_space (unsigned long long need)
 
 #if DEBUG_DATASTORE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Asked to recover %llu bytes of cache space\n",
+             "Asked to free up %llu bytes of cache space\n",
              need);
 #endif
   n = GNUNET_malloc (sizeof(unsigned long long));
index 2223dd6ebd28e4228ff3783b418d255383b78689..b5d5990c682f9f3b6bf499327e3f8f8d401fd63a 100644 (file)
  */
 
 #include "platform.h"
+#include "gnunet_arm_service.h"
 #include "gnunet_statistics_service.h"
 #include "plugin_datastore.h"
 #include <sqlite3.h>
 
-#define DEBUG_SQLITE GNUNET_NO
+#define DEBUG_SQLITE GNUNET_YES
 
 /**
  * After how many payload-changing operations
@@ -614,11 +615,28 @@ sqlite_next_request_cont (void *cls,
       nc->end_it = GNUNET_YES;
       return;
     }
+#if DEBUG_SQLITE
+  if (ret == GNUNET_NO)
+    GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                    "sqlite",
+                    "Asked to remove entry %llu (%u bytes)\n",
+                    (unsigned long long) rowid,
+                    size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
+#endif
   if ( (ret == GNUNET_NO) &&
        (GNUNET_OK == delete_by_rowid (plugin, rowid)) )
     {
       plugin->payload -= (size + GNUNET_DATASTORE_ENTRY_OVERHEAD);
       plugin->lastSync++; 
+#if DEBUG_SQLITE
+      if (ret == GNUNET_NO)
+       GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                        "sqlite",
+                        "Removed entry %llu (%u bytes), new payload is %llu\n",
+                        (unsigned long long) rowid,
+                        size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
+                        (unsigned long long) plugin->payload);
+#endif
       if (plugin->lastSync >= MAX_STAT_SYNC_LAG)
        sync_stats (plugin);
     }
@@ -741,6 +759,13 @@ sqlite_plugin_put (void *cls,
                 GNUNET_ERROR_TYPE_BULK, "sqlite3_reset");
   plugin->lastSync++;
   plugin->payload += size + GNUNET_DATASTORE_ENTRY_OVERHEAD;
+#if DEBUG_SQLITE
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                  "sqlite",
+                  "Stored new entry (%u bytes), new payload is %llu\n",
+                  size + GNUNET_DATASTORE_ENTRY_OVERHEAD,
+                  (unsigned long long) plugin->payload);
+#endif
   if (plugin->lastSync >= MAX_STAT_SYNC_LAG)
     sync_stats (plugin);
   return GNUNET_OK;
@@ -1522,11 +1547,18 @@ static int
 process_stat_in (void *cls,
                 const char *subsystem,
                 const char *name,
-                unsigned long long value,
+                uint64_t value,
                 int is_persistent)
 {
   struct Plugin *plugin = cls;
   plugin->payload += value;
+#if DEBUG_SQLITE
+  GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
+                  "sqlite",
+                  "Notification from statistics about existing payload (%llu), new payload is %llu\n",
+                  value,
+                  (unsigned long long) plugin->payload);
+#endif
   return GNUNET_OK;
 }
                                         
@@ -1548,6 +1580,7 @@ libgnunet_plugin_datastore_sqlite_init (void *cls)
     return NULL; /* can only initialize once! */
   memset (&plugin, 0, sizeof(struct Plugin));
   plugin.env = env;
+  GNUNET_ARM_start_services (env->cfg, env->sched, "statistics");
   plugin.statistics = GNUNET_STATISTICS_create (env->sched,
                                                "sqlite",
                                                env->cfg);
@@ -1562,6 +1595,7 @@ libgnunet_plugin_datastore_sqlite_init (void *cls)
       database_setup (env->cfg, &plugin))
     {
       database_shutdown (&plugin);
+      GNUNET_ARM_stop_services (env->cfg, env->sched, "statistics");
       return NULL;
     }
   api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions));
@@ -1603,6 +1637,7 @@ libgnunet_plugin_datastore_sqlite_done (void *cls)
   plugin->env = NULL; 
   plugin->payload = 0;
   GNUNET_STATISTICS_destroy (plugin->statistics);
+  GNUNET_ARM_stop_services (plugin->env->cfg, plugin->env->sched, "statistics");
   GNUNET_free (api);
   if (fn != NULL)
     {
index db7d1c58618c7e03da6a421d1dbdf1b90741a980..e0ff1f5a24b3098c488945240fe822ed19ea1958 100644 (file)
@@ -607,10 +607,10 @@ static int
 process_stat (void *cls,
              const char *subsystem,
              const char *name,
-             unsigned long long value,
+             uint64_t value,
              int is_persistent)
 {
-  hostlist_delay.value = (uint64_t) value;
+  hostlist_delay.value = value;
   return GNUNET_OK;
 }
 
index 2496f4091f2eef7516dca04e974fe8c0e9c2fd6b..d8f17b8a1ef51b43a0705b0e4194e6a2ce80f81c 100644 (file)
@@ -64,7 +64,7 @@ struct GNUNET_STATISTICS_Handle;
 typedef int (*GNUNET_STATISTICS_Iterator) (void *cls,
                                            const char *subsystem,
                                            const char *name,
-                                           unsigned long long value,
+                                           uint64_t value,
                                            int is_persistent);
 
 /**
@@ -129,7 +129,7 @@ GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle,
 void
 GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
                        const char *name,
-                       unsigned long long value, int make_persistent);
+                       uint64_t value, int make_persistent);
 
 /**
  * Set statistic value for the peer.  Will always use our
@@ -143,7 +143,7 @@ GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
 void
 GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
                           const char *name,
-                          long long delta, int make_persistent);
+                          int64_t delta, int make_persistent);
 
 
 
index bea9ca0cac999b80af87f6c1aea11bc1dd971908..dd9850418db3ba9a6ac77a3cc0178f75286d8667 100644 (file)
@@ -65,11 +65,13 @@ static int persistent;
 static int
 printer (void *cls,
          const char *subsystem,
-         const char *name, unsigned long long value, int is_persistent)
+         const char *name, 
+        uint64_t value, int is_persistent)
 {
   FPRINTF (stdout,
            "%s%-20s %-40s: %16llu\n",
-           is_persistent ? "!" : " ", subsystem, _(name), value);
+           is_persistent ? "!" : " ", subsystem, _(name),
+          (unsigned long long) value);
   return GNUNET_OK;
 }
 
@@ -127,7 +129,7 @@ run (void *cls,
           ret = 1;
           return;
         }
-      GNUNET_STATISTICS_set (h, name, val, persistent);
+      GNUNET_STATISTICS_set (h, name, (uint64_t) val, persistent);
       GNUNET_STATISTICS_destroy (h);
       return;
     }
index 335cd41652ce4b15fabc4e730bf60a4f44730111..21b8ecd8ab782607ff63a913ff7156c217e3a2ab 100644 (file)
@@ -88,7 +88,7 @@ struct ActionItem
   /**
    * Associated value.
    */
-  unsigned long long value;
+  uint64_t value;
 
   /**
    * Flag for SET/UPDATE actions.
@@ -630,7 +630,7 @@ static void
 add_setter_action (struct GNUNET_STATISTICS_Handle *h,
                    const char *name,
                    int make_persistent,
-                   unsigned long long value, enum ActionType type)
+                   uint64_t value, enum ActionType type)
 {
   struct ActionItem *ai;
   size_t slen;
@@ -674,7 +674,7 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h,
 void
 GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
                        const char *name,
-                       unsigned long long value, int make_persistent)
+                       uint64_t value, int make_persistent)
 {
   add_setter_action (handle, name, make_persistent, value, ACTION_SET);
 }
@@ -692,7 +692,7 @@ GNUNET_STATISTICS_set (struct GNUNET_STATISTICS_Handle *handle,
 void
 GNUNET_STATISTICS_update (struct GNUNET_STATISTICS_Handle *handle,
                           const char *name,
-                          long long delta, int make_persistent)
+                          int64_t delta, int make_persistent)
 {
   add_setter_action (handle, name, make_persistent,
                      (unsigned long long) delta, ACTION_UPDATE);