diff options
Diffstat (limited to 'src/dht/plugin_dhtlog_mysql_dump.c')
-rw-r--r-- | src/dht/plugin_dhtlog_mysql_dump.c | 107 |
1 files changed, 51 insertions, 56 deletions
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c index 25958044c..bbb1da0c9 100644 --- a/src/dht/plugin_dhtlog_mysql_dump.c +++ b/src/dht/plugin_dhtlog_mysql_dump.c | |||
@@ -162,24 +162,16 @@ static int | |||
162 | iopen () | 162 | iopen () |
163 | { | 163 | { |
164 | #define PINIT(a) (GNUNET_OK != (prepared_statement_create(a))) | 164 | #define PINIT(a) (GNUNET_OK != (prepared_statement_create(a))) |
165 | if (PINIT (INSERT_QUERIES_STMT) || | 165 | if (PINIT (INSERT_QUERIES_STMT) || PINIT (INSERT_ROUTES_STMT) || |
166 | PINIT (INSERT_ROUTES_STMT) || | 166 | PINIT (INSERT_ROUND_STMT) || PINIT (INSERT_ROUND_DETAILS_STMT) || |
167 | PINIT (INSERT_ROUND_STMT) || | 167 | PINIT (INSERT_TRIALS_STMT) || PINIT (SET_MALICIOUS_STMT) || |
168 | PINIT (INSERT_ROUND_DETAILS_STMT) || | 168 | PINIT (INSERT_GENERIC_STAT_STMT) || PINIT (INSERT_STAT_STMT) || |
169 | PINIT (INSERT_TRIALS_STMT) || | 169 | PINIT (INSERT_NODES_STMT) || PINIT (INSERT_DHTKEY_STMT) || |
170 | PINIT (SET_MALICIOUS_STMT) || | 170 | PINIT (UPDATE_TRIALS_STMT) || PINIT (GET_DHTKEYUID_STMT) || |
171 | PINIT (INSERT_GENERIC_STAT_STMT) || | 171 | PINIT (GET_NODEUID_STMT) || PINIT (UPDATE_CONNECTIONS_STMT) || |
172 | PINIT (INSERT_STAT_STMT) || | 172 | PINIT (INSERT_TOPOLOGY_STMT) || PINIT (EXTEND_TOPOLOGY_STMT) || |
173 | PINIT (INSERT_NODES_STMT) || | 173 | PINIT (UPDATE_TOPOLOGY_STMT) || PINIT (GET_TRIAL_STMT) || |
174 | PINIT (INSERT_DHTKEY_STMT) || | 174 | PINIT (GET_TOPOLOGY_STMT)) |
175 | PINIT (UPDATE_TRIALS_STMT) || | ||
176 | PINIT (GET_DHTKEYUID_STMT) || | ||
177 | PINIT (GET_NODEUID_STMT) || | ||
178 | PINIT (UPDATE_CONNECTIONS_STMT) || | ||
179 | PINIT (INSERT_TOPOLOGY_STMT) || | ||
180 | PINIT (EXTEND_TOPOLOGY_STMT) || | ||
181 | PINIT (UPDATE_TOPOLOGY_STMT) || | ||
182 | PINIT (GET_TRIAL_STMT) || PINIT (GET_TOPOLOGY_STMT)) | ||
183 | { | 175 | { |
184 | return GNUNET_SYSERR; | 176 | return GNUNET_SYSERR; |
185 | } | 177 | } |
@@ -325,8 +317,10 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, | |||
325 | if (ret < 0) | 317 | if (ret < 0) |
326 | return GNUNET_SYSERR; | 318 | return GNUNET_SYSERR; |
327 | 319 | ||
328 | ret = fprintf (outfile, "execute extend_topology using " | 320 | ret = |
329 | "@temp_first_node, @temp_second_node;\n"); | 321 | fprintf (outfile, |
322 | "execute extend_topology using " | ||
323 | "@temp_first_node, @temp_second_node;\n"); | ||
330 | 324 | ||
331 | if (ret >= 0) | 325 | if (ret >= 0) |
332 | return GNUNET_OK; | 326 | return GNUNET_OK; |
@@ -376,13 +370,13 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
376 | 370 | ||
377 | if (ret < 0) | 371 | if (ret < 0) |
378 | return GNUNET_SYSERR; | 372 | return GNUNET_SYSERR; |
379 | ret = fprintf (outfile, "execute insert_trial using " | 373 | ret = |
380 | "@date, @oid, @num, @topology, @t_p, @t_pr," | 374 | fprintf (outfile, |
381 | " @bl, @connect, @c_t_o," | 375 | "execute insert_trial using " |
382 | "@c_t_o_m, @puts, @gets," | 376 | "@date, @oid, @num, @topology, @t_p, @t_pr," |
383 | "@concurrent, @settle, @rounds," | 377 | " @bl, @connect, @c_t_o," "@c_t_o_m, @puts, @gets," |
384 | "@m_gets, @m_puts, @m_drops," | 378 | "@concurrent, @settle, @rounds," "@m_gets, @m_puts, @m_drops," |
385 | "@m_g_f, @m_p_f, @s_c, @s_f," "@s_k, @g_s, @message;\n"); | 379 | "@m_g_f, @m_p_f, @s_c, @s_f," "@s_k, @g_s, @message;\n"); |
386 | if (ret < 0) | 380 | if (ret < 0) |
387 | return GNUNET_SYSERR; | 381 | return GNUNET_SYSERR; |
388 | ret = fprintf (outfile, "execute select_trial;\n"); | 382 | ret = fprintf (outfile, "execute select_trial;\n"); |
@@ -404,8 +398,8 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
404 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 398 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
405 | */ | 399 | */ |
406 | int | 400 | int |
407 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, | 401 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, |
408 | const char *name, const char *section, uint64_t value) | 402 | const char *section, uint64_t value) |
409 | { | 403 | { |
410 | int ret; | 404 | int ret; |
411 | 405 | ||
@@ -466,10 +460,10 @@ int | |||
466 | add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | 460 | add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, |
467 | unsigned int route_forwards, unsigned int result_requests, | 461 | unsigned int route_forwards, unsigned int result_requests, |
468 | unsigned int client_requests, unsigned int result_forwards, | 462 | unsigned int client_requests, unsigned int result_forwards, |
469 | unsigned int gets, unsigned int puts, | 463 | unsigned int gets, unsigned int puts, unsigned int data_inserts, |
470 | unsigned int data_inserts, unsigned int find_peer_requests, | 464 | unsigned int find_peer_requests, unsigned int find_peers_started, |
471 | unsigned int find_peers_started, unsigned int gets_started, | 465 | unsigned int gets_started, unsigned int puts_started, |
472 | unsigned int puts_started, unsigned int find_peer_responses_received, | 466 | unsigned int find_peer_responses_received, |
473 | unsigned int get_responses_received, | 467 | unsigned int get_responses_received, |
474 | unsigned int find_peer_responses_sent, | 468 | unsigned int find_peer_responses_sent, |
475 | unsigned int get_responses_sent) | 469 | unsigned int get_responses_sent) |
@@ -489,25 +483,27 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | |||
489 | if (ret < 0) | 483 | if (ret < 0) |
490 | return GNUNET_SYSERR; | 484 | return GNUNET_SYSERR; |
491 | 485 | ||
492 | ret = fprintf (outfile, "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, " | 486 | ret = |
493 | "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, " | 487 | fprintf (outfile, |
494 | "@f_p_r = %u, @f_p_s = %u, @g_s = %u, @p_s = %u, " | 488 | "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, " |
495 | "@f_p_r_r = %u, @g_r_r = %u, @f_p_r_s = %u, @g_r_s = %u;\n", | 489 | "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, " |
496 | route_requests, route_forwards, result_requests, | 490 | "@f_p_r = %u, @f_p_s = %u, @g_s = %u, @p_s = %u, " |
497 | client_requests, result_forwards, gets, puts, | 491 | "@f_p_r_r = %u, @g_r_r = %u, @f_p_r_s = %u, @g_r_s = %u;\n", |
498 | data_inserts, find_peer_requests, find_peers_started, | 492 | route_requests, route_forwards, result_requests, client_requests, |
499 | gets_started, puts_started, find_peer_responses_received, | 493 | result_forwards, gets, puts, data_inserts, find_peer_requests, |
500 | get_responses_received, find_peer_responses_sent, | 494 | find_peers_started, gets_started, puts_started, |
501 | get_responses_sent); | 495 | find_peer_responses_received, get_responses_received, |
496 | find_peer_responses_sent, get_responses_sent); | ||
502 | 497 | ||
503 | if (ret < 0) | 498 | if (ret < 0) |
504 | return GNUNET_SYSERR; | 499 | return GNUNET_SYSERR; |
505 | 500 | ||
506 | ret = fprintf (outfile, "execute insert_stat using " | 501 | ret = |
507 | "@temp_trial, @temp_node, @r_r, @r_f, @res_r, @c_r, " | 502 | fprintf (outfile, |
508 | "@res_f, @gets, @puts, @d_i, " | 503 | "execute insert_stat using " |
509 | "@f_p_r, @f_p_s, @g_s, @p_s, " | 504 | "@temp_trial, @temp_node, @r_r, @r_f, @res_r, @c_r, " |
510 | "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n"); | 505 | "@res_f, @gets, @puts, @d_i, " "@f_p_r, @f_p_s, @g_s, @p_s, " |
506 | "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n"); | ||
511 | if (ret < 0) | 507 | if (ret < 0) |
512 | return GNUNET_SYSERR; | 508 | return GNUNET_SYSERR; |
513 | return GNUNET_OK; | 509 | return GNUNET_OK; |
@@ -784,9 +780,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
784 | */ | 780 | */ |
785 | int | 781 | int |
786 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | 782 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, |
787 | unsigned int type, unsigned int hops, | 783 | unsigned int type, unsigned int hops, int succeeded, |
788 | int succeeded, const struct GNUNET_PeerIdentity *node, | 784 | const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, |
789 | const GNUNET_HashCode * key, | ||
790 | const struct GNUNET_PeerIdentity *from_node, | 785 | const struct GNUNET_PeerIdentity *from_node, |
791 | const struct GNUNET_PeerIdentity *to_node) | 786 | const struct GNUNET_PeerIdentity *to_node) |
792 | { | 787 | { |
@@ -882,15 +877,15 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void *cls) | |||
882 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 877 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
883 | "MySQL (DUMP) DHT Logger: initializing\n"); | 878 | "MySQL (DUMP) DHT Logger: initializing\n"); |
884 | 879 | ||
885 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, | 880 | if (GNUNET_OK != |
886 | "MYSQLDUMP", "PATH", | 881 | GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQLDUMP", "PATH", |
887 | &outfile_path)) | 882 | &outfile_path)) |
888 | { | 883 | { |
889 | outfile_path = GNUNET_strdup (""); | 884 | outfile_path = GNUNET_strdup (""); |
890 | } | 885 | } |
891 | 886 | ||
892 | GNUNET_asprintf (&outfile_name, | 887 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump", |
893 | "%s%s-%d", outfile_path, "mysqldump", getpid ()); | 888 | getpid ()); |
894 | 889 | ||
895 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 890 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
896 | 891 | ||