diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-04-03 15:10:41 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-04-03 15:10:41 +0000 |
commit | d2f2c8800aa6ea07a024c5511a1b1d23ad356090 (patch) | |
tree | 244c947db2921817c15d04b6a88a3f843e33d2a3 /src/datastore | |
parent | 745d6c5753f2e5f163220a376d58083b2d7ff76d (diff) | |
download | gnunet-d2f2c8800aa6ea07a024c5511a1b1d23ad356090.tar.gz gnunet-d2f2c8800aa6ea07a024c5511a1b1d23ad356090.zip |
new plugin API
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/gnunet-service-datastore.c | 1 | ||||
-rw-r--r-- | src/datastore/perf_plugin_datastore.c | 5 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_mysql.c | 23 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 23 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_sqlite.c | 23 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_template.c | 22 |
6 files changed, 95 insertions, 2 deletions
diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 82a1f3ded..2538d5ef6 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c | |||
@@ -953,6 +953,7 @@ execute_put (struct GNUNET_SERVER_Client *client, | |||
953 | ntohl(dm->type), | 953 | ntohl(dm->type), |
954 | ntohl(dm->priority), | 954 | ntohl(dm->priority), |
955 | ntohl(dm->anonymity), | 955 | ntohl(dm->anonymity), |
956 | 0 /* FIXME: replication */, | ||
956 | GNUNET_TIME_absolute_ntoh(dm->expiration), | 957 | GNUNET_TIME_absolute_ntoh(dm->expiration), |
957 | &msg); | 958 | &msg); |
958 | if (GNUNET_OK == ret) | 959 | if (GNUNET_OK == ret) |
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index facf7be67..cb25da46b 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c | |||
@@ -125,9 +125,10 @@ putValue (struct GNUNET_DATASTORE_PluginFunctions * api, int i, int k) | |||
125 | &key, | 125 | &key, |
126 | size, | 126 | size, |
127 | value, | 127 | value, |
128 | i, | 128 | i /* type */, |
129 | prio, | 129 | prio, |
130 | i, | 130 | i /* anonymity */, |
131 | 0 /* replication */, | ||
131 | GNUNET_TIME_relative_to_absolute | 132 | GNUNET_TIME_relative_to_absolute |
132 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 133 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
133 | 60 * 60 * 60 * 1000 + | 134 | 60 * 60 * 60 * 1000 + |
diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index ac81c9011..fb1b13978 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c | |||
@@ -1348,6 +1348,7 @@ mysql_plugin_get_size (void *cls) | |||
1348 | * @param type type of the content | 1348 | * @param type type of the content |
1349 | * @param priority priority of the content | 1349 | * @param priority priority of the content |
1350 | * @param anonymity anonymity-level for the content | 1350 | * @param anonymity anonymity-level for the content |
1351 | * @param replication replication-level for the content | ||
1351 | * @param expiration expiration time for the content | 1352 | * @param expiration expiration time for the content |
1352 | * @param msg set to error message | 1353 | * @param msg set to error message |
1353 | * @return GNUNET_OK on success | 1354 | * @return GNUNET_OK on success |
@@ -1360,6 +1361,7 @@ mysql_plugin_put (void *cls, | |||
1360 | enum GNUNET_BLOCK_Type type, | 1361 | enum GNUNET_BLOCK_Type type, |
1361 | uint32_t priority, | 1362 | uint32_t priority, |
1362 | uint32_t anonymity, | 1363 | uint32_t anonymity, |
1364 | uint32_t replication, | ||
1363 | struct GNUNET_TIME_Absolute expiration, | 1365 | struct GNUNET_TIME_Absolute expiration, |
1364 | char **msg) | 1366 | char **msg) |
1365 | { | 1367 | { |
@@ -1688,6 +1690,26 @@ mysql_plugin_get (void *cls, | |||
1688 | 1690 | ||
1689 | 1691 | ||
1690 | /** | 1692 | /** |
1693 | * Get a random item for replication. Returns a single, not expired, random item | ||
1694 | * from those with the highest replication counters. The item's | ||
1695 | * replication counter is decremented by one IF it was positive before. | ||
1696 | * Call 'iter' with all values ZERO or NULL if the datastore is empty. | ||
1697 | * | ||
1698 | * @param cls closure | ||
1699 | * @param iter function to call the value (once only). | ||
1700 | * @param iter_cls closure for iter | ||
1701 | */ | ||
1702 | static void | ||
1703 | mysql_plugin_replication_get (void *cls, | ||
1704 | PluginIterator iter, void *iter_cls) | ||
1705 | { | ||
1706 | /* FIXME: not implemented! */ | ||
1707 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, | ||
1708 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
1709 | } | ||
1710 | |||
1711 | |||
1712 | /** | ||
1691 | * Update the priority for a particular key in the datastore. If | 1713 | * Update the priority for a particular key in the datastore. If |
1692 | * the expiration time in value is different than the time found in | 1714 | * the expiration time in value is different than the time found in |
1693 | * the datastore, the higher value should be kept. For the | 1715 | * the datastore, the higher value should be kept. For the |
@@ -1940,6 +1962,7 @@ libgnunet_plugin_datastore_mysql_init (void *cls) | |||
1940 | api->put = &mysql_plugin_put; | 1962 | api->put = &mysql_plugin_put; |
1941 | api->next_request = &mysql_plugin_next_request; | 1963 | api->next_request = &mysql_plugin_next_request; |
1942 | api->get = &mysql_plugin_get; | 1964 | api->get = &mysql_plugin_get; |
1965 | api->replication_get = &mysql_plugin_replication_get; | ||
1943 | api->update = &mysql_plugin_update; | 1966 | api->update = &mysql_plugin_update; |
1944 | api->iter_low_priority = &mysql_plugin_iter_low_priority; | 1967 | api->iter_low_priority = &mysql_plugin_iter_low_priority; |
1945 | api->iter_zero_anonymity = &mysql_plugin_iter_zero_anonymity; | 1968 | api->iter_zero_anonymity = &mysql_plugin_iter_zero_anonymity; |
diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 18ad77885..c004cd59f 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c | |||
@@ -587,6 +587,7 @@ postgres_plugin_get_size (void *cls) | |||
587 | * @param type type of the content | 587 | * @param type type of the content |
588 | * @param priority priority of the content | 588 | * @param priority priority of the content |
589 | * @param anonymity anonymity-level for the content | 589 | * @param anonymity anonymity-level for the content |
590 | * @param replication replication-level for the content | ||
590 | * @param expiration expiration time for the content | 591 | * @param expiration expiration time for the content |
591 | * @param msg set to error message | 592 | * @param msg set to error message |
592 | * @return GNUNET_OK on success | 593 | * @return GNUNET_OK on success |
@@ -599,6 +600,7 @@ postgres_plugin_put (void *cls, | |||
599 | enum GNUNET_BLOCK_Type type, | 600 | enum GNUNET_BLOCK_Type type, |
600 | uint32_t priority, | 601 | uint32_t priority, |
601 | uint32_t anonymity, | 602 | uint32_t anonymity, |
603 | uint32_t replication, | ||
602 | struct GNUNET_TIME_Absolute expiration, | 604 | struct GNUNET_TIME_Absolute expiration, |
603 | char **msg) | 605 | char **msg) |
604 | { | 606 | { |
@@ -1198,6 +1200,26 @@ postgres_plugin_get (void *cls, | |||
1198 | 1200 | ||
1199 | 1201 | ||
1200 | /** | 1202 | /** |
1203 | * Get a random item for replication. Returns a single, not expired, random item | ||
1204 | * from those with the highest replication counters. The item's | ||
1205 | * replication counter is decremented by one IF it was positive before. | ||
1206 | * Call 'iter' with all values ZERO or NULL if the datastore is empty. | ||
1207 | * | ||
1208 | * @param cls closure | ||
1209 | * @param iter function to call the value (once only). | ||
1210 | * @param iter_cls closure for iter | ||
1211 | */ | ||
1212 | static void | ||
1213 | postgres_plugin_replication_get (void *cls, | ||
1214 | PluginIterator iter, void *iter_cls) | ||
1215 | { | ||
1216 | /* FIXME: not implemented! */ | ||
1217 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, | ||
1218 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
1219 | } | ||
1220 | |||
1221 | |||
1222 | /** | ||
1201 | * Select a subset of the items in the datastore and call | 1223 | * Select a subset of the items in the datastore and call |
1202 | * the given iterator for each of them. | 1224 | * the given iterator for each of them. |
1203 | * | 1225 | * |
@@ -1333,6 +1355,7 @@ libgnunet_plugin_datastore_postgres_init (void *cls) | |||
1333 | api->put = &postgres_plugin_put; | 1355 | api->put = &postgres_plugin_put; |
1334 | api->next_request = &postgres_plugin_next_request; | 1356 | api->next_request = &postgres_plugin_next_request; |
1335 | api->get = &postgres_plugin_get; | 1357 | api->get = &postgres_plugin_get; |
1358 | api->replication_get = &postgres_plugin_replication_get; | ||
1336 | api->update = &postgres_plugin_update; | 1359 | api->update = &postgres_plugin_update; |
1337 | api->iter_low_priority = &postgres_plugin_iter_low_priority; | 1360 | api->iter_low_priority = &postgres_plugin_iter_low_priority; |
1338 | api->iter_zero_anonymity = &postgres_plugin_iter_zero_anonymity; | 1361 | api->iter_zero_anonymity = &postgres_plugin_iter_zero_anonymity; |
diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index 0eba474f6..260bd54cc 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c | |||
@@ -689,6 +689,7 @@ sqlite_next_request (void *next_cls, | |||
689 | * @param type type of the content | 689 | * @param type type of the content |
690 | * @param priority priority of the content | 690 | * @param priority priority of the content |
691 | * @param anonymity anonymity-level for the content | 691 | * @param anonymity anonymity-level for the content |
692 | * @param replication replication-level for the content | ||
692 | * @param expiration expiration time for the content | 693 | * @param expiration expiration time for the content |
693 | * @param msg set to an error message | 694 | * @param msg set to an error message |
694 | * @return GNUNET_OK on success | 695 | * @return GNUNET_OK on success |
@@ -701,6 +702,7 @@ sqlite_plugin_put (void *cls, | |||
701 | enum GNUNET_BLOCK_Type type, | 702 | enum GNUNET_BLOCK_Type type, |
702 | uint32_t priority, | 703 | uint32_t priority, |
703 | uint32_t anonymity, | 704 | uint32_t anonymity, |
705 | uint32_t replication, | ||
704 | struct GNUNET_TIME_Absolute expiration, | 706 | struct GNUNET_TIME_Absolute expiration, |
705 | char ** msg) | 707 | char ** msg) |
706 | { | 708 | { |
@@ -1532,6 +1534,26 @@ sqlite_plugin_get (void *cls, | |||
1532 | 1534 | ||
1533 | 1535 | ||
1534 | /** | 1536 | /** |
1537 | * Get a random item for replication. Returns a single, not expired, random item | ||
1538 | * from those with the highest replication counters. The item's | ||
1539 | * replication counter is decremented by one IF it was positive before. | ||
1540 | * Call 'iter' with all values ZERO or NULL if the datastore is empty. | ||
1541 | * | ||
1542 | * @param cls closure | ||
1543 | * @param iter function to call the value (once only). | ||
1544 | * @param iter_cls closure for iter | ||
1545 | */ | ||
1546 | static void | ||
1547 | sqlite_plugin_replication_get (void *cls, | ||
1548 | PluginIterator iter, void *iter_cls) | ||
1549 | { | ||
1550 | /* FIXME: not implemented! */ | ||
1551 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, | ||
1552 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
1553 | } | ||
1554 | |||
1555 | |||
1556 | /** | ||
1535 | * Drop database. | 1557 | * Drop database. |
1536 | * | 1558 | * |
1537 | * @param cls our plugin context | 1559 | * @param cls our plugin context |
@@ -1623,6 +1645,7 @@ libgnunet_plugin_datastore_sqlite_init (void *cls) | |||
1623 | api->put = &sqlite_plugin_put; | 1645 | api->put = &sqlite_plugin_put; |
1624 | api->next_request = &sqlite_next_request; | 1646 | api->next_request = &sqlite_next_request; |
1625 | api->get = &sqlite_plugin_get; | 1647 | api->get = &sqlite_plugin_get; |
1648 | api->replication_get = &sqlite_plugin_replication_get; | ||
1626 | api->update = &sqlite_plugin_update; | 1649 | api->update = &sqlite_plugin_update; |
1627 | api->iter_low_priority = &sqlite_plugin_iter_low_priority; | 1650 | api->iter_low_priority = &sqlite_plugin_iter_low_priority; |
1628 | api->iter_zero_anonymity = &sqlite_plugin_iter_zero_anonymity; | 1651 | api->iter_zero_anonymity = &sqlite_plugin_iter_zero_anonymity; |
diff --git a/src/datastore/plugin_datastore_template.c b/src/datastore/plugin_datastore_template.c index 09dfe85d9..fc67f600e 100644 --- a/src/datastore/plugin_datastore_template.c +++ b/src/datastore/plugin_datastore_template.c | |||
@@ -64,6 +64,7 @@ static unsigned long long template_plugin_get_size (void *cls) | |||
64 | * @param type type of the content | 64 | * @param type type of the content |
65 | * @param priority priority of the content | 65 | * @param priority priority of the content |
66 | * @param anonymity anonymity-level for the content | 66 | * @param anonymity anonymity-level for the content |
67 | * @param replication replication-level for the content | ||
67 | * @param expiration expiration time for the content | 68 | * @param expiration expiration time for the content |
68 | * @param msg set to error message | 69 | * @param msg set to error message |
69 | * @return GNUNET_OK on success | 70 | * @return GNUNET_OK on success |
@@ -76,6 +77,7 @@ template_plugin_put (void *cls, | |||
76 | enum GNUNET_BLOCK_Type type, | 77 | enum GNUNET_BLOCK_Type type, |
77 | uint32_t priority, | 78 | uint32_t priority, |
78 | uint32_t anonymity, | 79 | uint32_t anonymity, |
80 | uint32_t replication, | ||
79 | struct GNUNET_TIME_Absolute expiration, | 81 | struct GNUNET_TIME_Absolute expiration, |
80 | char **msg) | 82 | char **msg) |
81 | { | 83 | { |
@@ -133,6 +135,25 @@ template_plugin_get (void *cls, | |||
133 | } | 135 | } |
134 | 136 | ||
135 | 137 | ||
138 | |||
139 | /** | ||
140 | * Get a random item for replication. Returns a single, not expired, random item | ||
141 | * from those with the highest replication counters. The item's | ||
142 | * replication counter is decremented by one IF it was positive before. | ||
143 | * Call 'iter' with all values ZERO or NULL if the datastore is empty. | ||
144 | * | ||
145 | * @param cls closure | ||
146 | * @param iter function to call the value (once only). | ||
147 | * @param iter_cls closure for iter | ||
148 | */ | ||
149 | static void | ||
150 | template_plugin_replication_get (void *cls, | ||
151 | PluginIterator iter, void *iter_cls) | ||
152 | { | ||
153 | GNUNET_break (0); | ||
154 | } | ||
155 | |||
156 | |||
136 | /** | 157 | /** |
137 | * Update the priority for a particular key in the datastore. If | 158 | * Update the priority for a particular key in the datastore. If |
138 | * the expiration time in value is different than the time found in | 159 | * the expiration time in value is different than the time found in |
@@ -308,6 +329,7 @@ libgnunet_plugin_datastore_template_init (void *cls) | |||
308 | api->put = &template_plugin_put; | 329 | api->put = &template_plugin_put; |
309 | api->next_request = &template_plugin_next_request; | 330 | api->next_request = &template_plugin_next_request; |
310 | api->get = &template_plugin_get; | 331 | api->get = &template_plugin_get; |
332 | api->replication_get = &template_plugin_replication_get; | ||
311 | api->update = &template_plugin_update; | 333 | api->update = &template_plugin_update; |
312 | api->iter_low_priority = &template_plugin_iter_low_priority; | 334 | api->iter_low_priority = &template_plugin_iter_low_priority; |
313 | api->iter_zero_anonymity = &template_plugin_iter_zero_anonymity; | 335 | api->iter_zero_anonymity = &template_plugin_iter_zero_anonymity; |