API to push content from our datastore to other peers ('anonymous'-content P2P migration) More...
#include "platform.h"
#include "gnunet-service-fs.h"
#include "gnunet-service-fs_cp.h"
#include "gnunet-service-fs_indexing.h"
#include "gnunet-service-fs_push.h"
Go to the source code of this file.
Data Structures | |
struct | MigrationReadyBlock |
Block that is ready for migration to other peers. More... | |
struct | MigrationReadyPeer |
Information about a peer waiting for migratable data. More... | |
Macros | |
#define | MAX_MIGRATION_QUEUE 8 |
Maximum number of blocks we keep in memory for migration. More... | |
#define | MIGRATION_LIST_SIZE 2 |
Blocks are at most migrated to this number of peers plus one, each time they are fetched from the database. More... | |
#define | MIN_MIGRATION_CONTENT_LIFETIME |
How long must content remain valid for us to consider it for migration? If content will expire too soon, there is clearly no point in pushing it to other peers. More... | |
Functions | |
static void | delete_migration_block (struct MigrationReadyBlock *mb) |
Delete the given migration block. More... | |
static void | find_content (void *cls) |
Find content for migration to this peer. More... | |
static int | transmit_content (struct MigrationReadyPeer *mrp, struct MigrationReadyBlock *block) |
Send the given block to the given peer. More... | |
static unsigned int | count_targets (struct MigrationReadyBlock *block) |
Count the number of peers this block has already been forwarded to. More... | |
static long | score_content (struct MigrationReadyPeer *mrp, struct MigrationReadyBlock *block) |
Check if sending this block to this peer would be a good idea. More... | |
static void | consider_gathering (void) |
If the migration task is not currently running, consider (re)scheduling it with the appropriate delay. More... | |
static void | gather_migration_blocks (void *cls) |
Task that is run periodically to obtain blocks for content migration. More... | |
static void | process_migration_content (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 content offered for migration. More... | |
void | GSF_push_start_ (struct GSF_ConnectedPeer *peer) |
A peer connected to us. More... | |
void | GSF_push_stop_ (struct GSF_ConnectedPeer *peer) |
A peer disconnected from us. More... | |
void | GSF_push_init_ () |
Setup the module. More... | |
void | GSF_push_done_ () |
Shutdown the module. More... | |
Variables | |
static struct MigrationReadyBlock * | mig_head |
Head of linked list of blocks that can be migrated. More... | |
static struct MigrationReadyBlock * | mig_tail |
Tail of linked list of blocks that can be migrated. More... | |
static struct MigrationReadyPeer * | peer_head |
Head of linked list of peers. More... | |
static struct MigrationReadyPeer * | peer_tail |
Tail of linked list of peers. More... | |
static struct GNUNET_DATASTORE_QueueEntry * | mig_qe |
Request to datastore for migration (or NULL). More... | |
static struct GNUNET_SCHEDULER_Task * | mig_task |
ID of task that collects blocks for migration. More... | |
static struct GNUNET_TIME_Relative | min_migration_delay |
What is the maximum frequency at which we are allowed to poll the datastore for migration content? More... | |
static unsigned int | mig_size |
Size of the doubly-linked list of migration blocks. More... | |
static int | enabled |
Is this module enabled? More... | |
static int | value_found |
Did we find anything in the datastore? More... | |
API to push content from our datastore to other peers ('anonymous'-content P2P migration)
Definition in file gnunet-service-fs_push.c.
#define MAX_MIGRATION_QUEUE 8 |
Maximum number of blocks we keep in memory for migration.
Definition at line 37 of file gnunet-service-fs_push.c.
#define MIGRATION_LIST_SIZE 2 |
Blocks are at most migrated to this number of peers plus one, each time they are fetched from the database.
Definition at line 43 of file gnunet-service-fs_push.c.
#define MIN_MIGRATION_CONTENT_LIFETIME |
How long must content remain valid for us to consider it for migration? If content will expire too soon, there is clearly no point in pushing it to other peers.
This value gives the threshold for migration. Note that if this value is increased, the migration testcase may need to be adjusted as well (especially the CONTENT_LIFETIME in fs_test_lib.c).
Definition at line 52 of file gnunet-service-fs_push.c.
|
static |
Delete the given migration block.
mb | block to delete |
Definition at line 189 of file gnunet-service-fs_push.c.
References GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_PEER_decrement_rcs(), mig_head, mig_size, mig_tail, MIGRATION_LIST_SIZE, and MigrationReadyBlock::target_list.
Referenced by find_content(), GSF_push_done_(), and transmit_content().
|
static |
Find content for migration to this peer.
cls | A struct MigrationReadyPeer * to find content for |
Definition at line 329 of file gnunet-service-fs_push.c.
References consider_gathering(), count_targets(), delete_migration_block(), MigrationReadyPeer::env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, MAX_MIGRATION_QUEUE, mig_head, mig_size, MigrationReadyBlock::next, score_content(), and transmit_content().
Referenced by GSF_push_start_(), and transmit_content().
|
static |
Send the given block to the given peer.
mrp | target peer |
block | the block |
Definition at line 218 of file gnunet-service-fs_push.c.
References delete_migration_block(), MigrationReadyPeer::env, MigrationReadyBlock::expiration, find_content(), GNUNET_assert, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_FS_PUT, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_NO, GNUNET_PEER_change_rc(), GNUNET_TIME_absolute_hton(), GNUNET_YES, GSF_get_peer_performance_data_(), GSF_peer_transmit_(), MIGRATION_LIST_SIZE, msg, MigrationReadyPeer::peer, GSF_PeerPerformanceData::pid, ret, MigrationReadyBlock::size, MigrationReadyBlock::target_list, GNUNET_MessageHeader::type, and MigrationReadyBlock::type.
Referenced by find_content(), and process_migration_content().
|
static |
Count the number of peers this block has already been forwarded to.
block | the block |
Definition at line 274 of file gnunet-service-fs_push.c.
References MIGRATION_LIST_SIZE, and MigrationReadyBlock::target_list.
Referenced by find_content().
|
static |
Check if sending this block to this peer would be a good idea.
mrp | target peer |
block | the block |
Definition at line 294 of file gnunet-service-fs_push.c.
References GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_hash_distance_u32(), GNUNET_PEER_resolve(), GSF_get_peer_performance_data_(), id, MIGRATION_LIST_SIZE, MigrationReadyPeer::peer, GSF_PeerPerformanceData::pid, MigrationReadyBlock::query, and MigrationReadyBlock::target_list.
Referenced by find_content().
|
static |
If the migration task is not currently running, consider (re)scheduling it with the appropriate delay.
Definition at line 402 of file gnunet-service-fs_push.c.
References gather_migration_blocks(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_max(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_SECONDS, GSF_dsh, MAX_MIGRATION_QUEUE, mig_qe, mig_size, mig_task, min_migration_delay, and value_found.
Referenced by find_content(), gather_migration_blocks(), GSF_push_init_(), and process_migration_content().
|
static |
Task that is run periodically to obtain blocks for content migration.
cls | unused |
Definition at line 539 of file gnunet-service-fs_push.c.
References consider_gathering(), GNUNET_DATASTORE_get_for_replication(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GSF_dsh, MAX_MIGRATION_QUEUE, mig_qe, mig_size, mig_task, process_migration_content(), and value_found.
Referenced by consider_gathering().
|
static |
Process content offered for migration.
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 453 of file gnunet-service-fs_push.c.
References anonymity, consider_gathering(), data, MigrationReadyPeer::env, expiration, MigrationReadyBlock::expiration, GNUNET_BLOCK_TYPE_FS_ONDEMAND, GNUNET_CONTAINER_DLL_insert_after, GNUNET_ERROR_TYPE_DEBUG, GNUNET_FS_handle_on_demand_block(), GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_OK, GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, GSF_connected_peer_get_identity2_(), key, MAX_MIGRATION_QUEUE, mig_head, mig_qe, mig_size, mig_tail, MIN_MIGRATION_CONTENT_LIFETIME, MigrationReadyPeer::next, MigrationReadyPeer::peer, peer_head, process_migration_content(), MigrationReadyBlock::query, replication, size, MigrationReadyBlock::size, transmit_content(), type, MigrationReadyBlock::type, and value_found.
Referenced by gather_migration_blocks(), and process_migration_content().
void GSF_push_start_ | ( | struct GSF_ConnectedPeer * | peer | ) |
A peer connected to us.
A peer connected to us or we are now again allowed to push content.
Start pushing content to this peer.
peer | handle for the peer that connected |
Definition at line 567 of file gnunet-service-fs_push.c.
References enabled, find_content(), GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_YES, GSF_connected_peer_get_identity2_(), MigrationReadyPeer::next, MigrationReadyPeer::peer, peer_head, and peer_tail.
Referenced by peer_respect_cb(), and revive_migration().
void GSF_push_stop_ | ( | struct GSF_ConnectedPeer * | peer | ) |
A peer disconnected from us.
A peer disconnected from us or asked us to stop pushing content for a while.
Stop pushing content to this peer.
peer | handle for the peer that disconnected |
Definition at line 603 of file gnunet-service-fs_push.c.
References MigrationReadyPeer::env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_send_cancel(), MigrationReadyPeer::next, MigrationReadyPeer::peer, peer_head, and peer_tail.
Referenced by GSF_peer_disconnect_handler(), and handle_p2p_migration_stop().
void GSF_push_init_ | ( | void | ) |
Setup the module.
Definition at line 625 of file gnunet-service-fs_push.c.
References _, consider_gathering(), enabled, GNUNET_CONFIGURATION_get_value_time(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log_config_invalid(), GNUNET_OK, GNUNET_YES, GSF_cfg, and min_migration_delay.
Referenced by run().
void GSF_push_done_ | ( | void | ) |
Shutdown the module.
Definition at line 654 of file gnunet-service-fs_push.c.
References delete_migration_block(), GNUNET_assert, GNUNET_DATASTORE_cancel(), GNUNET_SCHEDULER_cancel(), mig_head, mig_qe, mig_size, and mig_task.
Referenced by shutdown_task().
|
static |
Head of linked list of blocks that can be migrated.
Definition at line 134 of file gnunet-service-fs_push.c.
Referenced by delete_migration_block(), find_content(), GSF_push_done_(), and process_migration_content().
|
static |
Tail of linked list of blocks that can be migrated.
Definition at line 139 of file gnunet-service-fs_push.c.
Referenced by delete_migration_block(), and process_migration_content().
|
static |
Head of linked list of peers.
Definition at line 144 of file gnunet-service-fs_push.c.
Referenced by GSF_push_start_(), GSF_push_stop_(), and process_migration_content().
|
static |
Tail of linked list of peers.
Definition at line 149 of file gnunet-service-fs_push.c.
Referenced by GSF_push_start_(), and GSF_push_stop_().
|
static |
Request to datastore for migration (or NULL).
Definition at line 154 of file gnunet-service-fs_push.c.
Referenced by consider_gathering(), gather_migration_blocks(), GSF_push_done_(), and process_migration_content().
|
static |
ID of task that collects blocks for migration.
Definition at line 159 of file gnunet-service-fs_push.c.
Referenced by consider_gathering(), gather_migration_blocks(), and GSF_push_done_().
|
static |
What is the maximum frequency at which we are allowed to poll the datastore for migration content?
Definition at line 165 of file gnunet-service-fs_push.c.
Referenced by consider_gathering(), and GSF_push_init_().
|
static |
Size of the doubly-linked list of migration blocks.
Definition at line 170 of file gnunet-service-fs_push.c.
Referenced by consider_gathering(), delete_migration_block(), find_content(), gather_migration_blocks(), GSF_push_done_(), and process_migration_content().
|
static |
Is this module enabled?
Definition at line 175 of file gnunet-service-fs_push.c.
Referenced by GSF_push_init_(), and GSF_push_start_().
|
static |
Did we find anything in the datastore?
Definition at line 180 of file gnunet-service-fs_push.c.
Referenced by consider_gathering(), gather_migration_blocks(), and process_migration_content().