37 #define LOG(kind, ...) \
38 GNUNET_log_from (kind, "testbed-api-statistics", __VA_ARGS__)
43 #define LOG_DEBUG(...) \
44 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
159 sc->call_completion_task_id = NULL;
160 LOG_DEBUG (
"Calling get_statistics() continuation callback\n");
161 sc->cont (
sc->cb_cls,
sc->main_op, NULL);
205 if (
sc->num_completed ==
sc->num_peers)
207 LOG_DEBUG (
"Scheduling to call iteration completion callback\n");
208 sc->call_completion_task_id =
264 LOG_DEBUG (
"Retrieving statistics of peer %u\n",
289 LOG_DEBUG (
"Connecting to statistics service of peer %u\n",
331 LOG_DEBUG (
"Starting get_statistics operation\n");
336 if (NULL ==
sc->peers[
peer])
366 LOG_DEBUG (
"Cleaning up get_statistics operation\n");
367 if (NULL !=
sc->call_completion_task_id)
373 if (NULL !=
sc->ops[
peer])
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static int ret
Return value of the commandline.
static struct GNUNET_ARM_Operation * op
Current operation.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
static struct SolverHandle * sh
static struct CadetPeer * peers
Operation to get peer ids.
static unsigned int num_peers
static char * value
Value of the record to add/remove.
static struct GNUNET_FS_SearchContext * sc
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
API for writing tests and creating large-scale emulation testbeds for GNUnet.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
void GNUNET_STATISTICS_get_cancel(struct GNUNET_STATISTICS_GetHandle *gh)
Cancel a GNUNET_STATISTICS_get request.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_STATISTICS_GetHandle * GNUNET_STATISTICS_get(struct GNUNET_STATISTICS_Handle *handle, const char *subsystem, const char *name, GNUNET_STATISTICS_Callback cont, GNUNET_STATISTICS_Iterator proc, void *cls)
Get statistic from the peer.
void GNUNET_TESTBED_operation_done(struct GNUNET_TESTBED_Operation *operation)
This function is used to signal that the event information (struct GNUNET_TESTBED_EventInformation) f...
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, const char *service_name, GNUNET_TESTBED_ServiceConnectCompletionCallback cb, void *cb_cls, GNUNET_TESTBED_ConnectAdapter ca, GNUNET_TESTBED_DisconnectAdapter da, void *cada_cls)
Connect to a service offered by the given peer.
int(* GNUNET_TESTBED_StatisticsIterator)(void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values from all peers.
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...
void(* GNUNET_TESTBED_OperationCompletionCallback)(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Callback to be called when an operation is completed.
static int op_result(struct GNUNET_OP_Handle *h, uint64_t op_id, int64_t result_code, const void *data, uint16_t data_size, void **ctx, uint8_t cancel)
Remove an operation, and call its result callback (unless it was cancelled).
Entry in list of pending tasks.
Linked list of things we still need to do.
Opaque handle to an abstract operation to be executed by the testing framework.
A peer controlled by the testing framework.
Context information for use in GNUNET_TESTBED_get_statistics()
unsigned int num_completed
How many peers' statistics have we iterated through.
struct GNUNET_TESTBED_Peer ** peers
The array of peers whose statistics services are to be accessed.
GNUNET_TESTBED_OperationCompletionCallback cont
The callback to call when we are done iterating through all peers' statistics services.
char * name
The particular statistics value of interest.
unsigned int num_peers
The number of peers present in the peers array.
struct GNUNET_SCHEDULER_Task * call_completion_task_id
The task for calling the continuation callback.
void * cb_cls
The closure for the above callbacks.
struct GNUNET_TESTBED_Operation * main_op
The main operation we generate while creating this context.
GNUNET_TESTBED_StatisticsIterator proc
The iterator to call with statistics information.
char * subsystem
The subsystem of peers for which statistics are requested.
struct GNUNET_TESTBED_Operation ** ops
The service connect operations we create to open connection to the statistics service of each given p...
Queue of operations where we can only support a certain number of concurrent operations of a particul...
Context information with respect to a particular peer.
struct GNUNET_SCHEDULER_Task * op_done_task_id
Task to mark the statistics service connect operation as done.
struct GNUNET_STATISTICS_GetHandle * get_handle
The handle from GNUNET_STATISTICS_get()
struct GetStatsContext * sc
The GetStatsContext which is associated with this context.
unsigned int peer_index
The index of this peer in the peers array of GetStatsContext.
struct GNUNET_TESTBED_Operation * GNUNET_TESTBED_operation_create_(void *cls, OperationStart start, OperationRelease release)
Create an 'operation' to be performed.
struct OperationQueue * GNUNET_TESTBED_operation_queue_create_(enum OperationQueueType type, unsigned int max_active)
Create an operation queue.
void GNUNET_TESTBED_operation_queue_insert_(struct OperationQueue *queue, struct GNUNET_TESTBED_Operation *op)
Add an operation to a queue.
void GNUNET_TESTBED_operation_begin_wait_(struct GNUNET_TESTBED_Operation *op)
Marks the given operation as waiting on the queues.
int GNUNET_TESTBED_operation_queue_destroy_empty_(struct OperationQueue *queue)
Destroys the operation queue if it is empty.
internal API to access the 'operations' subsystem
@ OPERATION_QUEUE_TYPE_FIXED
Operation queue which permits a fixed maximum number of operations to be active at any time.
static void iteration_completion_cb(void *cls, int success)
Continuation called by the "get_all" and "get" functions.
static void oprelease_get_stats(void *cls)
Function called when get_statistics operation is cancelled or marked as done.
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.
#define LOG_DEBUG(...)
Debug logging shorthand.
static void call_completion_task(void *cls)
Call statistics operation completion.
static void op_done_task(void *cls)
Task to mark statistics service connect operation as done.
static struct OperationQueue * no_wait_queue
A no-wait operation queue.
static void opstart_get_stats(void *cls)
Function called when get_statistics operation is ready.
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.
static int iterator_cb(void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values.
static void statistics_da(void *cls, void *op_result)
Adapter function called to destroy statistics connection.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.