37 #define MAX_MIGRATION_QUEUE 8 43 #define MIGRATION_LIST_SIZE 2 52 #define MIN_MIGRATION_CONTENT_LIFETIME GNUNET_TIME_relative_multiply ( \ 53 GNUNET_TIME_UNIT_MINUTES, 30) 246 if (MIGRATION_LIST_SIZE == i)
316 return UINT32_MAX - dist;
349 if (score > best_score)
361 "No content found for pushing, waiting for queue to fill\n");
365 "No suitable content found, purging content from full queue\n");
373 if (score >= best_score)
386 "Preparing to push best content to peer\n");
415 if (NULL != mig_task)
434 "Scheduling gathering task (queue size: %u)\n",
476 "No content found for migration...\n");
506 "Retrieved block `%s' of type %u for migration (queue size: %u/%u)\n",
521 for (pos = peer_head; NULL != pos; pos = pos->
next)
524 "Preparing to push best content to peer %s\n",
526 if ((NULL == pos->
env) &&
552 "Asking datastore for content for replication (queue size: %u)\n",
578 for (mrp = peer_head; NULL != mrp; mrp = mrp->
next)
579 if (mrp->
peer == peer)
589 "Adding peer %s to list for pushing\n",
612 for (pos = peer_head; NULL != pos; pos = pos->
next)
613 if (pos->
peer == peer)
617 if (NULL != pos->
env)
642 "MIN_MIGRATION_DELAY",
647 "MIN_MIGRATION_DELAY",
648 _ (
"time required, content pushing disabled"));
661 if (NULL != mig_task)
671 while (NULL != mig_head)
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
API to handle 'connected peers'.
static long score_content(struct MigrationReadyPeer *mrp, struct MigrationReadyBlock *block)
Check if sending this block to this peer would be a good idea.
#define MIGRATION_LIST_SIZE
Blocks are at most migrated to this number of peers plus one, each time they are fetched from the dat...
struct GSF_ConnectedPeer * peer
Handle to peer.
#define MAX_MIGRATION_QUEUE
Maximum number of blocks we keep in memory for migration.
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
Envelope of the currently pushed message.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GSF_push_stop_(struct GSF_ConnectedPeer *peer)
A peer disconnected from us.
static struct GNUNET_DATASTORE_QueueEntry * mig_qe
Request to datastore for migration (or NULL).
Response from FS service with a result for a previous FS search.
struct GNUNET_TIME_AbsoluteNBO expiration
When does this result expire?
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
struct GNUNET_TIME_Absolute expiration
When does this block expire?
struct GNUNET_TIME_Relative GNUNET_TIME_relative_max(struct GNUNET_TIME_Relative t1, struct GNUNET_TIME_Relative t2)
Return the maximum of two relative time values.
static struct MigrationReadyPeer * peer_tail
Tail of linked list of peers.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GSF_peer_transmit_(struct GSF_ConnectedPeer *cp, int is_query, uint32_t priority, struct GNUNET_MQ_Envelope *env)
Transmit a message to the given peer as soon as possible.
#define GNUNET_TIME_UNIT_SECONDS
One second.
static unsigned int replication
Information about a peer waiting for migratable data.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static int ret
Return value of the commandline.
static int transmit_content(struct MigrationReadyPeer *mrp, struct MigrationReadyBlock *block)
Send the given block to the given peer.
enum GNUNET_BLOCK_Type type
Type of the block.
shared data structures of gnunet-service-fs.c
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct MigrationReadyBlock * mig_head
Head of linked list of blocks that can be migrated.
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
static struct GNUNET_SCHEDULER_Task * mig_task
ID of task that collects blocks for migration.
static int enabled
Is this module enabled?
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...
Block that is ready for migration to other peers.
static struct MigrationReadyBlock * mig_tail
Tail of linked list of blocks that can be migrated.
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
const struct GNUNET_CONFIGURATION_Handle * GSF_cfg
Our configuration.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Type of a block representing a block to be encoded on demand from disk.
static void delete_migration_block(struct MigrationReadyBlock *mb)
Delete the given migration block.
static void consider_gathering(void)
If the migration task is not currently running, consider (re)scheduling it with the appropriate delay...
void GSF_push_init_()
Setup the module.
struct MigrationReadyPeer * prev
This is a doubly-linked list.
GNUNET_PEER_Id target_list[2]
Peers we already forwarded this block to.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
#define MIN_MIGRATION_CONTENT_LIFETIME
How long must content remain valid for us to consider it for migration? If content will expire too so...
Entry in our priority queue.
unsigned int GNUNET_PEER_Id
A GNUNET_PEER_Id is simply a shorter version of a "struct GNUNET_PeerIdentifier" that can be used ins...
unsigned int used_targets
Number of targets already used.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore...
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
struct MigrationReadyBlock * next
This is a doubly-linked list.
struct GSF_PeerPerformanceData * GSF_get_peer_performance_data_(struct GSF_ConnectedPeer *cp)
Return the performance data record for the given peer.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
#define GNUNET_CONTAINER_DLL_insert_after(head, tail, other, element)
Insert an element into a DLL after the given other element.
static int value_found
Did we find anything in the datastore?
uint32_t GNUNET_CRYPTO_hash_distance_u32(const struct GNUNET_HashCode *a, const struct GNUNET_HashCode *b)
Compute the distance between 2 hashcodes.
struct GNUNET_DATASTORE_Handle * GSF_dsh
Our connection to the datastore.
void GNUNET_PEER_decrement_rcs(const GNUNET_PEER_Id *ids, unsigned int count)
Decrement multiple RCs of peer identities by one.
struct MigrationReadyPeer * next
This is a doubly-linked list.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_HashCode key
The key used in the DHT.
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.
indexing for the file-sharing service
uint32_t type
Type of the block (in big endian).
void GSF_push_start_(struct GSF_ConnectedPeer *peer)
A peer connected to us.
void GNUNET_DATASTORE_cancel(struct GNUNET_DATASTORE_QueueEntry *qe)
Cancel a datastore operation.
The identity of the host (wraps the signing key of the peer).
static unsigned int mig_size
Size of the doubly-linked list of migration blocks.
const struct GNUNET_PeerIdentity * GSF_connected_peer_get_identity2_(const struct GSF_ConnectedPeer *cp)
Obtain the identity of a connected peer.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
void GNUNET_PEER_change_rc(GNUNET_PEER_Id id, int delta)
Change the reference counter of an interned PID.
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
void GSF_push_done_()
Shutdown the module.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
static unsigned int count_targets(struct MigrationReadyBlock *block)
Count the number of peers this block has already been forwarded to.
Time for absolute times used by GNUnet, in microseconds.
static unsigned int anonymity
struct GNUNET_HashCode query
Query for the block.
static void find_content(void *cls)
Find content for migration to this peer.
int GNUNET_FS_handle_on_demand_block(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, GNUNET_DATASTORE_DatumProcessor cont, void *cont_cls)
We've received an on-demand encoded block from the datastore.
support for pushing out content
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
struct GNUNET_DATASTORE_QueueEntry * GNUNET_DATASTORE_get_for_replication(struct GNUNET_DATASTORE_Handle *h, unsigned int queue_priority, unsigned int max_queue_size, GNUNET_DATASTORE_DatumProcessor proc, void *proc_cls)
Get a random value from the datastore for content replication.
static void gather_migration_blocks(void *cls)
Task that is run periodically to obtain blocks for content migration.
void GNUNET_MQ_send_cancel(struct GNUNET_MQ_Envelope *ev)
Cancel sending the message.
#define GNUNET_MESSAGE_TYPE_FS_PUT
P2P response with content or active migration of content.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
static struct MigrationReadyPeer * peer_head
Head of linked list of peers.
size_t size
Size of the block.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct MigrationReadyBlock * prev
This is a doubly-linked list.
Time for relative time used by GNUnet, in microseconds.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.