tool to manipulate datastores More...
#include "platform.h"
#include <inttypes.h>
#include "gnunet_util_lib.h"
#include "gnunet_datastore_service.h"
Go to the source code of this file.
Data Structures | |
struct | DataRecord |
Functions | |
static void | do_shutdown (void *cls) |
static void | start_dump (void) |
Begin dumping the database. More... | |
static void | start_insert (void) |
Begin inserting into the database. More... | |
static void | do_get (const uint64_t next_uid) |
Perform next GET operation. More... | |
static void | get_cb (void *cls, const struct GNUNET_HashCode *key, size_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) |
Process a datum that was stored in the datastore. More... | |
static void | put_cb (void *cls, int32_t success, struct GNUNET_TIME_Absolute min_expiration, const char *msg) |
Continuation called to notify client about result of the operation. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Main function that will be run by the scheduler. More... | |
int | main (int argc, char *const *argv) |
The main function to manipulate datastores. More... | |
Variables | |
static GNUNET_NETWORK_STRUCT_END const size_t | MAGIC_LEN = 16 |
Length of our magic header. More... | |
static const uint8_t | MAGIC_BYTES [16] = "GNUNETDATASTORE1" |
Magic header bytes. More... | |
static int | dump |
Dump the database. More... | |
static int | insert |
Insert into the database. More... | |
static char * | file_name |
Dump file name. More... | |
static struct GNUNET_DISK_FileHandle * | file_handle |
Dump file handle. More... | |
static int | ret |
Global return value. More... | |
static struct GNUNET_DATASTORE_Handle * | datastore |
Handle for datastore. More... | |
static struct GNUNET_DATASTORE_QueueEntry * | qe |
Current operation. More... | |
static uint64_t | record_count |
Record count. More... | |
tool to manipulate datastores
Definition in file gnunet-datastore.c.
|
static |
Definition at line 125 of file gnunet-datastore.c.
References datastore, file_handle, GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_disconnect(), GNUNET_DISK_file_close(), GNUNET_NO, and qe.
Referenced by run().
|
static |
Begin dumping the database.
Definition at line 268 of file gnunet-datastore.c.
References _, do_get(), file_handle, file_name, GNUNET_DISK_file_open(), GNUNET_DISK_file_write(), GNUNET_DISK_get_handle_from_int_fd(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_TRUNCATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_SCHEDULER_shutdown(), MAGIC_BYTES, MAGIC_LEN, record_count, and ret.
Referenced by run().
|
static |
Begin inserting into the database.
Definition at line 391 of file gnunet-datastore.c.
References _, file_handle, file_name, GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_get_handle_from_int_fd(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, MAGIC_BYTES, MAGIC_LEN, put_cb(), record_count, and ret.
Referenced by get_cb(), and run().
|
static |
Perform next GET operation.
Definition at line 243 of file gnunet-datastore.c.
References _, datastore, get_cb(), GNUNET_assert, GNUNET_BLOCK_TYPE_ANY, GNUNET_DATASTORE_get_key(), GNUNET_SCHEDULER_shutdown(), qe, and ret.
Referenced by get_cb(), and start_dump().
|
static |
Process a datum that was stored in the datastore.
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 173 of file gnunet-datastore.c.
References _, DataRecord::anonymity, anonymity, data, do_get(), DataRecord::expiration, expiration, file_handle, GNUNET_DISK_file_close(), GNUNET_DISK_file_write(), GNUNET_SCHEDULER_shutdown(), GNUNET_TIME_absolute_hton(), insert, DataRecord::key, key, DataRecord::priority, qe, record_count, DataRecord::replication, replication, ret, DataRecord::size, size, start_insert(), DataRecord::type, and type.
Referenced by do_get(), and GNUNET_DHT_monitor_start().
|
static |
Continuation called to notify client about result of the operation.
cls | closure |
success | GNUNET_SYSERR on failure (including timeout/queue drop) GNUNET_NO if content was already there GNUNET_YES (or other positive value) on success |
min_expiration | minimum expiration time required for 0-priority content to be stored by the datacache at this time, zero for unknown, forever if we have no space for 0-priority content |
msg | NULL on success, otherwise an error message |
Definition at line 311 of file gnunet-datastore.c.
References _, DataRecord::anonymity, data, datastore, DataRecord::expiration, file_handle, GNUNET_DATASTORE_put(), GNUNET_DISK_file_read(), GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_TIME_absolute_ntoh(), DataRecord::key, msg, DataRecord::priority, put_cb(), qe, record_count, DataRecord::replication, ret, DataRecord::size, size, and DataRecord::type.
Referenced by GNUNET_DHT_monitor_start(), put_cb(), and start_insert().
|
static |
Main function that will be run by the scheduler.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used |
cfg | configuration |
Definition at line 434 of file gnunet-datastore.c.
References _, cfg, datastore, do_shutdown(), dump, GNUNET_DATASTORE_connect(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), insert, ret, start_dump(), and start_insert().
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function to manipulate datastores.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 472 of file gnunet-datastore.c.
References dump, file_name, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_filename(), GNUNET_GETOPT_option_flag(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), insert, options, ret, and run().
|
static |
Length of our magic header.
Definition at line 76 of file gnunet-datastore.c.
Referenced by start_dump(), and start_insert().
|
static |
Magic header bytes.
Definition at line 81 of file gnunet-datastore.c.
Referenced by start_dump(), and start_insert().
|
static |
Dump the database.
Definition at line 86 of file gnunet-datastore.c.
|
static |
Insert into the database.
Definition at line 91 of file gnunet-datastore.c.
|
static |
Dump file name.
Definition at line 96 of file gnunet-datastore.c.
Referenced by GNUNET_TESTING_cmd_load_topology_from_file(), main(), start_dump(), start_insert(), store_prefix_file_name(), to_file_raw(), and to_file_raw_unaligned().
|
static |
Dump file handle.
Definition at line 101 of file gnunet-datastore.c.
Referenced by do_shutdown(), get_cb(), put_cb(), start_dump(), and start_insert().
|
static |
Global return value.
Definition at line 106 of file gnunet-datastore.c.
Referenced by do_get(), get_cb(), main(), put_cb(), run(), start_dump(), and start_insert().
|
static |
Handle for datastore.
Definition at line 111 of file gnunet-datastore.c.
Referenced by do_get(), do_shutdown(), put_cb(), and run().
|
static |
Current operation.
Definition at line 116 of file gnunet-datastore.c.
Referenced by add_continuation(), delay_warning(), do_get(), do_shutdown(), find_qe(), force_reconnect(), free_pending_message(), free_qe(), free_queue(), free_queue_entry(), get_cb(), get_queue_head(), GNUNET_DATASTORE_cancel(), GNUNET_DATASTORE_disconnect(), GNUNET_DATASTORE_get_for_replication(), GNUNET_DATASTORE_get_key(), GNUNET_DATASTORE_get_zero_anonymity(), GNUNET_DATASTORE_put(), GNUNET_DATASTORE_release_reserve(), GNUNET_DATASTORE_remove(), GNUNET_DATASTORE_reserve(), GNUNET_FS_dequeue_(), GNUNET_FS_queue_(), GNUNET_NAMECACHE_block_cache(), GNUNET_NAMECACHE_cancel(), GNUNET_NAMECACHE_lookup_block(), GNUNET_NAMESTORE_cancel(), GNUNET_NAMESTORE_record_set_edit_begin(), GNUNET_NAMESTORE_record_set_edit_cancel(), GNUNET_NAMESTORE_records_store(), GNUNET_NAMESTORE_zone_to_name(), handle_block_cache_response(), handle_data(), handle_data_end(), handle_edit_record_set_response(), handle_generic_response(), handle_lookup_block_response(), handle_lookup_result(), handle_record_result(), handle_record_result_end(), handle_send_message_ack(), handle_status(), handle_zone_to_name_response(), make_queue_entry(), mq_error_handler(), process_job_queue(), process_queue(), put_cb(), queue_send_msg(), reconnect(), records_lookup(), start_job(), stop_job(), and warn_delay().
|
static |
Record count.
Definition at line 121 of file gnunet-datastore.c.
Referenced by database_setup(), get_cb(), get_records_and_call_iterator(), parse_result_call_iterator(), put_cb(), start_dump(), and start_insert().