[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r14833 - in gnunet/src: datastore include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r14833 - in gnunet/src: datastore include |
Date: |
Sun, 3 Apr 2011 17:10:42 +0200 |
Author: grothoff
Date: 2011-04-03 17:10:41 +0200 (Sun, 03 Apr 2011)
New Revision: 14833
Modified:
gnunet/src/datastore/gnunet-service-datastore.c
gnunet/src/datastore/perf_plugin_datastore.c
gnunet/src/datastore/plugin_datastore_mysql.c
gnunet/src/datastore/plugin_datastore_postgres.c
gnunet/src/datastore/plugin_datastore_sqlite.c
gnunet/src/datastore/plugin_datastore_template.c
gnunet/src/include/gnunet_datastore_plugin.h
Log:
new plugin API
Modified: gnunet/src/datastore/gnunet-service-datastore.c
===================================================================
--- gnunet/src/datastore/gnunet-service-datastore.c 2011-04-03 14:12:15 UTC
(rev 14832)
+++ gnunet/src/datastore/gnunet-service-datastore.c 2011-04-03 15:10:41 UTC
(rev 14833)
@@ -953,6 +953,7 @@
ntohl(dm->type),
ntohl(dm->priority),
ntohl(dm->anonymity),
+ 0 /* FIXME: replication */,
GNUNET_TIME_absolute_ntoh(dm->expiration),
&msg);
if (GNUNET_OK == ret)
Modified: gnunet/src/datastore/perf_plugin_datastore.c
===================================================================
--- gnunet/src/datastore/perf_plugin_datastore.c 2011-04-03 14:12:15 UTC
(rev 14832)
+++ gnunet/src/datastore/perf_plugin_datastore.c 2011-04-03 15:10:41 UTC
(rev 14833)
@@ -125,9 +125,10 @@
&key,
size,
value,
- i,
+ i /* type */,
prio,
- i,
+ i /* anonymity */,
+ 0 /* replication */,
GNUNET_TIME_relative_to_absolute
(GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS,
60 * 60 * 60 *
1000 +
Modified: gnunet/src/datastore/plugin_datastore_mysql.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_mysql.c 2011-04-03 14:12:15 UTC
(rev 14832)
+++ gnunet/src/datastore/plugin_datastore_mysql.c 2011-04-03 15:10:41 UTC
(rev 14833)
@@ -1348,6 +1348,7 @@
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to error message
* @return GNUNET_OK on success
@@ -1360,6 +1361,7 @@
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char **msg)
{
@@ -1688,6 +1690,26 @@
/**
+ * Get a random item for replication. Returns a single, not expired, random
item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+static void
+mysql_plugin_replication_get (void *cls,
+ PluginIterator iter, void *iter_cls)
+{
+ /* FIXME: not implemented! */
+ iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
+}
+
+
+/**
* Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in
* the datastore, the higher value should be kept. For the
@@ -1940,6 +1962,7 @@
api->put = &mysql_plugin_put;
api->next_request = &mysql_plugin_next_request;
api->get = &mysql_plugin_get;
+ api->replication_get = &mysql_plugin_replication_get;
api->update = &mysql_plugin_update;
api->iter_low_priority = &mysql_plugin_iter_low_priority;
api->iter_zero_anonymity = &mysql_plugin_iter_zero_anonymity;
Modified: gnunet/src/datastore/plugin_datastore_postgres.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_postgres.c 2011-04-03 14:12:15 UTC
(rev 14832)
+++ gnunet/src/datastore/plugin_datastore_postgres.c 2011-04-03 15:10:41 UTC
(rev 14833)
@@ -587,6 +587,7 @@
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to error message
* @return GNUNET_OK on success
@@ -599,6 +600,7 @@
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char **msg)
{
@@ -1198,6 +1200,26 @@
/**
+ * Get a random item for replication. Returns a single, not expired, random
item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+static void
+postgres_plugin_replication_get (void *cls,
+ PluginIterator iter, void *iter_cls)
+{
+ /* FIXME: not implemented! */
+ iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
+}
+
+
+/**
* Select a subset of the items in the datastore and call
* the given iterator for each of them.
*
@@ -1333,6 +1355,7 @@
api->put = &postgres_plugin_put;
api->next_request = &postgres_plugin_next_request;
api->get = &postgres_plugin_get;
+ api->replication_get = &postgres_plugin_replication_get;
api->update = &postgres_plugin_update;
api->iter_low_priority = &postgres_plugin_iter_low_priority;
api->iter_zero_anonymity = &postgres_plugin_iter_zero_anonymity;
Modified: gnunet/src/datastore/plugin_datastore_sqlite.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_sqlite.c 2011-04-03 14:12:15 UTC
(rev 14832)
+++ gnunet/src/datastore/plugin_datastore_sqlite.c 2011-04-03 15:10:41 UTC
(rev 14833)
@@ -689,6 +689,7 @@
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to an error message
* @return GNUNET_OK on success
@@ -701,6 +702,7 @@
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char ** msg)
{
@@ -1532,6 +1534,26 @@
/**
+ * Get a random item for replication. Returns a single, not expired, random
item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+static void
+sqlite_plugin_replication_get (void *cls,
+ PluginIterator iter, void *iter_cls)
+{
+ /* FIXME: not implemented! */
+ iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
+}
+
+
+/**
* Drop database.
*
* @param cls our plugin context
@@ -1623,6 +1645,7 @@
api->put = &sqlite_plugin_put;
api->next_request = &sqlite_next_request;
api->get = &sqlite_plugin_get;
+ api->replication_get = &sqlite_plugin_replication_get;
api->update = &sqlite_plugin_update;
api->iter_low_priority = &sqlite_plugin_iter_low_priority;
api->iter_zero_anonymity = &sqlite_plugin_iter_zero_anonymity;
Modified: gnunet/src/datastore/plugin_datastore_template.c
===================================================================
--- gnunet/src/datastore/plugin_datastore_template.c 2011-04-03 14:12:15 UTC
(rev 14832)
+++ gnunet/src/datastore/plugin_datastore_template.c 2011-04-03 15:10:41 UTC
(rev 14833)
@@ -64,6 +64,7 @@
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to error message
* @return GNUNET_OK on success
@@ -76,6 +77,7 @@
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char **msg)
{
@@ -133,7 +135,26 @@
}
+
/**
+ * Get a random item for replication. Returns a single, not expired, random
item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+static void
+template_plugin_replication_get (void *cls,
+ PluginIterator iter, void *iter_cls)
+{
+ GNUNET_break (0);
+}
+
+
+/**
* Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in
* the datastore, the higher value should be kept. For the
@@ -308,6 +329,7 @@
api->put = &template_plugin_put;
api->next_request = &template_plugin_next_request;
api->get = &template_plugin_get;
+ api->replication_get = &template_plugin_replication_get;
api->update = &template_plugin_update;
api->iter_low_priority = &template_plugin_iter_low_priority;
api->iter_zero_anonymity = &template_plugin_iter_zero_anonymity;
Modified: gnunet/src/include/gnunet_datastore_plugin.h
===================================================================
--- gnunet/src/include/gnunet_datastore_plugin.h 2011-04-03 14:12:15 UTC
(rev 14832)
+++ gnunet/src/include/gnunet_datastore_plugin.h 2011-04-03 15:10:41 UTC
(rev 14833)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2009 Christian Grothoff (and other contributing authors)
+ (C) 2009, 2011 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -136,8 +136,8 @@
/**
* Store an item in the datastore. If the item is already present,
- * the priorities are summed up and the higher expiration time and
- * lower anonymity level is used.
+ * the priorities and replication levels are summed up and the higher
+ * expiration time and lower anonymity level is used.
*
* @param cls closure
* @param key key for the item
@@ -146,6 +146,7 @@
* @param type type of the content
* @param priority priority of the content
* @param anonymity anonymity-level for the content
+ * @param replication replication-level for the content
* @param expiration expiration time for the content
* @param msg set to an error message (on failure)
* @return GNUNET_OK on success, GNUNET_NO if the content
@@ -159,6 +160,7 @@
enum GNUNET_BLOCK_Type type,
uint32_t priority,
uint32_t anonymity,
+ uint32_t replication,
struct GNUNET_TIME_Absolute expiration,
char **msg);
@@ -191,7 +193,23 @@
PluginIterator iter, void *iter_cls);
+
/**
+ * Get a random item for replication. Returns a single,
+ * not expired, random item
+ * from those with the highest replication counters. The item's
+ * replication counter is decremented by one IF it was positive before.
+ * Call 'iter' with all values ZERO or NULL if the datastore is empty.
+ *
+ * @param cls closure
+ * @param iter function to call the value (once only).
+ * @param iter_cls closure for iter
+ */
+typedef void (*PluginReplicationGet) (void *cls,
+ PluginIterator iter, void *iter_cls);
+
+
+/**
* Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in
* the datastore, the higher value should be kept. For the
@@ -288,6 +306,12 @@
PluginGet get;
/**
+ * Function to get a random item with high replication score from
+ * the database, lowering the item's replication score.
+ */
+ PluginReplicationGet replication_get;
+
+ /**
* Update the priority for a particular key in the datastore. If
* the expiration time in value is different than the time found in
* the datastore, the higher value should be kept. For the
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r14833 - in gnunet/src: datastore include,
gnunet <=