diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-08-12 22:59:35 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-08-12 22:59:35 +0000 |
commit | efb7b575ac99e67da4315ff9f7a5652413a8d472 (patch) | |
tree | dffd18faebabdbee95ffa15ac4ecb5f4a49b9496 /src/consensus | |
parent | a94ef1396711df72377dea56bd07f01c9de35eb1 (diff) | |
download | gnunet-efb7b575ac99e67da4315ff9f7a5652413a8d472.tar.gz gnunet-efb7b575ac99e67da4315ff9f7a5652413a8d472.zip |
- show received elements in consensus profiler
Diffstat (limited to 'src/consensus')
-rw-r--r-- | src/consensus/gnunet-consensus.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/src/consensus/gnunet-consensus.c b/src/consensus/gnunet-consensus.c index 847c99a02..dca18cece 100644 --- a/src/consensus/gnunet-consensus.c +++ b/src/consensus/gnunet-consensus.c | |||
@@ -53,6 +53,8 @@ static struct GNUNET_HashCode session_id; | |||
53 | 53 | ||
54 | static unsigned int peers_done = 0; | 54 | static unsigned int peers_done = 0; |
55 | 55 | ||
56 | static unsigned *results_for_peer; | ||
57 | |||
56 | 58 | ||
57 | /** | 59 | /** |
58 | * Signature of the event handler function called by the | 60 | * Signature of the event handler function called by the |
@@ -78,9 +80,11 @@ destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *ctx) | |||
78 | peers_done++; | 80 | peers_done++; |
79 | if (peers_done == num_peers) | 81 | if (peers_done == num_peers) |
80 | { | 82 | { |
81 | int i; | 83 | unsigned int i; |
82 | for (i = 0; i < num_peers; i++) | 84 | for (i = 0; i < num_peers; i++) |
83 | GNUNET_TESTBED_operation_done (testbed_operations[i]); | 85 | GNUNET_TESTBED_operation_done (testbed_operations[i]); |
86 | for (i = 0; i < num_peers; i++) | ||
87 | printf ("P%u got %u of %u elements\n", i, results_for_peer[i], num_values); | ||
84 | GNUNET_SCHEDULER_shutdown (); | 88 | GNUNET_SCHEDULER_shutdown (); |
85 | } | 89 | } |
86 | } | 90 | } |
@@ -174,7 +178,6 @@ connect_complete (void *cls, | |||
174 | void *ca_result, | 178 | void *ca_result, |
175 | const char *emsg) | 179 | const char *emsg) |
176 | { | 180 | { |
177 | struct GNUNET_CONSENSUS_Handle **chp; | ||
178 | 181 | ||
179 | if (NULL != emsg) | 182 | if (NULL != emsg) |
180 | { | 183 | { |
@@ -182,12 +185,10 @@ connect_complete (void *cls, | |||
182 | GNUNET_assert (0); | 185 | GNUNET_assert (0); |
183 | } | 186 | } |
184 | 187 | ||
185 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "connect complete\n"); | ||
186 | |||
187 | chp = (struct GNUNET_CONSENSUS_Handle **) cls; | ||
188 | *chp = (struct GNUNET_CONSENSUS_Handle *) ca_result; | ||
189 | num_connected_handles++; | 188 | num_connected_handles++; |
190 | 189 | ||
190 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "connect complete\n"); | ||
191 | |||
191 | if (num_connected_handles == num_peers) | 192 | if (num_connected_handles == num_peers) |
192 | { | 193 | { |
193 | do_consensus (); | 194 | do_consensus (); |
@@ -199,7 +200,11 @@ static void | |||
199 | new_element_cb (void *cls, | 200 | new_element_cb (void *cls, |
200 | const struct GNUNET_SET_Element *element) | 201 | const struct GNUNET_SET_Element *element) |
201 | { | 202 | { |
202 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "received new element\n"); | 203 | struct GNUNET_CONSENSUS_Handle **chp = cls; |
204 | |||
205 | GNUNET_assert (NULL != cls); | ||
206 | |||
207 | results_for_peer[chp - consensus_handles]++; | ||
203 | } | 208 | } |
204 | 209 | ||
205 | 210 | ||
@@ -217,10 +222,13 @@ static void * | |||
217 | connect_adapter (void *cls, | 222 | connect_adapter (void *cls, |
218 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 223 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
219 | { | 224 | { |
225 | struct GNUNET_CONSENSUS_Handle **chp = cls; | ||
220 | struct GNUNET_CONSENSUS_Handle *consensus; | 226 | struct GNUNET_CONSENSUS_Handle *consensus; |
227 | chp = (struct GNUNET_CONSENSUS_Handle **) cls; | ||
228 | |||
221 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "connect adapter, %d peers\n", num_peers); | 229 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "connect adapter, %d peers\n", num_peers); |
222 | consensus = GNUNET_CONSENSUS_create (cfg, num_peers, peer_ids, &session_id, new_element_cb, NULL); | 230 | consensus = GNUNET_CONSENSUS_create (cfg, num_peers, peer_ids, &session_id, new_element_cb, chp); |
223 | GNUNET_assert (NULL != consensus); | 231 | *chp = (struct GNUNET_CONSENSUS_Handle *) consensus; |
224 | return consensus; | 232 | return consensus; |
225 | } | 233 | } |
226 | 234 | ||
@@ -268,8 +276,8 @@ peer_info_cb (void *cb_cls, | |||
268 | if (num_retrieved_peer_ids == num_peers) | 276 | if (num_retrieved_peer_ids == num_peers) |
269 | for (i = 0; i < num_peers; i++) | 277 | for (i = 0; i < num_peers; i++) |
270 | testbed_operations[i] = | 278 | testbed_operations[i] = |
271 | GNUNET_TESTBED_service_connect (NULL, peers[i], "consensus", connect_complete, &consensus_handles[i], | 279 | GNUNET_TESTBED_service_connect (NULL, peers[i], "consensus", connect_complete, NULL, |
272 | connect_adapter, disconnect_adapter, NULL); | 280 | connect_adapter, disconnect_adapter, &consensus_handles[i]); |
273 | } | 281 | } |
274 | else | 282 | else |
275 | { | 283 | { |
@@ -309,6 +317,7 @@ test_master (void *cls, | |||
309 | 317 | ||
310 | peer_ids = GNUNET_malloc (num_peers * sizeof (struct GNUNET_PeerIdentity)); | 318 | peer_ids = GNUNET_malloc (num_peers * sizeof (struct GNUNET_PeerIdentity)); |
311 | 319 | ||
320 | results_for_peer = GNUNET_malloc (num_peers * sizeof (unsigned int)); | ||
312 | consensus_handles = GNUNET_malloc (num_peers * sizeof (struct ConsensusHandle *)); | 321 | consensus_handles = GNUNET_malloc (num_peers * sizeof (struct ConsensusHandle *)); |
313 | testbed_operations = GNUNET_malloc (num_peers * sizeof (struct ConsensusHandle *)); | 322 | testbed_operations = GNUNET_malloc (num_peers * sizeof (struct ConsensusHandle *)); |
314 | 323 | ||
@@ -324,6 +333,23 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
324 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 333 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
325 | { | 334 | { |
326 | static char *session_str = "gnunet-consensus/test"; | 335 | static char *session_str = "gnunet-consensus/test"; |
336 | char *topology; | ||
337 | |||
338 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "testbed", "OVERLAY_TOPOLOGY", &topology)) | ||
339 | { | ||
340 | fprintf (stderr, "'OVERLAY_TOPOLOGY' not found in 'testbed' config section, " | ||
341 | "seems like you passed the wrong configuration file\n"); | ||
342 | return; | ||
343 | } | ||
344 | |||
345 | if (0 == strcasecmp (topology, "NONE")) | ||
346 | { | ||
347 | fprintf (stderr, "'OVERLAY_TOPOLOGY' set to 'NONE', " | ||
348 | "seems like you passed the wrong configuration file\n"); | ||
349 | return; | ||
350 | } | ||
351 | |||
352 | GNUNET_free (topology); | ||
327 | 353 | ||
328 | if (num_peers < replication) | 354 | if (num_peers < replication) |
329 | { | 355 | { |