diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-09-10 18:58:23 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-09-10 18:58:23 +0000 |
commit | f20bd9202bf4e3c4e9e1fc00f26b1e24a70f1353 (patch) | |
tree | 51acd0ef9508d8b752550862b81f49111de80bd2 | |
parent | 65036e201bd0d5b6a856f5ded9e8dadd3a82ddc1 (diff) |
adding another testbed API function: convenience function to get all stats from all peers
git-svn-id: https://gnunet.org/svn/gnunet@23740 140774ce-b5e7-0310-ab8b-a85725594a96
-rw-r--r-- | src/include/gnunet_testbed_service.h | 38 | ||||
-rw-r--r-- | src/testbed/Makefile.am | 1 | ||||
-rw-r--r-- | src/testbed/testbed_api_statistics.c | 56 |
3 files changed, 95 insertions, 0 deletions
diff --git a/src/include/gnunet_testbed_service.h b/src/include/gnunet_testbed_service.h index 0c1cf985fe..bd9e51bfac 100644 --- a/src/include/gnunet_testbed_service.h +++ b/src/include/gnunet_testbed_service.h @@ -1202,6 +1202,44 @@ GNUNET_TESTBED_destroy (struct GNUNET_TESTBED_Testbed *testbed); /** + * Callback function to process statistic values from all peers. + * + * @param cls closure + * @param peer the peer the statistic belong to + * @param subsystem name of subsystem that created the statistic + * @param name the name of the datum + * @param value the current value + * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not + * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration + */ +typedef int (*GNUNET_TESTBED_StatisticsIterator) (void *cls, + const struct GNUNET_TESTBED_Peer *peer, + const char *subsystem, + const char *name, + uint64_t value, + int is_persistent); + + +/** + * Convenience method that iterates over all (running) peers + * and retrieves all statistics from each peer. + * + * @param num_peers number of peers to iterate over + * @param peers array of peers to iterate over + * @param proc processing function for each statistic retrieved + * @param cont continuation to call once call is completed(?) + * @param cls closure to pass to proc and cont + * @return operation handle to cancel the operation + */ +struct GNUNET_TESTBED_Operation * +GNUNET_TESTBED_get_statistics (unsigned int num_peers, + struct GNUNET_TESTBED_Peer **peers, + GNUNET_TESTBED_StatisticsIterator proc, + GNUNET_TESTBED_OperationCompletionCallback cont, + void *cls); + + +/** * Convenience method for running a testbed with * a single call. Underlay and overlay topology * are configured using the "UNDERLAY" and "OVERLAY" diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index a94193305e..5efaef97ef 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am @@ -51,6 +51,7 @@ libgnunettestbed_la_SOURCES = \ testbed_api_operations.c testbed_api_operations.h \ testbed_api_peers.c testbed_api_peers.h \ testbed_api_services.c \ + testbed_api_statistics.c \ testbed_api_testbed.c \ testbed_api_test.c \ testbed_api_topology.c diff --git a/src/testbed/testbed_api_statistics.c b/src/testbed/testbed_api_statistics.c new file mode 100644 index 0000000000..8fe104be27 --- /dev/null +++ b/src/testbed/testbed_api_statistics.c @@ -0,0 +1,56 @@ +/* + This file is part of GNUnet + (C) 2008--2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +/** + * @file testbed/testbed_api_statistics.c + * @brief high-level statistics function + * @author Christian Grothoff + * @author Sree Harsha Totakura + */ +#include "platform.h" +#include "gnunet_testbed_service.h" + + +/** + * Convenience method that iterates over all (running) peers + * and retrieves all statistics from each peer. + * + * @param num_peers number of peers to iterate over + * @param peers array of peers to iterate over + * @param proc processing function for each statistic retrieved + * @param cont continuation to call once call is completed(?) + * @param cls closure to pass to proc and cont + * @return operation handle to cancel the operation + */ +struct GNUNET_TESTBED_Operation * +GNUNET_TESTBED_get_statistics (unsigned int num_peers, + struct GNUNET_TESTBED_Peer **peers, + GNUNET_TESTBED_StatisticsIterator proc, + GNUNET_TESTBED_OperationCompletionCallback cont, + void *cls) +{ + // FIXME: not implemented, but clients will kind-of work if we do this: + GNUNET_break (0); + cont (cls, NULL, NULL); + return NULL; +} + + +/* end of testbed_api_statistics.c */ |