aboutsummaryrefslogtreecommitdiff
path: root/src/dht/plugin_dhtlog_mysql_dump.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-08-10 15:23:21 +0000
committerNathan S. Evans <evans@in.tum.de>2010-08-10 15:23:21 +0000
commit0cd34604e5497edad8fa3a761ef626ad7168c90a (patch)
tree980215ff8a81f9b897e32c8ccad833652c3bf6d6 /src/dht/plugin_dhtlog_mysql_dump.c
parentda1d8fd60b46ccdeb9c9e09b58e0a2bb89db3bfd (diff)
downloadgnunet-0cd34604e5497edad8fa3a761ef626ad7168c90a.tar.gz
gnunet-0cd34604e5497edad8fa3a761ef626ad7168c90a.zip
lots of little things, mainly report statistics at end of dht profiling testcase
Diffstat (limited to 'src/dht/plugin_dhtlog_mysql_dump.c')
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c81
1 files changed, 76 insertions, 5 deletions
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index da3981841..9db19a202 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -77,6 +77,15 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
77 "malicious_putters, malicious_droppers, message) "\ 77 "malicious_putters, malicious_droppers, message) "\
78 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'" 78 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'"
79 79
80#define INSERT_STAT_STMT "prepare insert_stat from 'INSERT INTO node_statistics"\
81 "(trialuid, nodeuid, route_requests,"\
82 "route_forwards, result_requests,"\
83 "client_results, result_forwards, gets,"\
84 "puts, data_inserts, find_peer_requests, "\
85 "find_peers_started, gets_started, puts_started, find_peer_responses_received,"\
86 "get_responses_received, find_peer_responses_sent, get_responses_sent) "\
87 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'"
88
80#define INSERT_DHTKEY_STMT "prepare insert_dhtkey from 'INSERT ignore INTO dhtkeys (dhtkey, trialuid) "\ 89#define INSERT_DHTKEY_STMT "prepare insert_dhtkey from 'INSERT ignore INTO dhtkeys (dhtkey, trialuid) "\
81 "VALUES (?, @temp_trial)'" 90 "VALUES (?, @temp_trial)'"
82 91
@@ -142,6 +151,7 @@ iopen ()
142 if (PINIT (INSERT_QUERIES_STMT) || 151 if (PINIT (INSERT_QUERIES_STMT) ||
143 PINIT (INSERT_ROUTES_STMT) || 152 PINIT (INSERT_ROUTES_STMT) ||
144 PINIT (INSERT_TRIALS_STMT) || 153 PINIT (INSERT_TRIALS_STMT) ||
154 PINIT (INSERT_STAT_STMT) ||
145 PINIT (INSERT_NODES_STMT) || 155 PINIT (INSERT_NODES_STMT) ||
146 PINIT (INSERT_DHTKEY_STMT) || 156 PINIT (INSERT_DHTKEY_STMT) ||
147 PINIT (UPDATE_TRIALS_STMT) || 157 PINIT (UPDATE_TRIALS_STMT) ||
@@ -300,7 +310,71 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
300 return GNUNET_SYSERR; 310 return GNUNET_SYSERR;
301} 311}
302 312
313/*
314 * Inserts the specified stats into the dhttests.node_statistics table
315 *
316 * @param peer the peer inserting the statistic
317 * @param route_requests route requests seen
318 * @param route_forwards route requests forwarded
319 * @param result_requests route result requests seen
320 * @param client_requests client requests initiated
321 * @param result_forwards route results forwarded
322 * @param gets get requests handled
323 * @param puts put requests handle
324 * @param data_inserts data inserted at this node
325 * @param find_peer_requests find peer requests seen
326 * @param find_peers_started find peer requests initiated at this node
327 * @param gets_started get requests initiated at this node
328 * @param puts_started put requests initiated at this node
329 * @param find_peer_responses_received find peer responses received locally
330 * @param get_responses_received get responses received locally
331 * @param find_peer_responses_sent find peer responses sent from this node
332 * @param get_responses_sent get responses sent from this node
333 *
334 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
335 */
336int
337add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests,
338 unsigned int route_forwards, unsigned int result_requests,
339 unsigned int client_requests, unsigned int result_forwards,
340 unsigned int gets, unsigned int puts,
341 unsigned int data_inserts, unsigned int find_peer_requests,
342 unsigned int find_peers_started, unsigned int gets_started,
343 unsigned int puts_started, unsigned int find_peer_responses_received,
344 unsigned int get_responses_received, unsigned int find_peer_responses_sent,
345 unsigned int get_responses_sent)
346{
347 int ret;
348 if (outfile == NULL)
349 return GNUNET_SYSERR;
350
351 if (peer != NULL)
352 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&peer->hashPubKey));
353 else
354 ret = fprintf(outfile, "set @temp_node = 0;\n");
355
356 ret = fprintf(outfile, "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, "
357 "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, "
358 "@f_p_r = %u, @f_p_s = %u, @g_s = %u, @p_s = %u, "
359 "@f_p_r_r = %u, @g_r_r = %u, @f_p_r_s = %u, @g_r_s = %u;\n",
360 route_requests, route_forwards, result_requests,
361 client_requests, result_forwards, gets, puts,
362 data_inserts, find_peer_requests, find_peers_started,
363 gets_started, puts_started, find_peer_responses_received,
364 get_responses_received, find_peer_responses_sent,
365 get_responses_sent);
303 366
367 if (ret < 0)
368 return GNUNET_SYSERR;
369
370 ret = fprintf(outfile, "execute insert_stat using "
371 "@temp_trial, @temp_node, @r_r, @r_f, @res_r, @c_r, "
372 "@res_f, @gets, @puts, @d_i, "
373 "@f_p_r, @f_p_s, @g_s, @p_s, "
374 "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n");
375
376 return GNUNET_OK;
377}
304/* 378/*
305 * Inserts the specified dhtkey into the dhttests.dhtkeys table, 379 * Inserts the specified dhtkey into the dhttests.dhtkeys table,
306 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid 380 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
@@ -604,9 +678,7 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
604 cfg = plugin->cfg; 678 cfg = plugin->cfg;
605 max_varchar_len = 255; 679 max_varchar_len = 255;
606 680
607#if DEBUG_DHTLOG
608 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MySQL (DUMP) DHT Logger: initializing\n"); 681 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MySQL (DUMP) DHT Logger: initializing\n");
609#endif
610 682
611 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, 683 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg,
612 "MYSQLDUMP", "PATH", 684 "MYSQLDUMP", "PATH",
@@ -652,6 +724,7 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
652 GNUNET_assert(plugin->dhtlog_api == NULL); 724 GNUNET_assert(plugin->dhtlog_api == NULL);
653 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle)); 725 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
654 plugin->dhtlog_api->insert_trial = &add_trial; 726 plugin->dhtlog_api->insert_trial = &add_trial;
727 plugin->dhtlog_api->insert_stat = &add_stat;
655 plugin->dhtlog_api->insert_query = &add_query; 728 plugin->dhtlog_api->insert_query = &add_query;
656 plugin->dhtlog_api->update_trial = &update_trials; 729 plugin->dhtlog_api->update_trial = &update_trials;
657 plugin->dhtlog_api->insert_route = &add_route; 730 plugin->dhtlog_api->insert_route = &add_route;
@@ -662,7 +735,7 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
662 plugin->dhtlog_api->insert_extended_topology = &add_extended_topology; 735 plugin->dhtlog_api->insert_extended_topology = &add_extended_topology;
663 plugin->dhtlog_api->update_topology = &update_topology; 736 plugin->dhtlog_api->update_topology = &update_topology;
664 737
665 return NULL; 738 return plugin;
666} 739}
667 740
668/** 741/**
@@ -672,10 +745,8 @@ void *
672libgnunet_plugin_dhtlog_mysql_dump_done (void * cls) 745libgnunet_plugin_dhtlog_mysql_dump_done (void * cls)
673{ 746{
674 struct GNUNET_DHTLOG_Handle *dhtlog_api = cls; 747 struct GNUNET_DHTLOG_Handle *dhtlog_api = cls;
675#if DEBUG_DHTLOG
676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 748 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
677 "MySQL DHT Logger: database shutdown\n"); 749 "MySQL DHT Logger: database shutdown\n");
678#endif
679 GNUNET_assert(dhtlog_api != NULL); 750 GNUNET_assert(dhtlog_api != NULL);
680 751
681 GNUNET_free(dhtlog_api); 752 GNUNET_free(dhtlog_api);