Management for the datastore for files stored on a GNUnet node. More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_statistics_service.h"
#include "gnunet_datastore_plugin.h"
#include "datastore.h"
Go to the source code of this file.
Data Structures | |
struct | DatastorePlugin |
Our datastore plugin. More... | |
struct | ReservationList |
Linked list of active reservations. More... | |
Macros | |
#define | MAX_PENDING 1024 |
How many messages do we queue at most per client? More... | |
#define | MAX_BF_SIZE ((uint32_t) (1LL << 31)) |
Limit size of bloom filter to 2 GB. More... | |
#define | MAX_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
How long are we at most keeping "expired" content past the expiration date in the database? More... | |
#define | MIN_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
How fast are we allowed to query the database for deleting expired content? (1 item per second). More... | |
#define | MAX_STAT_SYNC_LAG 50 |
After how many payload-changing operations do we sync our statistics? More... | |
Functions | |
static void | sync_stats () |
Synchronize our utilization statistics with the statistics service. More... | |
static void | delete_expired (void *cls) |
Task that is used to remove expired entries from the datastore. More... | |
static int | expired_processor (void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
Iterate over the expired items stored in the datastore. More... | |
static int | quota_processor (void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
An iterator over a set of items stored in the datastore that deletes until we're happy with respect to our quota. More... | |
static void | manage_space (unsigned long long need) |
Manage available disk space by running tasks that will discard content if necessary. More... | |
static void | transmit_status (struct GNUNET_SERVICE_Client *client, int code, const char *msg) |
Transmit a status code to the client. More... | |
static int | transmit_item (void *cls, const struct GNUNET_HashCode *key, uint32_t size, const void *data, enum GNUNET_BLOCK_Type type, uint32_t priority, uint32_t anonymity, uint32_t replication, struct GNUNET_TIME_Absolute expiration, uint64_t uid) |
Function that will transmit the given datastore entry to the client. More... | |
static void | handle_reserve (void *cls, const struct ReserveMessage *msg) |
Handle RESERVE-message. More... | |
static void | handle_release_reserve (void *cls, const struct ReleaseReserveMessage *msg) |
Handle RELEASE_RESERVE-message. More... | |
static int | check_data (const struct DataMessage *dm) |
Check that the given message is a valid data message. More... | |
static void | put_continuation (void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg) |
Put continuation. More... | |
static int | check_put (void *cls, const struct DataMessage *dm) |
Verify PUT-message. More... | |
static void | handle_put (void *cls, const struct DataMessage *dm) |
Handle PUT-message. More... | |
static void | handle_get (void *cls, const struct GetMessage *msg) |
Handle GNUNET_MESSAGE_TYPE_DATASTORE_GET-message. More... | |
static void | handle_get_key (void *cls, const struct GetKeyMessage *msg) |
Handle GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY-message. More... | |
static void | handle_get_replication (void *cls, const struct GNUNET_MessageHeader *message) |
Handle GET_REPLICATION-message. More... | |
static void | handle_get_zero_anonymity (void *cls, const struct GetZeroAnonymityMessage *msg) |
Handle GET_ZERO_ANONYMITY-message. More... | |
static void | remove_continuation (void *cls, const struct GNUNET_HashCode *key, uint32_t size, int status, const char *msg) |
Remove continuation. More... | |
static int | check_remove (void *cls, const struct DataMessage *dm) |
Verify REMOVE-message. More... | |
static void | handle_remove (void *cls, const struct DataMessage *dm) |
Handle REMOVE-message. More... | |
static void | handle_drop (void *cls, const struct GNUNET_MessageHeader *message) |
Handle DROP-message. More... | |
static void | disk_utilization_change_cb (void *cls, int delta) |
Function called by plugins to notify us about a change in their disk utilization. More... | |
static int | process_stat_in (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) |
Callback function to process statistic values. More... | |
static struct DatastorePlugin * | load_plugin () |
Load the datastore plugin. More... | |
static void | unload_plugin (struct DatastorePlugin *plug) |
Function called when the service shuts down. More... | |
static void | begin_service () |
Initialization complete, start operating the service. More... | |
static void | add_key_to_bloomfilter (void *cls, const struct GNUNET_HashCode *key, unsigned int count) |
Adds a given key to the bloomfilter in cls count times. More... | |
static void | process_stat_done (void *cls, int success) |
We finished receiving the statistic. More... | |
static void | stat_timeout (void *cls) |
Fetching stats took to long, run without. More... | |
static void | cleaning_task (void *cls) |
Task run during shutdown. More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq) |
Add a client to our list of active clients. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx) |
Called whenever a client is disconnected. More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *serv) |
Process datastore requests. More... | |
GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "datastore", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(reserve, GNUNET_MESSAGE_TYPE_DATASTORE_RESERVE, struct ReserveMessage, NULL), GNUNET_MQ_hd_fixed_size(release_reserve, GNUNET_MESSAGE_TYPE_DATASTORE_RELEASE_RESERVE, struct ReleaseReserveMessage, NULL), GNUNET_MQ_hd_var_size(put, GNUNET_MESSAGE_TYPE_DATASTORE_PUT, struct DataMessage, NULL), GNUNET_MQ_hd_fixed_size(get, GNUNET_MESSAGE_TYPE_DATASTORE_GET, struct GetMessage, NULL), GNUNET_MQ_hd_fixed_size(get_key, GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY, struct GetKeyMessage, NULL), GNUNET_MQ_hd_fixed_size(get_replication, GNUNET_MESSAGE_TYPE_DATASTORE_GET_REPLICATION, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(get_zero_anonymity, GNUNET_MESSAGE_TYPE_DATASTORE_GET_ZERO_ANONYMITY, struct GetZeroAnonymityMessage, NULL), GNUNET_MQ_hd_var_size(remove, GNUNET_MESSAGE_TYPE_DATASTORE_REMOVE, struct DataMessage, NULL), GNUNET_MQ_hd_fixed_size(drop, GNUNET_MESSAGE_TYPE_DATASTORE_DROP, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static char * | quota_stat_name |
Name under which we store current space consumption. More... | |
static struct GNUNET_SCHEDULER_Task * | stat_timeout_task |
Task to timeout stat GET. More... | |
static struct DatastorePlugin * | plugin |
Our datastore plugin (NULL if not available). More... | |
static struct ReservationList * | reservations |
Linked list of space reservations made by clients. More... | |
static struct GNUNET_CONTAINER_BloomFilter * | filter |
Bloomfilter to quickly tell if we don't have the content. More... | |
static char * | plugin_name |
Name of our plugin. More... | |
static const struct GNUNET_CONFIGURATION_Handle * | cfg |
Our configuration. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
Handle for reporting statistics. More... | |
static unsigned long long | cache_size |
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"). More... | |
static unsigned long long | reserved |
How much space have we currently reserved? More... | |
static unsigned long long | payload |
How much data are we currently storing in the database? More... | |
static struct GNUNET_SCHEDULER_Task * | expired_kill_task |
Identity of the task that is used to delete expired content. More... | |
static struct GNUNET_TIME_Absolute | min_expiration |
Minimum time that content should have to not be discarded instantly (time stamp of any content that we've been discarding recently to stay below the quota). More... | |
static unsigned long long | quota |
How much space are we allowed to use? More... | |
static int | do_drop |
Should the database be dropped on exit? More... | |
static int | refresh_bf |
Should we refresh the BF when the DB is loaded? More... | |
static unsigned int | last_sync |
Number of updates that were made to the payload value since we last synchronized it with the statistics service. More... | |
static int | stats_worked |
Did we get an answer from statistics? More... | |
static int | cleaning_done |
Have we already cleaned up the TCCs and are hence no longer willing (or able) to transmit anything to anyone? More... | |
static struct GNUNET_STATISTICS_GetHandle * | stat_get |
Handle for pending get request. More... | |
static struct GNUNET_SERVICE_Handle * | service |
Handle to our server. More... | |
Management for the datastore for files stored on a GNUnet node.
Definition in file gnunet-service-datastore.c.
#define MAX_PENDING 1024 |
How many messages do we queue at most per client?
Definition at line 37 of file gnunet-service-datastore.c.
#define MAX_BF_SIZE ((uint32_t) (1LL << 31)) |
Limit size of bloom filter to 2 GB.
Definition at line 42 of file gnunet-service-datastore.c.
#define MAX_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
How long are we at most keeping "expired" content past the expiration date in the database?
Definition at line 48 of file gnunet-service-datastore.c.
#define MIN_EXPIRE_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
How fast are we allowed to query the database for deleting expired content? (1 item per second).
Definition at line 55 of file gnunet-service-datastore.c.
#define MAX_STAT_SYNC_LAG 50 |
After how many payload-changing operations do we sync our statistics?
Definition at line 72 of file gnunet-service-datastore.c.
|
static |
Synchronize our utilization statistics with the statistics service.
Definition at line 232 of file gnunet-service-datastore.c.
References GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_YES, last_sync, payload, quota_stat_name, and stats.
Referenced by cleaning_task(), and disk_utilization_change_cb().
|
static |
Task that is used to remove expired entries from the datastore.
This task will schedule itself again automatically to always delete all expired content quickly.
cls | not used |
Definition at line 357 of file gnunet-service-datastore.c.
References DatastorePlugin::api, GNUNET_DATASTORE_PluginFunctions::cls, expired_kill_task, expired_processor(), GNUNET_DATASTORE_PluginFunctions::get_expiration, and plugin.
Referenced by begin_service(), and expired_processor().
|
static |
Iterate over the expired items stored in the datastore.
Delete all expired items; once we have processed all expired items, re-schedule the "delete_expired" task.
cls | not used |
key | key for the content |
size | number of bytes in data |
data | content stored |
type | type of the content |
priority | priority of the content |
anonymity | anonymity-level for the content |
replication | replication-level for the content |
expiration | expiration time for the content |
uid | unique identifier for the datum; maybe 0 if no unique identifier is available |
Definition at line 293 of file gnunet-service-datastore.c.
References GNUNET_TIME_Absolute::abs_value_us, delete_expired(), expiration, expired_kill_task, filter, gettext_noop, GNUNET_CONTAINER_bloomfilter_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_YES, key, MAX_EXPIRE_DELAY, min_expiration, MIN_EXPIRE_DELAY, size, stats, and type.
Referenced by delete_expired().
|
static |
An iterator over a set of items stored in the datastore that deletes until we're happy with respect to our quota.
cls | closure |
key | key for the content |
size | number of bytes in data |
data | content stored |
type | type of the content |
priority | priority of the content |
anonymity | anonymity-level for the content |
replication | replication-level for the content |
expiration | expiration time for the content |
uid | unique identifier for the datum; maybe 0 if no unique identifier is available |
Definition at line 384 of file gnunet-service-datastore.c.
References expiration, filter, gettext_noop, GNUNET_CONTAINER_bloomfilter_remove(), GNUNET_DATASTORE_ENTRY_OVERHEAD, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, key, min_expiration, size, stats, and type.
Referenced by manage_space().
|
static |
Manage available disk space by running tasks that will discard content if necessary.
This function will be run whenever a request for "need" bytes of storage could only be satisfied by eating into the "cache" (and we want our cache space back).
need | number of bytes of content that were placed into the "cache" (and hence the number of bytes that should be removed). |
Definition at line 440 of file gnunet-service-datastore.c.
References DatastorePlugin::api, GNUNET_DATASTORE_PluginFunctions::cls, GNUNET_DATASTORE_PluginFunctions::get_expiration, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, plugin, and quota_processor().
Referenced by put_continuation().
|
static |
Transmit a status code to the client.
client | receiver of the response |
code | status code |
msg | optional error message (can be NULL) |
Definition at line 464 of file gnunet-service-datastore.c.
References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DATASTORE_STATUS, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), GNUNET_TIME_absolute_hton(), StatusMessage::min_expiration, min_expiration, msg, and StatusMessage::status.
Referenced by handle_release_reserve(), handle_reserve(), put_continuation(), and remove_continuation().
|
static |
Function that will transmit the given datastore entry to the client.
cls | closure, pointer to the client (of type struct GNUNET_SERVICE_Client ). |
key | key for the content |
size | number of bytes in data |
data | content stored |
type | type of the content |
priority | priority of the content |
anonymity | anonymity-level for the content |
replication | replication-level for the content |
expiration | expiration time for the content |
uid | unique identifier for the datum; maybe 0 if no unique identifier is available |
Definition at line 505 of file gnunet-service-datastore.c.
References anonymity, DataMessage::anonymity, data, end, env, expiration, DataMessage::expiration, gettext_noop, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_htonll(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_DATASTORE_DATA, GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END, GNUNET_MQ_msg, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_get_mq(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_absolute_hton(), GNUNET_YES, key, DataMessage::key, DataMessage::priority, replication, DataMessage::replication, DataMessage::rid, size, DataMessage::size, stats, type, DataMessage::type, and DataMessage::uid.
Referenced by handle_get(), handle_get_key(), handle_get_replication(), and handle_get_zero_anonymity().
|
static |
Handle RESERVE-message.
cls | identification of the client |
msg | the actual message |
Static counter to produce reservation identifiers.
Definition at line 566 of file gnunet-service-datastore.c.
References _, ReservationList::amount, cache_size, ReservationList::client, ReservationList::entries, gettext_noop, GNUNET_DATASTORE_ENTRY_OVERHEAD, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_set(), msg, ReservationList::next, payload, quota, reservations, reserved, ReservationList::rid, stats, and transmit_status().
|
static |
Handle RELEASE_RESERVE-message.
cls | identification of the client |
msg | the actual message |
Definition at line 650 of file gnunet-service-datastore.c.
References ReservationList::amount, ReservationList::client, ReservationList::entries, gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_DATASTORE_ENTRY_OVERHEAD, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, msg, ReservationList::next, reservations, reserved, ReservationList::rid, stats, and transmit_status().
|
static |
Check that the given message is a valid data message.
dm | message to check |
Definition at line 705 of file gnunet-service-datastore.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, DataMessage::header, GNUNET_MessageHeader::size, size, and DataMessage::size.
Referenced by check_put(), and check_remove().
|
static |
Put continuation.
cls | closure |
key | key for the item stored |
size | size of the item stored |
status | GNUNET_OK if inserted, GNUNET_NO if updated, or #GNUNET_SYSERROR if error |
msg | error message on error |
Definition at line 732 of file gnunet-service-datastore.c.
References _, cache_size, filter, gettext_noop, GNUNET_CONTAINER_bloomfilter_add(), GNUNET_DATASTORE_ENTRY_OVERHEAD, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, key, manage_space(), msg, payload, quota, reserved, size, stats, status, and transmit_status().
Referenced by handle_put().
|
static |
Verify PUT-message.
cls | identification of the client |
dm | the actual message |
Definition at line 775 of file gnunet-service-datastore.c.
References check_data(), GNUNET_break, GNUNET_OK, and GNUNET_SYSERR.
|
static |
Handle PUT-message.
cls | identification of the client |
dm | the actual message |
Definition at line 793 of file gnunet-service-datastore.c.
References ReservationList::amount, DataMessage::anonymity, DatastorePlugin::api, ReservationList::client, GNUNET_DATASTORE_PluginFunctions::cls, ReservationList::entries, DataMessage::expiration, filter, gettext_noop, GNUNET_break, GNUNET_CONTAINER_bloomfilter_test(), GNUNET_DATASTORE_ENTRY_OVERHEAD, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_set(), GNUNET_TIME_absolute_ntoh(), DataMessage::key, ReservationList::next, plugin, DataMessage::priority, GNUNET_DATASTORE_PluginFunctions::put, put_continuation(), DataMessage::replication, reservations, reserved, DataMessage::rid, ReservationList::rid, size, DataMessage::size, stats, and DataMessage::type.
|
static |
Handle GNUNET_MESSAGE_TYPE_DATASTORE_GET-message.
cls | identification of the client |
msg | the actual message |
Definition at line 852 of file gnunet-service-datastore.c.
References DatastorePlugin::api, GNUNET_DATASTORE_PluginFunctions::cls, GNUNET_DATASTORE_PluginFunctions::get_key, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), msg, plugin, stats, transmit_item(), and GNUNET_MessageHeader::type.
|
static |
Handle GNUNET_MESSAGE_TYPE_DATASTORE_GET_KEY-message.
cls | closure |
msg | the actual message |
Definition at line 881 of file gnunet-service-datastore.c.
References DatastorePlugin::api, GNUNET_DATASTORE_PluginFunctions::cls, filter, GNUNET_DATASTORE_PluginFunctions::get_key, gettext_noop, GNUNET_CONTAINER_bloomfilter_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, msg, plugin, stats, transmit_item(), and GNUNET_MessageHeader::type.
|
static |
Handle GET_REPLICATION-message.
cls | identification of the client |
message | the actual message |
Definition at line 935 of file gnunet-service-datastore.c.
References DatastorePlugin::api, GNUNET_DATASTORE_PluginFunctions::cls, GNUNET_DATASTORE_PluginFunctions::get_replication, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), plugin, stats, and transmit_item().
|
static |
Handle GET_ZERO_ANONYMITY-message.
cls | client identification of the client |
msg | the actual message |
Definition at line 957 of file gnunet-service-datastore.c.
References DatastorePlugin::api, GNUNET_DATASTORE_PluginFunctions::cls, GNUNET_DATASTORE_PluginFunctions::get_zero_anonymity, gettext_noop, GNUNET_BLOCK_TYPE_ANY, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_ntohll(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), msg, plugin, stats, transmit_item(), type, and GNUNET_MessageHeader::type.
|
static |
Remove continuation.
cls | closure |
key | key for the content |
size | number of bytes in data |
status | GNUNET_OK if removed, GNUNET_NO if not found, or #GNUNET_SYSERROR if error |
msg | error message on error |
Definition at line 996 of file gnunet-service-datastore.c.
References _, filter, gettext_noop, GNUNET_CONTAINER_bloomfilter_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_YES, key, msg, size, stats, status, and transmit_status().
Referenced by handle_remove().
|
static |
Verify REMOVE-message.
cls | identification of the client |
dm | the actual message |
Definition at line 1037 of file gnunet-service-datastore.c.
References check_data(), GNUNET_break, GNUNET_OK, and GNUNET_SYSERR.
|
static |
Handle REMOVE-message.
cls | closure |
dm | the actual message |
Definition at line 1055 of file gnunet-service-datastore.c.
References DatastorePlugin::api, GNUNET_DATASTORE_PluginFunctions::cls, gettext_noop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_STATISTICS_update(), DataMessage::key, plugin, remove_continuation(), GNUNET_DATASTORE_PluginFunctions::remove_key, DataMessage::size, and stats.
|
static |
Handle DROP-message.
cls | identification of the client |
message | the actual message |
Definition at line 1083 of file gnunet-service-datastore.c.
References do_drop, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), and GNUNET_YES.
|
static |
Function called by plugins to notify us about a change in their disk utilization.
cls | closure (NULL) |
delta | change in disk utilization, 0 for "reset to empty" |
Definition at line 1104 of file gnunet-service-datastore.c.
References _, DatastorePlugin::api, GNUNET_DATASTORE_PluginFunctions::cls, delta, GNUNET_DATASTORE_PluginFunctions::estimate_size, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, last_sync, MAX_STAT_SYNC_LAG, payload, plugin, and sync_stats().
Referenced by load_plugin().
|
static |
Callback function to process statistic values.
cls | closure (struct Plugin*) |
subsystem | name of subsystem that created the statistic |
name | the name of the datum |
value | the current value |
is_persistent | GNUNET_YES if the value is persistent, GNUNET_NO if not |
Definition at line 1139 of file gnunet-service-datastore.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_YES, payload, stats_worked, and value.
Referenced by run().
|
static |
Load the datastore plugin.
Definition at line 1161 of file gnunet-service-datastore.c.
References _, cfg, disk_utilization_change_cb(), GNUNET_asprintf(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_OS_project_data_gnunet(), GNUNET_PLUGIN_load(), GNUNET_strdup, plugin_name, and ret.
Referenced by process_stat_done().
|
static |
Function called when the service shuts down.
Unloads our datastore plugin.
plug | plugin to unload |
Definition at line 1202 of file gnunet-service-datastore.c.
References DatastorePlugin::api, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_PLUGIN_unload(), DatastorePlugin::lib_name, and DatastorePlugin::short_name.
Referenced by cleaning_task().
|
static |
Initialization complete, start operating the service.
Definition at line 1217 of file gnunet-service-datastore.c.
References delete_expired(), expired_kill_task, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_SERVICE_resume(), and service.
Referenced by add_key_to_bloomfilter(), and process_stat_done().
|
static |
Adds a given key to the bloomfilter in cls count times.
cls | the bloomfilter |
key | key to add |
count | number of times to add key |
Definition at line 1235 of file gnunet-service-datastore.c.
References _, begin_service(), GNUNET_CONTAINER_bloomfilter_add(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, and key.
Referenced by process_stat_done().
|
static |
We finished receiving the statistic.
Initialize the plugin; if loading the statistic failed, run the estimator.
cls | NULL |
success | GNUNET_NO if we failed to read the stat |
Definition at line 1262 of file gnunet-service-datastore.c.
References _, add_key_to_bloomfilter(), DatastorePlugin::api, begin_service(), GNUNET_DATASTORE_PluginFunctions::cls, GNUNET_DATASTORE_PluginFunctions::estimate_size, filter, GNUNET_DATASTORE_PluginFunctions::get_keys, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_YES, load_plugin(), payload, plugin, refresh_bf, stat_get, stat_timeout_task, stats, and stats_worked.
Referenced by run(), and stat_timeout().
|
static |
Fetching stats took to long, run without.
cls | NULL |
Definition at line 1320 of file gnunet-service-datastore.c.
References GNUNET_NO, GNUNET_STATISTICS_get_cancel(), process_stat_done(), stat_get, and stat_timeout_task.
Referenced by run().
|
static |
Task run during shutdown.
Definition at line 1332 of file gnunet-service-datastore.c.
References DatastorePlugin::api, cleaning_done, GNUNET_DATASTORE_PluginFunctions::cls, do_drop, GNUNET_DATASTORE_PluginFunctions::drop, expired_kill_task, filter, GNUNET_CONTAINER_bloomfilter_free(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_STATISTICS_get_cancel(), GNUNET_YES, last_sync, payload, plugin, plugin_name, quota_stat_name, stat_get, stat_timeout_task, stats, sync_stats(), and unload_plugin().
Referenced by run().
|
static |
Add a client to our list of active clients.
cls | NULL |
client | client to add |
mq | message queue for client |
Definition at line 1391 of file gnunet-service-datastore.c.
|
static |
Called whenever a client is disconnected.
Frees our resources associated with that client.
cls | closure |
client | identification of the client |
app_ctx | must match client |
Definition at line 1408 of file gnunet-service-datastore.c.
References ReservationList::amount, ReservationList::client, ReservationList::entries, gettext_noop, GNUNET_assert, GNUNET_DATASTORE_ENTRY_OVERHEAD, GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_set(), ReservationList::next, reservations, reserved, and stats.
|
static |
Process datastore requests.
cls | closure |
serv | the initialized service |
c | configuration to use |
Definition at line 1452 of file gnunet-service-datastore.c.
References _, cache_size, cfg, cleaning_task(), filter, gettext_noop, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_size(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONTAINER_bloomfilter_init(), GNUNET_CONTAINER_bloomfilter_load(), GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SERVICE_suspend(), GNUNET_STATISTICS_create(), GNUNET_STATISTICS_destroy(), GNUNET_STATISTICS_get(), GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, MAX_BF_SIZE, plugin_name, process_stat_done(), process_stat_in(), quota, quota_stat_name, refresh_bf, service, stat_get, stat_timeout(), stat_timeout_task, and stats.
Define "main" method using service macro.
|
static |
Name under which we store current space consumption.
Definition at line 61 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), run(), and sync_stats().
|
static |
Task to timeout stat GET.
Definition at line 66 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), process_stat_done(), run(), and stat_timeout().
|
static |
Our datastore plugin (NULL if not available).
Definition at line 139 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), delete_expired(), disk_utilization_change_cb(), handle_get(), handle_get_key(), handle_get_replication(), handle_get_zero_anonymity(), handle_put(), handle_remove(), manage_space(), and process_stat_done().
|
static |
Linked list of space reservations made by clients.
Definition at line 144 of file gnunet-service-datastore.c.
Referenced by client_disconnect_cb(), handle_put(), handle_release_reserve(), and handle_reserve().
|
static |
Bloomfilter to quickly tell if we don't have the content.
Definition at line 149 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), expired_processor(), get_audiobin(), GNUNET_GNSRECORD_normalize_record_set(), GNUNET_NAMESTORE_records_lookup2(), GNUNET_NAMESTORE_zone_iteration_start2(), GNUNET_NAMESTORE_zone_monitor_start2(), handle_get_key(), handle_put(), main(), process_stat_done(), put_continuation(), quota_processor(), records_lookup(), remove_continuation(), run(), and send_lookup_response_with_filter().
|
static |
Name of our plugin.
Definition at line 154 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), load_plugin(), and run().
|
static |
Our configuration.
Definition at line 159 of file gnunet-service-datastore.c.
Referenced by load_plugin(), and run().
|
static |
Handle for reporting statistics.
Definition at line 164 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), client_disconnect_cb(), expired_processor(), handle_get(), handle_get_key(), handle_get_replication(), handle_get_zero_anonymity(), handle_put(), handle_release_reserve(), handle_remove(), handle_reserve(), process_stat_done(), put_continuation(), quota_processor(), remove_continuation(), run(), sync_stats(), and transmit_item().
|
static |
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").
Definition at line 172 of file gnunet-service-datastore.c.
Referenced by handle_reserve(), put_continuation(), and run().
|
static |
How much space have we currently reserved?
Definition at line 177 of file gnunet-service-datastore.c.
Referenced by client_disconnect_cb(), handle_put(), handle_release_reserve(), handle_reserve(), and put_continuation().
|
static |
How much data are we currently storing in the database?
Definition at line 183 of file gnunet-service-datastore.c.
Referenced by block_create_ecdsa(), block_create_eddsa(), block_decrypt_ecdsa(), block_decrypt_eddsa(), cleaning_task(), disk_utilization_change_cb(), GNUNET_TRANSPORT_TESTING_transport_communicator_send(), GNUNET_TUN_calculate_icmp_checksum(), GNUNET_TUN_calculate_tcp4_checksum(), GNUNET_TUN_calculate_tcp6_checksum(), GNUNET_TUN_calculate_udp4_checksum(), GNUNET_TUN_calculate_udp6_checksum(), GSC_KX_encrypt_and_transmit(), handle_alices_cryptodata_message(), handle_bobs_cryptodata_message(), handle_bobs_cryptodata_multipart(), handle_client_response(), handle_icmp_remote(), handle_icmp_service(), handle_local_data(), handle_reserve(), handle_stun(), handle_tcp_remote(), handle_udp_remote(), OIDC_build_authz_code(), parse(), prepare_ipv4_packet(), prepare_ipv6_packet(), process_stat_done(), process_stat_in(), put_continuation(), queue_send_msg(), route_packet(), send_alices_cryptodata_message(), send_icmp_packet_via_tun(), send_reply(), send_tcp_packet_via_tun(), send_udp_packet_via_tun(), sync_stats(), transmit_bobs_cryptodata_message(), and transmit_bobs_cryptodata_message_multipart().
|
static |
Identity of the task that is used to delete expired content.
Definition at line 189 of file gnunet-service-datastore.c.
Referenced by begin_service(), cleaning_task(), delete_expired(), and expired_processor().
|
static |
Minimum time that content should have to not be discarded instantly (time stamp of any content that we've been discarding recently to stay below the quota).
FOREVER if we had to expire content with non-zero priority.
Definition at line 197 of file gnunet-service-datastore.c.
Referenced by expired_processor(), put_migration_continuation(), quota_processor(), and transmit_status().
|
static |
How much space are we allowed to use?
Definition at line 202 of file gnunet-service-datastore.c.
Referenced by GNUNET_DATACACHE_create(), handle_reserve(), put_continuation(), and run().
|
static |
Should the database be dropped on exit?
Definition at line 207 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), and handle_drop().
|
static |
Should we refresh the BF when the DB is loaded?
Definition at line 212 of file gnunet-service-datastore.c.
Referenced by process_stat_done(), and run().
|
static |
Number of updates that were made to the payload value since we last synchronized it with the statistics service.
Definition at line 219 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), disk_utilization_change_cb(), and sync_stats().
|
static |
Did we get an answer from statistics?
Definition at line 224 of file gnunet-service-datastore.c.
Referenced by process_stat_done(), and process_stat_in().
|
static |
Have we already cleaned up the TCCs and are hence no longer willing (or able) to transmit anything to anyone?
Definition at line 247 of file gnunet-service-datastore.c.
Referenced by cleaning_task().
|
static |
Handle for pending get request.
Definition at line 252 of file gnunet-service-datastore.c.
Referenced by cleaning_task(), process_stat_done(), run(), and stat_timeout().
|
static |
Handle to our server.
Definition at line 257 of file gnunet-service-datastore.c.
Referenced by begin_service(), and run().