aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-04-03 20:00:42 +0000
committerChristian Grothoff <christian@grothoff.org>2011-04-03 20:00:42 +0000
commite8f35bb025c25839a52fb502e452393831e4e6f0 (patch)
tree7a056253bddc61b1e6a3258567e176af128c2b67 /src/include
parent9f871785d57da57ba128ac2279fda1db1d9b8bfb (diff)
downloadgnunet-e8f35bb025c25839a52fb502e452393831e4e6f0.tar.gz
gnunet-e8f35bb025c25839a52fb502e452393831e4e6f0.zip
improving datastore API --- not working yet
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_datastore_plugin.h64
-rw-r--r--src/include/gnunet_datastore_service.h88
2 files changed, 74 insertions, 78 deletions
diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h
index c981ceb1d..34a659163 100644
--- a/src/include/gnunet_datastore_plugin.h
+++ b/src/include/gnunet_datastore_plugin.h
@@ -162,7 +162,7 @@ typedef int (*PluginPut) (void *cls,
162 uint32_t anonymity, 162 uint32_t anonymity,
163 uint32_t replication, 163 uint32_t replication,
164 struct GNUNET_TIME_Absolute expiration, 164 struct GNUNET_TIME_Absolute expiration,
165 char **msg); 165 char **msg);
166 166
167 167
168/** 168/**
@@ -187,26 +187,25 @@ typedef int (*PluginPut) (void *cls,
187 * @param iter_cls closure for iter 187 * @param iter_cls closure for iter
188 */ 188 */
189typedef void (*PluginGet) (void *cls, 189typedef void (*PluginGet) (void *cls,
190 const GNUNET_HashCode * key, 190 const GNUNET_HashCode *key,
191 const GNUNET_HashCode * vhash, 191 const GNUNET_HashCode *vhash,
192 enum GNUNET_BLOCK_Type type, 192 enum GNUNET_BLOCK_Type type,
193 PluginIterator iter, void *iter_cls); 193 PluginIterator iter, void *iter_cls);
194 194
195 195
196 196
197/** 197/**
198 * Get a random item for replication. Returns a single, 198 * Get a random item (additional constraints may apply depending on
199 * not expired, random item 199 * the specific implementation). Calls 'iter' with all values ZERO or
200 * from those with the highest replication counters. The item's 200 * NULL if no item applies, otherwise 'iter' is called once and only
201 * replication counter is decremented by one IF it was positive before. 201 * once with an item, with the 'next_cls' argument being NULL.
202 * Call 'iter' with all values ZERO or NULL if the datastore is empty.
203 * 202 *
204 * @param cls closure 203 * @param cls closure
205 * @param iter function to call the value (once only). 204 * @param iter function to call the value (once only).
206 * @param iter_cls closure for iter 205 * @param iter_cls closure for iter
207 */ 206 */
208typedef void (*PluginReplicationGet) (void *cls, 207typedef void (*PluginRandomGet) (void *cls,
209 PluginIterator iter, void *iter_cls); 208 PluginIterator iter, void *iter_cls);
210 209
211 210
212/** 211/**
@@ -234,13 +233,16 @@ typedef void (*PluginReplicationGet) (void *cls,
234 */ 233 */
235typedef int (*PluginUpdate) (void *cls, 234typedef int (*PluginUpdate) (void *cls,
236 uint64_t uid, 235 uint64_t uid,
237 int delta, struct GNUNET_TIME_Absolute expire, 236 int delta,
237 struct GNUNET_TIME_Absolute expire,
238 char **msg); 238 char **msg);
239 239
240 240
241/** 241/**
242 * Select a subset of the items in the datastore and call 242 * Select a subset of the items in the datastore and call the given
243 * the given iterator for each of them. 243 * iterator for the first item; then allow getting more items by
244 * calling the 'next_request' callback with the given 'next_cls'
245 * argument passed to 'iter'.
244 * 246 *
245 * @param cls closure 247 * @param cls closure
246 * @param type entries of which type should be considered? 248 * @param type entries of which type should be considered?
@@ -258,6 +260,7 @@ typedef void (*PluginSelector) (void *cls,
258 PluginIterator iter, 260 PluginIterator iter,
259 void *iter_cls); 261 void *iter_cls);
260 262
263
261/** 264/**
262 * Drop database. 265 * Drop database.
263 * 266 *
@@ -307,9 +310,18 @@ struct GNUNET_DATASTORE_PluginFunctions
307 310
308 /** 311 /**
309 * Function to get a random item with high replication score from 312 * Function to get a random item with high replication score from
310 * the database, lowering the item's replication score. 313 * the database, lowering the item's replication score. Returns a
314 * single, not expired, random item from those with the highest
315 * replication counters. The item's replication counter is
316 * decremented by one IF it was positive before.
317 */
318 PluginRandomGet replication_get;
319
320 /**
321 * Function to get a random expired item or, if none are expired, one
322 * with a low priority.
311 */ 323 */
312 PluginReplicationGet replication_get; 324 PluginRandomGet expiration_get;
313 325
314 /** 326 /**
315 * Update the priority for a particular key in the datastore. If 327 * Update the priority for a particular key in the datastore. If
@@ -322,31 +334,11 @@ struct GNUNET_DATASTORE_PluginFunctions
322 PluginUpdate update; 334 PluginUpdate update;
323 335
324 /** 336 /**
325 * Iterate over the items in the datastore in ascending 337 * Iterate over content with anonymity level zero.
326 * order of priority.
327 */
328 PluginSelector iter_low_priority;
329
330 /**
331 * Iterate over content with anonymity zero.
332 */ 338 */
333 PluginSelector iter_zero_anonymity; 339 PluginSelector iter_zero_anonymity;
334 340
335 /** 341 /**
336 * Iterate over the items in the datastore in ascending order of
337 * expiration time.
338 */
339 PluginSelector iter_ascending_expiration;
340
341 /**
342 * Iterate over the items in the datastore in migration
343 * order. Call the given function on the next item only
344 * (and then signal 'end' with a second call). This is
345 * a significant difference from all the other iterators!
346 */
347 PluginSelector iter_migration_order;
348
349 /**
350 * Iterate over all the items in the datastore 342 * Iterate over all the items in the datastore
351 * as fast as possible in a single transaction 343 * as fast as possible in a single transaction
352 * (can lock datastore while this happens, focus 344 * (can lock datastore while this happens, focus
diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h
index 1e2e9e050..284d544f5 100644
--- a/src/include/gnunet_datastore_service.h
+++ b/src/include/gnunet_datastore_service.h
@@ -82,11 +82,11 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h,
82 * @param cls closure 82 * @param cls closure
83 * @param success GNUNET_SYSERR on failure, 83 * @param success GNUNET_SYSERR on failure,
84 * GNUNET_NO on timeout/queue drop 84 * GNUNET_NO on timeout/queue drop
85 * GNUNET_YES on success 85 * GNUNET_YES (or other positive value) on success
86 * @param msg NULL on success, otherwise an error message 86 * @param msg NULL on success, otherwise an error message
87 */ 87 */
88typedef void (*GNUNET_DATASTORE_ContinuationWithStatus)(void *cls, 88typedef void (*GNUNET_DATASTORE_ContinuationWithStatus)(void *cls,
89 int success, 89 int32_t success,
90 const char *msg); 90 const char *msg);
91 91
92 92
@@ -148,7 +148,7 @@ GNUNET_DATASTORE_reserve (struct GNUNET_DATASTORE_Handle *h,
148 */ 148 */
149struct GNUNET_DATASTORE_QueueEntry * 149struct GNUNET_DATASTORE_QueueEntry *
150GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, 150GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
151 int rid, 151 uint32_t rid,
152 const GNUNET_HashCode * key, 152 const GNUNET_HashCode * key,
153 size_t size, 153 size_t size,
154 const void *data, 154 const void *data,
@@ -187,7 +187,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h,
187 */ 187 */
188struct GNUNET_DATASTORE_QueueEntry * 188struct GNUNET_DATASTORE_QueueEntry *
189GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h, 189GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h,
190 int rid, 190 uint32_t rid,
191 unsigned int queue_priority, 191 unsigned int queue_priority,
192 unsigned int max_queue_size, 192 unsigned int max_queue_size,
193 struct GNUNET_TIME_Relative timeout, 193 struct GNUNET_TIME_Relative timeout,
@@ -214,7 +214,7 @@ GNUNET_DATASTORE_release_reserve (struct GNUNET_DATASTORE_Handle *h,
214 */ 214 */
215struct GNUNET_DATASTORE_QueueEntry * 215struct GNUNET_DATASTORE_QueueEntry *
216GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h, 216GNUNET_DATASTORE_update (struct GNUNET_DATASTORE_Handle *h,
217 unsigned long long uid, 217 uint64_t uid,
218 uint32_t priority, 218 uint32_t priority,
219 struct GNUNET_TIME_Absolute expiration, 219 struct GNUNET_TIME_Absolute expiration,
220 unsigned int queue_priority, 220 unsigned int queue_priority,
@@ -287,7 +287,7 @@ typedef void (*GNUNET_DATASTORE_Iterator) (void *cls,
287 * in the datastore. The iterator will only be called 287 * in the datastore. The iterator will only be called
288 * once initially; if the first call did contain a 288 * once initially; if the first call did contain a
289 * result, further results can be obtained by calling 289 * result, further results can be obtained by calling
290 * "GNUNET_DATASTORE_get_next" with the given argument. 290 * "GNUNET_DATASTORE_iterate_get_next" with the given argument.
291 * 291 *
292 * @param h handle to the datastore 292 * @param h handle to the datastore
293 * @param key maybe NULL (to match all entries) 293 * @param key maybe NULL (to match all entries)
@@ -304,24 +304,54 @@ typedef void (*GNUNET_DATASTORE_Iterator) (void *cls,
304 * (or rather, will already have been invoked) 304 * (or rather, will already have been invoked)
305 */ 305 */
306struct GNUNET_DATASTORE_QueueEntry * 306struct GNUNET_DATASTORE_QueueEntry *
307GNUNET_DATASTORE_get (struct GNUNET_DATASTORE_Handle *h, 307GNUNET_DATASTORE_iterate_key (struct GNUNET_DATASTORE_Handle *h,
308 const GNUNET_HashCode * key, 308 const GNUNET_HashCode * key,
309 enum GNUNET_BLOCK_Type type, 309 enum GNUNET_BLOCK_Type type,
310 unsigned int queue_priority, 310 unsigned int queue_priority,
311 unsigned int max_queue_size, 311 unsigned int max_queue_size,
312 struct GNUNET_TIME_Relative timeout, 312 struct GNUNET_TIME_Relative timeout,
313 GNUNET_DATASTORE_Iterator iter, 313 GNUNET_DATASTORE_Iterator iter,
314 void *iter_cls); 314 void *iter_cls);
315
316
317/**
318 * Get all zero-anonymity values from the datastore.
319 *
320 * @param h handle to the datastore
321 * @param queue_priority ranking of this request in the priority queue
322 * @param max_queue_size at what queue size should this request be dropped
323 * (if other requests of higher priority are in the queue)
324 * @param timeout how long to wait at most for a response
325 * @param type allowed type for the operation (ANY for 'all types')
326 * @param iter function to call on a random value; it
327 * will be called once with a value (if available)
328 * and always once with a value of NULL at the end.
329 * @param iter_cls closure for iter
330 * @return NULL if the entry was not queued, otherwise a handle that can be used to
331 * cancel; note that even if NULL is returned, the callback will be invoked
332 * (or rather, will already have been invoked)
333 */
334struct GNUNET_DATASTORE_QueueEntry *
335GNUNET_DATASTORE_iterate_zero_anonymity (struct GNUNET_DATASTORE_Handle *h,
336 unsigned int queue_priority,
337 unsigned int max_queue_size,
338 struct GNUNET_TIME_Relative timeout,
339 enum GNUNET_BLOCK_Type type,
340 GNUNET_DATASTORE_Iterator iter,
341 void *iter_cls);
315 342
316 343
317/** 344/**
318 * Function called to trigger obtaining the next result 345 * Function called to trigger obtaining the next result
319 * from the datastore. 346 * from the datastore. ONLY applies for 'GNUNET_DATASTORE_iterate_*'
347 * calls, not for 'get' calls. FIXME: how much mixing of iterate
348 * calls with other operations can we permit!? Should we pass
349 * the 'QueueEntry' instead of the datastore handle here instead?
320 * 350 *
321 * @param h handle to the datastore 351 * @param h handle to the datastore
322 */ 352 */
323void 353void
324GNUNET_DATASTORE_get_next (struct GNUNET_DATASTORE_Handle *h); 354GNUNET_DATASTORE_iterate_get_next (struct GNUNET_DATASTORE_Handle *h);
325 355
326 356
327/** 357/**
@@ -353,32 +383,6 @@ GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h,
353 void *iter_cls); 383 void *iter_cls);
354 384
355 385
356/**
357 * Get a zero-anonymity value from the datastore.
358 *
359 * @param h handle to the datastore
360 * @param queue_priority ranking of this request in the priority queue
361 * @param max_queue_size at what queue size should this request be dropped
362 * (if other requests of higher priority are in the queue)
363 * @param timeout how long to wait at most for a response
364 * @param type allowed type for the operation
365 * @param iter function to call on a random value; it
366 * will be called once with a value (if available)
367 * and always once with a value of NULL.
368 * @param iter_cls closure for iter
369 * @return NULL if the entry was not queued, otherwise a handle that can be used to
370 * cancel; note that even if NULL is returned, the callback will be invoked
371 * (or rather, will already have been invoked)
372 */
373struct GNUNET_DATASTORE_QueueEntry *
374GNUNET_DATASTORE_get_zero_anonymity (struct GNUNET_DATASTORE_Handle *h,
375 unsigned int queue_priority,
376 unsigned int max_queue_size,
377 struct GNUNET_TIME_Relative timeout,
378 enum GNUNET_BLOCK_Type type,
379 GNUNET_DATASTORE_Iterator iter,
380 void *iter_cls);
381
382 386
383/** 387/**
384 * Cancel a datastore operation. The final callback from the 388 * Cancel a datastore operation. The final callback from the