From 8c23a185ee8d3c16c5552668dced851f82986041 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 3 Apr 2011 13:47:56 +0000 Subject: changing datastore API to support replication level --- not fully implemented --- and adding GNUNET_FS_BlockOptions struct to replace prio/anonymity/expiration+replication args --- src/datastore/datastore_api.c | 20 +++++++++++++------- src/datastore/perf_datastore_api.c | 12 ++++++------ src/datastore/test_datastore_api.c | 5 ++++- src/datastore/test_datastore_api_management.c | 3 ++- 4 files changed, 25 insertions(+), 15 deletions(-) (limited to 'src/datastore') diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index cf6a2cc8e..344a70842 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c @@ -792,6 +792,7 @@ process_status_message (void *cls, * @param type type of the content * @param priority priority of the content * @param anonymity anonymity-level for the content + * @param replication how often should the content be replicated to other peers? * @param expiration expiration time for the content * @param queue_priority ranking of this request in the priority queue * @param max_queue_size at what queue size should this request be dropped @@ -812,6 +813,7 @@ GNUNET_DATASTORE_put (struct GNUNET_DATASTORE_Handle *h, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, + uint32_t replication, struct GNUNET_TIME_Absolute expiration, unsigned int queue_priority, unsigned int max_queue_size, @@ -1274,7 +1276,11 @@ process_result_message (void *cls, /** - * Get a random value from the datastore. + * Get a random value from the datastore for content replication. + * Returns a single, random value among those with the highest + * replication score, lowering positive replication scores by one for + * the chosen value (if only content with a replication score exists, + * a random value is returned and replication scores are not changed). * * @param h handle to the datastore * @param queue_priority ranking of this request in the priority queue @@ -1290,12 +1296,12 @@ process_result_message (void *cls, * (or rather, will already have been invoked) */ struct GNUNET_DATASTORE_QueueEntry * -GNUNET_DATASTORE_get_random (struct GNUNET_DATASTORE_Handle *h, - unsigned int queue_priority, - unsigned int max_queue_size, - struct GNUNET_TIME_Relative timeout, - GNUNET_DATASTORE_Iterator iter, - void *iter_cls) +GNUNET_DATASTORE_get_for_replication (struct GNUNET_DATASTORE_Handle *h, + unsigned int queue_priority, + unsigned int max_queue_size, + struct GNUNET_TIME_Relative timeout, + GNUNET_DATASTORE_Iterator iter, + void *iter_cls) { struct GNUNET_DATASTORE_QueueEntry *qe; struct GNUNET_MessageHeader *m; diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index de9a8b236..00d91b4c7 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -269,7 +269,7 @@ run_continuation (void *cls, data, i+1, GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100), - i, + i, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1000))), @@ -279,10 +279,10 @@ run_continuation (void *cls, break; case RP_CUT: /* trim down below MAX_SIZE again */ - GNUNET_DATASTORE_get_random (datastore, - 1, 1, TIMEOUT, - &delete_value, - crc); + GNUNET_DATASTORE_get_for_replication (datastore, + 1, 1, TIMEOUT, + &delete_value, + crc); break; case RP_REPORT: printf ( @@ -355,7 +355,7 @@ run (void *cls, GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", GNUNET_BLOCK_TYPE_TEST, - 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), + 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), 0, 1, GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) { diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index d8e4b7b34..965f05687 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -402,6 +402,7 @@ run_continuation (void *cls, get_type (crc->i), get_priority (crc->i), get_anonymity (crc->i), + 0, get_expiration (crc->i), 1, 1, TIMEOUT, &check_success, @@ -502,6 +503,7 @@ run_continuation (void *cls, get_type (42), get_priority (42), get_anonymity (42), + 0, get_expiration (42), 1, 1, TIMEOUT, &check_success, @@ -517,6 +519,7 @@ run_continuation (void *cls, get_type (42), get_priority (43), get_anonymity (43), + 0, get_expiration (43), 1, 1, TIMEOUT, &check_success, @@ -613,7 +616,7 @@ run (void *cls, GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", GNUNET_BLOCK_TYPE_TEST, - 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), + 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), 0, 1, GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) { diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 2873caa02..50a426af6 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -231,6 +231,7 @@ run_continuation (void *cls, get_type (crc->i), get_priority (crc->i), get_anonymity (crc->i), + 0, get_expiration (crc->i), 1, 1, TIMEOUT, &check_success, @@ -327,7 +328,7 @@ run (void *cls, GNUNET_DATASTORE_put (datastore, 0, &zkey, 4, "TEST", GNUNET_BLOCK_TYPE_TEST, - 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), + 0, 0, 0, GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_SECONDS), 0, 1, GNUNET_TIME_UNIT_MINUTES, &run_tests, crc)) { -- cgit v1.2.3