API to manage query plan. More...
#include "platform.h"
#include "gnunet-service-fs.h"
#include "gnunet-service-fs_cp.h"
#include "gnunet-service-fs_pe.h"
#include "gnunet-service-fs_pr.h"
Go to the source code of this file.
Data Structures | |
struct | GSF_PendingRequestPlanBijection |
M:N binding of plans to pending requests. More... | |
struct | GSF_RequestPlan |
Information we keep per request per peer. More... | |
struct | PeerPlan |
Transmission plan for a peer. More... | |
struct | MergeContext |
Closure for merge_pr(). More... | |
Macros | |
#define | INSANE_STATISTICS GNUNET_NO |
Collect an instance number of statistics? May cause excessive IPC. More... | |
#define | N ((double) 128.0) |
Functions | |
static const struct GNUNET_HashCode * | get_rp_key (struct GSF_RequestPlan *rp) |
Return the query (key in the plan_map) for the given request plan. More... | |
static void | plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp) |
Insert the given request plan into the heap with the appropriate weight. More... | |
static struct GSF_PendingRequest * | get_latest (const struct GSF_RequestPlan *rp) |
Get the pending request with the highest TTL from the given plan. More... | |
static void | schedule_peer_transmission (void *cls) |
Figure out when and how to transmit to the given peer. More... | |
static int | merge_pr (void *cls, const struct GNUNET_HashCode *query, void *element) |
Iterator that checks if an equivalent request is already present for this peer. More... | |
void | GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) |
Create a new query plan entry. More... | |
void | GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp) |
Notify the plan about a peer being no longer available; destroy all entries associated with this peer. More... | |
int | GSF_request_plan_reference_get_last_transmission_ (struct GSF_PendingRequestPlanBijection *pr_head, struct GSF_ConnectedPeer *sender, struct GNUNET_TIME_Absolute *result) |
Get the last transmission attempt time for the request plan list referenced by pr_head, that was sent to sender. More... | |
void | GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr) |
Notify the plan about a request being done; destroy all entries associated with this request. More... | |
void | GSF_plan_init () |
Initialize plan subsystem. More... | |
void | GSF_plan_done () |
Shutdown plan subsystem. More... | |
Variables | |
static struct GNUNET_CONTAINER_MultiPeerMap * | plans |
Hash map from peer identities to PeerPlans. More... | |
static unsigned long long | total_delay |
Sum of all transmission counters (equals total delay for all plan entries). More... | |
static unsigned long long | plan_count |
Number of plan entries. More... | |
API to manage query plan.
Definition in file gnunet-service-fs_pe.c.
#define INSANE_STATISTICS GNUNET_NO |
Collect an instance number of statistics? May cause excessive IPC.
Definition at line 35 of file gnunet-service-fs_pe.c.
#define N ((double) 128.0) |
|
static |
Return the query (key in the plan_map) for the given request plan.
Note that this key may change as there can be multiple pending requests for the same key and we just return one of them; this particular one might complete while another one might still be active, hence the lifetime of the returned hash code is NOT necessarily identical to that of the struct GSF_RequestPlan
given.
rp | a request plan |
Definition at line 233 of file gnunet-service-fs_pe.c.
References GSF_pending_request_get_data_(), GSF_PendingRequestData::query, and rp.
Referenced by GSF_plan_add_(), GSF_plan_notify_peer_disconnect_(), and plan().
|
static |
Insert the given request plan into the heap with the appropriate weight.
pp | associated peer's plan |
rp | request to plan |
Running average delay we currently impose.
Definition at line 246 of file gnunet-service-fs_pe.c.
References PeerPlan::delay_heap, get_rp_key(), gettext_noop, GNUNET_assert, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_multihashmap_contains_value(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, GSF_current_priorities, GSF_pending_request_get_data_(), GSF_stats, N, plan_count, PeerPlan::plan_map, PeerPlan::priority_heap, GSF_PendingRequestData::query, GNUNET_TIME_Relative::rel_value_us, rp, total_delay, and TTL_DECREMENT.
Referenced by GSF_plan_add_(), and schedule_peer_transmission().
|
static |
Get the pending request with the highest TTL from the given plan.
rp | plan to investigate |
Definition at line 346 of file gnunet-service-fs_pe.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_break, GNUNET_YES, GSF_pending_request_get_data_(), GSF_pending_request_test_active_(), GSF_PendingRequestPlanBijection::next_PE, GSF_PendingRequestPlanBijection::pr, ret, rp, and GSF_PendingRequestData::ttl.
Referenced by merge_pr(), and schedule_peer_transmission().
|
static |
Figure out when and how to transmit to the given peer.
cls | the struct PeerPlan |
Definition at line 379 of file gnunet-service-fs_pe.c.
References PeerPlan::cp, PeerPlan::delay_heap, PeerPlan::env, get_latest(), gettext_noop, GNUNET_assert, GNUNET_CONTAINER_heap_get_size(), GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_peek(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_notify_sent(), GNUNET_NO, GNUNET_SCHEDULER_add_at(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_remaining(), GNUNET_YES, GSF_peer_transmit_(), GSF_pending_request_get_message_(), GSF_stats, plan(), PeerPlan::priority_heap, GNUNET_TIME_Relative::rel_value_us, rp, schedule_peer_transmission(), PeerPlan::task, and total_delay.
Referenced by GSF_plan_add_(), and schedule_peer_transmission().
|
static |
Iterator that checks if an equivalent request is already present for this peer.
cls | closure |
query | the query |
element | request plan stored at the node |
Definition at line 498 of file gnunet-service-fs_pe.c.
References GNUNET_TIME_Absolute::abs_value_us, get_latest(), gettext_noop, GNUNET_break, GNUNET_CONTAINER_MDLL_insert, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_YES, GSF_pending_request_get_data_(), GSF_pending_request_is_compatible_(), GSF_pending_request_test_active_(), GSF_stats, MergeContext::merged, GSF_PendingRequestPlanBijection::pr, MergeContext::pr, GSF_PendingRequestData::pr_head, GSF_PendingRequestData::pr_tail, rp, GSF_PendingRequestPlanBijection::rp, ttl, and GSF_PendingRequestData::ttl.
Referenced by GSF_plan_add_().
void GSF_plan_add_ | ( | struct GSF_ConnectedPeer * | cp, |
struct GSF_PendingRequest * | pr | ||
) |
Create a new query plan entry.
cp | peer with the entry |
pr | request with the entry |
Definition at line 557 of file gnunet-service-fs_pe.c.
References PeerPlan::cp, PeerPlan::delay_heap, get_rp_key(), gettext_noop, GNUNET_assert, GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MAX, GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_MDLL_insert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), GNUNET_YES, GSF_connected_peer_get_identity2_(), GSF_pending_request_get_data_(), GSF_pending_request_test_active_(), GSF_stats, id, merge_pr(), MergeContext::merged, plan(), plan_count, PeerPlan::plan_map, plans, GSF_PendingRequestPlanBijection::pr, MergeContext::pr, GSF_PendingRequestData::pr_head, GSF_PendingRequestData::pr_tail, PeerPlan::priority_heap, GSF_PendingRequestData::query, rp, GSF_PendingRequestPlanBijection::rp, schedule_peer_transmission(), and PeerPlan::task.
Referenced by consider_peer_for_forwarding(), and consider_request_for_forwarding().
void GSF_plan_notify_peer_disconnect_ | ( | const struct GSF_ConnectedPeer * | cp | ) |
Notify the plan about a peer being no longer available; destroy all entries associated with this peer.
cp | connected peer |
Definition at line 637 of file gnunet-service-fs_pe.c.
References PeerPlan::delay_heap, get_rp_key(), gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_CONTAINER_MDLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_set(), GNUNET_YES, GSF_connected_peer_get_identity2_(), GSF_pending_request_get_data_(), GSF_stats, id, plan_count, PeerPlan::plan_map, plans, GSF_PendingRequestPlanBijection::pr, GSF_PendingRequestData::pr_head, GSF_PendingRequestData::pr_tail, PeerPlan::priority_heap, rp, and PeerPlan::task.
Referenced by GSF_peer_disconnect_handler().
int GSF_request_plan_reference_get_last_transmission_ | ( | struct GSF_PendingRequestPlanBijection * | pr_head, |
struct GSF_ConnectedPeer * | sender, | ||
struct GNUNET_TIME_Absolute * | result | ||
) |
Get the last transmission attempt time for the request plan list referenced by pr_head, that was sent to sender.
Get the last transmission attempt time for the request plan list referenced by 'rpr_head', that was sent to 'sender'.
pr_head | request plan reference list to check. |
sender | the peer that we've sent the request to. |
result | the timestamp to fill, set to GNUNET_TIME_UNIT_FOREVER_ABS if never transmitted |
Definition at line 722 of file gnunet-service-fs_pe.c.
References GNUNET_TIME_Absolute::abs_value_us, PeerPlan::cp, GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, GSF_RequestPlan::last_transmission, GSF_PendingRequestPlanBijection::next_PR, GSF_RequestPlan::pp, result, and GSF_PendingRequestPlanBijection::rp.
Referenced by process_reply().
void GSF_plan_notify_request_done_ | ( | struct GSF_PendingRequest * | pr | ) |
Notify the plan about a request being done; destroy all entries associated with this request.
pr | request that is done |
Definition at line 754 of file gnunet-service-fs_pe.c.
References gettext_noop, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_heap_remove_node(), GNUNET_CONTAINER_MDLL_remove, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_YES, GSF_pending_request_get_data_(), GSF_stats, plan_count, GSF_PendingRequestPlanBijection::pr, GSF_PendingRequestData::pr_head, GSF_PendingRequestData::pr_tail, GSF_PendingRequestData::query, rp, and GSF_PendingRequestPlanBijection::rp.
Referenced by clean_request(), and GSF_pending_request_cancel_().
void GSF_plan_init | ( | void | ) |
Initialize plan subsystem.
Definition at line 796 of file gnunet-service-fs_pe.c.
References GNUNET_CONTAINER_multipeermap_create(), GNUNET_YES, and plans.
Referenced by run().
void GSF_plan_done | ( | void | ) |
Shutdown plan subsystem.
Definition at line 807 of file gnunet-service-fs_pe.c.
References GNUNET_assert, GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_size(), and plans.
Referenced by shutdown_task().
|
static |
Hash map from peer identities to PeerPlans.
Definition at line 207 of file gnunet-service-fs_pe.c.
Referenced by GSF_plan_add_(), GSF_plan_done(), GSF_plan_init(), and GSF_plan_notify_peer_disconnect_().
|
static |
Sum of all transmission counters (equals total delay for all plan entries).
Definition at line 212 of file gnunet-service-fs_pe.c.
Referenced by plan(), and schedule_peer_transmission().
|
static |
Number of plan entries.
Definition at line 217 of file gnunet-service-fs_pe.c.
Referenced by GSF_plan_add_(), GSF_plan_notify_peer_disconnect_(), GSF_plan_notify_request_done_(), and plan().