high-level statistics function More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "testbed_api_operations.h"
Go to the source code of this file.
Data Structures | |
struct | GetStatsContext |
Context information for use in GNUNET_TESTBED_get_statistics() More... | |
struct | PeerGetStatsContext |
Context information with respect to a particular peer. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "testbed-api-statistics", __VA_ARGS__) |
Generic logging shorthand. More... | |
#define | LOG_DEBUG(...) LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
Debug logging shorthand. More... | |
Functions | |
static void | call_completion_task (void *cls) |
Call statistics operation completion. More... | |
static void | op_done_task (void *cls) |
Task to mark statistics service connect operation as done. More... | |
static void | iteration_completion_cb (void *cls, int success) |
Continuation called by the "get_all" and "get" functions. More... | |
static int | iterator_cb (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) |
Callback function to process statistic values. More... | |
static void | service_connect_comp (void *cls, struct GNUNET_TESTBED_Operation *op, void *ca_result, const char *emsg) |
Called after opening a connection to the statistics service of a peer. More... | |
static void * | statistics_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
Adapter function called to establish a connection to the statistics service of a peer. More... | |
static void | statistics_da (void *cls, void *op_result) |
Adapter function called to destroy statistics connection. More... | |
static void | opstart_get_stats (void *cls) |
Function called when get_statistics operation is ready. More... | |
static void | oprelease_get_stats (void *cls) |
Function called when get_statistics operation is cancelled or marked as done. More... | |
struct GNUNET_TESTBED_Operation * | GNUNET_TESTBED_get_statistics (unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, const char *subsystem, const char *name, GNUNET_TESTBED_StatisticsIterator proc, GNUNET_TESTBED_OperationCompletionCallback cont, void *cls) |
Convenience method that iterates over all (running) peers and retrieves all statistics from each peer. More... | |
Variables | |
static struct OperationQueue * | no_wait_queue |
A no-wait operation queue. More... | |
high-level statistics function
Definition in file testbed_api_statistics.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "testbed-api-statistics", __VA_ARGS__) |
Generic logging shorthand.
Definition at line 37 of file testbed_api_statistics.c.
#define LOG_DEBUG | ( | ... | ) | LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
Debug logging shorthand.
Definition at line 43 of file testbed_api_statistics.c.
|
static |
Call statistics operation completion.
We call it in a separate task because the iteration_completion_cb() cannot destroy statistics handle which will be the case if the user calls GNUNET_TESTBED_operation_done() on the get_statistics operation.
cls | the GetStatsContext |
Definition at line 154 of file testbed_api_statistics.c.
References GNUNET_assert, LOG_DEBUG, and sc.
Referenced by iteration_completion_cb().
|
static |
Task to mark statistics service connect operation as done.
We call it here as we cannot destroy the statistics handle in iteration_completion_cb()
cls | the PeerGetStatsContext |
Definition at line 172 of file testbed_api_statistics.c.
References GNUNET_assert, GNUNET_TESTBED_operation_done(), op, PeerGetStatsContext::op_done_task_id, PeerGetStatsContext::peer_index, sc, and PeerGetStatsContext::sc.
Referenced by iteration_completion_cb().
|
static |
Continuation called by the "get_all" and "get" functions.
cls | the PeerGetStatsContext |
success | GNUNET_OK if statistics were successfully obtained, GNUNET_SYSERR if not. |
Definition at line 195 of file testbed_api_statistics.c.
References call_completion_task(), PeerGetStatsContext::get_handle, GNUNET_break, GNUNET_OK, GNUNET_SCHEDULER_add_now(), LOG_DEBUG, op_done_task(), PeerGetStatsContext::op_done_task_id, sc, and PeerGetStatsContext::sc.
Referenced by service_connect_comp().
|
static |
Callback function to process statistic values.
cls | the PeerGetStatsContext |
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 225 of file testbed_api_statistics.c.
References GNUNET_SYSERR, LOG_DEBUG, name, peer, PeerGetStatsContext::peer_index, ret, sc, PeerGetStatsContext::sc, subsystem, and value.
Referenced by service_connect_comp().
|
static |
Called after opening a connection to the statistics service of a peer.
cls | the PeerGetStatsContext |
op | the operation that has been finished |
ca_result | the service handle returned from GNUNET_TESTBED_ConnectAdapter() |
emsg | error message in case the operation has failed; will be NULL if operation has executed successfully. |
Definition at line 256 of file testbed_api_statistics.c.
References PeerGetStatsContext::get_handle, GNUNET_STATISTICS_get(), h, iteration_completion_cb(), iterator_cb(), LOG_DEBUG, GetStatsContext::name, PeerGetStatsContext::peer_index, PeerGetStatsContext::sc, and GetStatsContext::subsystem.
Referenced by opstart_get_stats().
|
static |
Adapter function called to establish a connection to the statistics service of a peer.
cls | the PeerGetStatsContext |
cfg | configuration of the peer to connect to; will be available until GNUNET_TESTBED_operation_done() is called on the operation returned from GNUNET_TESTBED_service_connect() |
Definition at line 285 of file testbed_api_statistics.c.
References cfg, GNUNET_STATISTICS_create(), LOG_DEBUG, and PeerGetStatsContext::peer_index.
Referenced by opstart_get_stats().
|
static |
Adapter function called to destroy statistics connection.
cls | the PeerGetStatsContext |
op_result | service handle returned from the connect adapter |
Definition at line 302 of file testbed_api_statistics.c.
References PeerGetStatsContext::get_handle, GNUNET_free, GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), GNUNET_STATISTICS_get_cancel(), PeerGetStatsContext::op_done_task_id, op_result(), and sh.
Referenced by opstart_get_stats().
|
static |
Function called when get_statistics operation is ready.
cls | the GetStatsContext |
Definition at line 325 of file testbed_api_statistics.c.
References GNUNET_break, GNUNET_malloc, GNUNET_new, GNUNET_TESTBED_service_connect(), LOG_DEBUG, peer, PeerGetStatsContext::peer_index, sc, PeerGetStatsContext::sc, service_connect_comp(), statistics_ca(), and statistics_da().
Referenced by GNUNET_TESTBED_get_statistics().
|
static |
Function called when get_statistics operation is cancelled or marked as done.
cls | the GetStatsContext |
Definition at line 361 of file testbed_api_statistics.c.
References GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TESTBED_operation_done(), GNUNET_TESTBED_operation_queue_destroy_empty_(), GNUNET_YES, LOG_DEBUG, no_wait_queue, peer, and sc.
Referenced by GNUNET_TESTBED_get_statistics().
|
static |
A no-wait operation queue.
Definition at line 142 of file testbed_api_statistics.c.
Referenced by GNUNET_TESTBED_get_statistics(), and oprelease_get_stats().