aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-02-08 14:46:17 +0000
committerNathan S. Evans <evans@in.tum.de>2011-02-08 14:46:17 +0000
commit2669904d8e9280390a3cf87acc574e7caef4dc19 (patch)
tree85026797c11d2c6582d058a05ae0c660987a42ea /src/dht
parentb9cb7a612968c7b7347b0bc598e46435ef9600a5 (diff)
downloadgnunet-2669904d8e9280390a3cf87acc574e7caef4dc19.tar.gz
gnunet-2669904d8e9280390a3cf87acc574e7caef4dc19.zip
enable very minimal dht logging
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/dhtlog.h14
-rw-r--r--src/dht/gnunet-dht-driver.c32
-rw-r--r--src/dht/plugin_dhtlog_dummy.c18
-rw-r--r--src/dht/plugin_dhtlog_mysql.c40
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c36
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump_load.c27
-rw-r--r--src/dht/test_dhtlog.c2
7 files changed, 156 insertions, 13 deletions
diff --git a/src/dht/dhtlog.h b/src/dht/dhtlog.h
index d53167a5c..c86d98ee2 100644
--- a/src/dht/dhtlog.h
+++ b/src/dht/dhtlog.h
@@ -278,6 +278,20 @@ struct GNUNET_DHTLOG_Handle
278 int (*insert_round) (unsigned int round_type, unsigned int round_count); 278 int (*insert_round) (unsigned int round_type, unsigned int round_count);
279 279
280 /* 280 /*
281 * Inserts the specified round results into the
282 * dhttests.processed_round_details table
283 *
284 * @param round_type the type of round that is being started
285 * @param round_count counter for the round (if applicable)
286 * @param num_messages the total number of messages initiated
287 * @param num_messages_succeeded the number of messages that succeeded
288 *
289 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
290 */
291 int (*insert_round_details) (unsigned int round_type, unsigned int round_count,
292 unsigned int num_messages, unsigned int num_messages_succeeded);
293
294 /*
281 * Update dhttests.trials table with total connections information 295 * Update dhttests.trials table with total connections information
282 * 296 *
283 * @param totalConnections the number of connections 297 * @param totalConnections the number of connections
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c
index 772b96d6e..16e3aa93d 100644
--- a/src/dht/gnunet-dht-driver.c
+++ b/src/dht/gnunet-dht-driver.c
@@ -42,7 +42,7 @@
42#define DEFAULT_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5) 42#define DEFAULT_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
43 43
44/* Timeout for waiting for (individual) replies to get requests */ 44/* Timeout for waiting for (individual) replies to get requests */
45#define DEFAULT_GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) 45#define DEFAULT_GET_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
46 46
47#define DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90) 47#define DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90)
48 48
@@ -292,8 +292,6 @@ struct FindPeerContext
292 /** 292 /**
293 * How long to send find peer requests, once the settle time 293 * How long to send find peer requests, once the settle time
294 * is over don't send any more out! 294 * is over don't send any more out!
295 *
296 * TODO: Add option for settle time and find peer sending time?
297 */ 295 */
298 struct GNUNET_TIME_Absolute endtime; 296 struct GNUNET_TIME_Absolute endtime;
299 297
@@ -701,6 +699,12 @@ static unsigned int previous_connections;
701 */ 699 */
702static unsigned int failed_connections; 700static unsigned int failed_connections;
703 701
702/**
703 * If GNUNET_YES, only log PUT/GET round data to mysql, otherwise
704 * log everything (including each dht service logging).
705 */
706static unsigned int dhtlog_minimal;
707
704/* Task handle to use to schedule shutdown if something goes wrong */ 708/* Task handle to use to schedule shutdown if something goes wrong */
705GNUNET_SCHEDULER_TaskIdentifier die_task; 709GNUNET_SCHEDULER_TaskIdentifier die_task;
706 710
@@ -920,15 +924,13 @@ log_topology_cb (void *cls,
920 struct TopologyIteratorContext *topo_ctx = cls; 924 struct TopologyIteratorContext *topo_ctx = cls;
921 if ((first != NULL) && (second != NULL)) 925 if ((first != NULL) && (second != NULL))
922 { 926 {
923 /* GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "According to CORE, peer %s is connected to %s\n", GNUNET_i2s(first), GNUNET_h2s(&second->hashPubKey));*/
924 if ((topo_ctx->peers_seen != NULL) && (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(topo_ctx->peers_seen, &first->hashPubKey))) 927 if ((topo_ctx->peers_seen != NULL) && (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(topo_ctx->peers_seen, &first->hashPubKey)))
925 { 928 {
926 GNUNET_CONTAINER_multihashmap_put(topo_ctx->peers_seen, &first->hashPubKey, NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 929 GNUNET_CONTAINER_multihashmap_put(topo_ctx->peers_seen, &first->hashPubKey, NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
927 topo_ctx->total_peers++; 930 topo_ctx->total_peers++;
928 } 931 }
929 topo_ctx->total_connections++; 932 topo_ctx->total_connections++;
930 if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(config, "dht_testing", "mysql_logging")) || 933 if ((GNUNET_NO == dhtlog_minimal) && (dhtlog_handle != NULL))
931 (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(config, "dht_testing", "mysql_logging_extended")))
932 dhtlog_handle->insert_extended_topology(first, second); 934 dhtlog_handle->insert_extended_topology(first, second);
933 } 935 }
934 else 936 else
@@ -1571,7 +1573,6 @@ static void churn_complete (void *cls, const char *emsg)
1571 } 1573 }
1572 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Added %d peers to heap, total size %d\n", count_added, GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap)); 1574 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Added %d peers to heap, total size %d\n", count_added, GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap));
1573 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context); 1575 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &schedule_churn_get_topology, find_peer_context);
1574 //GNUNET_TESTING_get_topology (pg, &count_peers_churn_cb, find_peer_context);
1575 } 1576 }
1576 else 1577 else
1577 { 1578 {
@@ -1589,6 +1590,7 @@ static void churn_complete (void *cls, const char *emsg)
1589 die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout, 1590 die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout,
1590 &end_badly, "from do gets (churn_complete)"); 1591 &end_badly, "from do gets (churn_complete)");
1591 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx); 1592 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &capture_current_topology, topo_ctx);
1593 dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished);
1592 } 1594 }
1593 else 1595 else
1594 { 1596 {
@@ -1596,8 +1598,6 @@ static void churn_complete (void *cls, const char *emsg)
1596 calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT); 1598 calc_timeout = GNUNET_TIME_relative_add(calc_timeout, DEFAULT_PEER_DISCONNECT_TIMEOUT);
1597 die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout, 1599 die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout,
1598 &end_badly, "from do gets (churn_complete)"); 1600 &end_badly, "from do gets (churn_complete)");
1599 if (dhtlog_handle != NULL)
1600 dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished);
1601 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, all_gets); 1601 GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, all_gets);
1602 } 1602 }
1603 } 1603 }
@@ -1692,6 +1692,8 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1692 if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) 1692 if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0))
1693 { 1693 {
1694 fprintf(stderr, "Canceling die task (get_stop_finished) %llu gets completed, %llu gets failed\n", gets_completed, gets_failed); 1694 fprintf(stderr, "Canceling die task (get_stop_finished) %llu gets completed, %llu gets failed\n", gets_completed, gets_failed);
1695 if ((GNUNET_YES == dhtlog_minimal) && (NULL != dhtlog_handle))
1696 dhtlog_handle->insert_round_details(DHT_ROUND_GET, rounds_finished, num_gets, gets_completed);
1695 GNUNET_SCHEDULER_cancel(die_task); 1697 GNUNET_SCHEDULER_cancel(die_task);
1696 reset_meter(put_meter); 1698 reset_meter(put_meter);
1697 reset_meter(get_meter); 1699 reset_meter(get_meter);
@@ -1703,7 +1705,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1703 */ 1705 */
1704 if (rounds_finished == total_rounds - 1) /* Everything is finished, end testing */ 1706 if (rounds_finished == total_rounds - 1) /* Everything is finished, end testing */
1705 { 1707 {
1706 if (dhtlog_handle != NULL) 1708 if ((dhtlog_handle != NULL) && (GNUNET_NO == dhtlog_minimal))
1707 { 1709 {
1708 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); 1710 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext));
1709 topo_ctx->cont = &log_dht_statistics; 1711 topo_ctx->cont = &log_dht_statistics;
@@ -1907,7 +1909,7 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
1907 { 1909 {
1908 GNUNET_assert(outstanding_puts == 0); 1910 GNUNET_assert(outstanding_puts == 0);
1909 GNUNET_SCHEDULER_cancel (die_task); 1911 GNUNET_SCHEDULER_cancel (die_task);
1910 if (dhtlog_handle != NULL) 1912 if ((dhtlog_handle != NULL) && (GNUNET_NO == dhtlog_minimal))
1911 { 1913 {
1912 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); 1914 topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext));
1913 topo_ctx->cont = &do_get; 1915 topo_ctx->cont = &do_get;
@@ -2265,7 +2267,7 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t
2265 struct TopologyIteratorContext *topo_ctx; 2267 struct TopologyIteratorContext *topo_ctx;
2266 struct FindPeerContext *find_peer_context; 2268 struct FindPeerContext *find_peer_context;
2267 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "In continue_puts_and_gets\n"); 2269 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "In continue_puts_and_gets\n");
2268 if (dhtlog_handle != NULL) 2270 if ((dhtlog_handle != NULL) && (GNUNET_NO == dhtlog_minimal))
2269 { 2271 {
2270 if (settle_time >= 180 * 2) 2272 if (settle_time >= 180 * 2)
2271 max = (settle_time / 180) - 2; 2273 max = (settle_time / 180) - 2;
@@ -2818,8 +2820,12 @@ run (void *cls,
2818 * Get DHT specific testing options. 2820 * Get DHT specific testing options.
2819 */ 2821 */
2820 if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", "mysql_logging")) || 2822 if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", "mysql_logging")) ||
2821 (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", "mysql_logging_extended"))) 2823 (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", "mysql_logging_extended")) ||
2824 (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", "mysql_logging_minimal")))
2822 { 2825 {
2826 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", "mysql_logging_minimal"))
2827 dhtlog_minimal = GNUNET_YES;
2828
2823 dhtlog_handle = GNUNET_DHTLOG_connect(cfg); 2829 dhtlog_handle = GNUNET_DHTLOG_connect(cfg);
2824 if (dhtlog_handle == NULL) 2830 if (dhtlog_handle == NULL)
2825 { 2831 {
diff --git a/src/dht/plugin_dhtlog_dummy.c b/src/dht/plugin_dhtlog_dummy.c
index 96a29af89..0a7091030 100644
--- a/src/dht/plugin_dhtlog_dummy.c
+++ b/src/dht/plugin_dhtlog_dummy.c
@@ -58,6 +58,23 @@ int add_round (unsigned int round_type, unsigned int round_count)
58} 58}
59 59
60/* 60/*
61 * Inserts the specified round results into the
62 * dhttests.processed_round_details table
63 *
64 * @param round_type the type of round that is being started
65 * @param round_count counter for the round (if applicable)
66 * @param num_messages the total number of messages initiated
67 * @param num_messages_succeeded the number of messages that succeeded
68 *
69 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
70 */
71int add_round_details (unsigned int round_type, unsigned int round_count,
72 unsigned int num_messages, unsigned int num_messages_succeded)
73{
74 return GNUNET_OK;
75}
76
77/*
61 * Inserts the specified dhtkey into the dhttests.dhtkeys table, 78 * Inserts the specified dhtkey into the dhttests.dhtkeys table,
62 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid 79 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
63 * 80 *
@@ -292,6 +309,7 @@ libgnunet_plugin_dhtlog_dummy_init (void * cls)
292 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle)); 309 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
293 plugin->dhtlog_api->add_generic_stat = &add_generic_stat; 310 plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
294 plugin->dhtlog_api->insert_round = &add_round; 311 plugin->dhtlog_api->insert_round = &add_round;
312 plugin->dhtlog_api->insert_round_details = &add_round_details;
295 plugin->dhtlog_api->insert_stat = &insert_stat; 313 plugin->dhtlog_api->insert_stat = &insert_stat;
296 plugin->dhtlog_api->insert_trial = &add_trial; 314 plugin->dhtlog_api->insert_trial = &add_trial;
297 plugin->dhtlog_api->insert_query = &add_query; 315 plugin->dhtlog_api->insert_query = &add_query;
diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c
index 5510163b0..0cce99d6d 100644
--- a/src/dht/plugin_dhtlog_mysql.c
+++ b/src/dht/plugin_dhtlog_mysql.c
@@ -108,6 +108,11 @@ static struct StatementHandle *insert_node;
108 108
109static struct StatementHandle *insert_round; 109static struct StatementHandle *insert_round;
110 110
111#define INSERT_ROUND_DETAILS_STMT "INSERT INTO rounds (trialuid, round_type, round_count, starttime, endtime, num_messages, num_messages_succeeded) "\
112 "VALUES (?, ?, ?, NOW(), NOW(), ?, ?)"
113
114static struct StatementHandle *insert_round_details;
115
111#define INSERT_TRIALS_STMT "INSERT INTO trials"\ 116#define INSERT_TRIALS_STMT "INSERT INTO trials"\
112 "(starttime, other_trial_identifier, numnodes, topology,"\ 117 "(starttime, other_trial_identifier, numnodes, topology,"\
113 "topology_percentage, topology_probability,"\ 118 "topology_percentage, topology_probability,"\
@@ -454,6 +459,7 @@ iopen (struct GNUNET_DHTLOG_Plugin *plugin)
454 PINIT (insert_route, INSERT_ROUTES_STMT) || 459 PINIT (insert_route, INSERT_ROUTES_STMT) ||
455 PINIT (insert_trial, INSERT_TRIALS_STMT) || 460 PINIT (insert_trial, INSERT_TRIALS_STMT) ||
456 PINIT (insert_round, INSERT_ROUNDS_STMT) || 461 PINIT (insert_round, INSERT_ROUNDS_STMT) ||
462 PINIT (insert_round, INSERT_ROUND_DETAILS_STMT) ||
457 PINIT (insert_stat, INSERT_STAT_STMT) || 463 PINIT (insert_stat, INSERT_STAT_STMT) ||
458 PINIT (insert_generic_stat, INSERT_GENERIC_STAT_STMT) || 464 PINIT (insert_generic_stat, INSERT_GENERIC_STAT_STMT) ||
459 PINIT (insert_node, INSERT_NODES_STMT) || 465 PINIT (insert_node, INSERT_NODES_STMT) ||
@@ -918,6 +924,38 @@ int add_round (unsigned int round_type, unsigned int round_count)
918} 924}
919 925
920/* 926/*
927 * Inserts the specified round results into the
928 * dhttests.processed_round_details table
929 *
930 * @param round_type the type of round that is being started
931 * @param round_count counter for the round (if applicable)
932 * @param num_messages the total number of messages initiated
933 * @param num_messages_succeeded the number of messages that succeeded
934 *
935 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
936 */
937int add_round_details (unsigned int round_type, unsigned int round_count,
938 unsigned int num_messages, unsigned int num_messages_succeeded)
939{
940 MYSQL_STMT *stmt;
941 int ret;
942
943 stmt = mysql_stmt_init(conn);
944 ret = prepared_statement_run (insert_round_details,
945 NULL,
946 MYSQL_TYPE_LONGLONG, &current_trial, GNUNET_YES,
947 MYSQL_TYPE_LONG, &round_type, GNUNET_YES,
948 MYSQL_TYPE_LONG, &round_count, GNUNET_YES,
949 MYSQL_TYPE_LONG, &num_messages, GNUNET_YES,
950 MYSQL_TYPE_LONG, &num_messages_succeeded, GNUNET_YES,
951 -1);
952 mysql_stmt_close(stmt);
953 if (ret != GNUNET_OK)
954 return GNUNET_SYSERR;
955 return ret;
956}
957
958/*
921 * Inserts the specified stats into the dhttests.node_statistics table 959 * Inserts the specified stats into the dhttests.node_statistics table
922 * 960 *
923 * @param peer the peer inserting the statistic 961 * @param peer the peer inserting the statistic
@@ -1561,6 +1599,7 @@ libgnunet_plugin_dhtlog_mysql_init (void * cls)
1561 plugin->dhtlog_api->insert_trial = &add_trial; 1599 plugin->dhtlog_api->insert_trial = &add_trial;
1562 plugin->dhtlog_api->insert_stat = &add_stat; 1600 plugin->dhtlog_api->insert_stat = &add_stat;
1563 plugin->dhtlog_api->insert_round = &add_round; 1601 plugin->dhtlog_api->insert_round = &add_round;
1602 plugin->dhtlog_api->insert_round_details = &add_round_details;
1564 plugin->dhtlog_api->add_generic_stat = &add_generic_stat; 1603 plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
1565 plugin->dhtlog_api->insert_query = &add_query; 1604 plugin->dhtlog_api->insert_query = &add_query;
1566 plugin->dhtlog_api->update_trial = &update_trials; 1605 plugin->dhtlog_api->update_trial = &update_trials;
@@ -1593,6 +1632,7 @@ libgnunet_plugin_dhtlog_mysql_done (void * cls)
1593 prepared_statement_close(insert_route); 1632 prepared_statement_close(insert_route);
1594 prepared_statement_close(insert_trial); 1633 prepared_statement_close(insert_trial);
1595 prepared_statement_close(insert_round); 1634 prepared_statement_close(insert_round);
1635 prepared_statement_close(insert_round_details);
1596 prepared_statement_close(insert_node); 1636 prepared_statement_close(insert_node);
1597 prepared_statement_close(insert_dhtkey); 1637 prepared_statement_close(insert_dhtkey);
1598 prepared_statement_close(update_trial); 1638 prepared_statement_close(update_trial);
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index 1e549d115..3033be535 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -65,6 +65,10 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
65 65
66#define INSERT_ROUND_STMT "prepare insert_round from 'INSERT INTO rounds (trialuid, round_type, round_count, starttime) VALUES (@temp_trial, @rtype, @rcount, @curr_time)'" 66#define INSERT_ROUND_STMT "prepare insert_round from 'INSERT INTO rounds (trialuid, round_type, round_count, starttime) VALUES (@temp_trial, @rtype, @rcount, @curr_time)'"
67 67
68#define INSERT_ROUND_DETAILS_STMT "prepare insert_round_details from 'INSERT INTO processed_trial_rounds "\
69 "(trialuid, round_type, round_count, starttime, endtime, num_messages, num_messages_succeeded)"\
70 "VALUES (@temp_trial, @rtype, @rcount, @curr_time, @curr_time, @totalmsgs, @msgssucceeded)'"
71
68#define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO extended_topology (topology_uid, uid_first, uid_second) "\ 72#define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO extended_topology (topology_uid, uid_first, uid_second) "\
69 "VALUES (@temp_topology, ?, ?)'" 73 "VALUES (@temp_topology, ?, ?)'"
70 74
@@ -161,6 +165,7 @@ iopen ()
161 if (PINIT (INSERT_QUERIES_STMT) || 165 if (PINIT (INSERT_QUERIES_STMT) ||
162 PINIT (INSERT_ROUTES_STMT) || 166 PINIT (INSERT_ROUTES_STMT) ||
163 PINIT (INSERT_ROUND_STMT) || 167 PINIT (INSERT_ROUND_STMT) ||
168 PINIT (INSERT_ROUND_DETAILS_STMT) ||
164 PINIT (INSERT_TRIALS_STMT) || 169 PINIT (INSERT_TRIALS_STMT) ||
165 PINIT (SET_MALICIOUS_STMT) || 170 PINIT (SET_MALICIOUS_STMT) ||
166 PINIT (INSERT_GENERIC_STAT_STMT) || 171 PINIT (INSERT_GENERIC_STAT_STMT) ||
@@ -210,6 +215,36 @@ int add_round (unsigned int round_type, unsigned int round_count)
210} 215}
211 216
212/* 217/*
218 * Inserts the specified round results into the
219 * dhttests.processed_round_details table
220 *
221 * @param round_type the type of round that is being started
222 * @param round_count counter for the round (if applicable)
223 * @param num_messages the total number of messages initiated
224 * @param num_messages_succeeded the number of messages that succeeded
225 *
226 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
227 */
228int add_round_details (unsigned int round_type, unsigned int round_count,
229 unsigned int num_messages, unsigned int num_messages_succeeded)
230{
231 int ret;
232 if (outfile == NULL)
233 return GNUNET_SYSERR;
234
235 ret = fprintf(outfile, "set @curr_time = \"%s\", @rtype = \"%u\", @rcount = \"%u\", @totalmsgs = \"%u\", @msgssucceeded = \"%u\";\n",
236 get_sql_time(), round_type, round_count, num_messages, num_messages_succeeded);
237
238 if (ret < 0)
239 return GNUNET_SYSERR;
240 ret = fprintf(outfile, "execute insert_round_details;\n");
241
242 if (ret >= 0)
243 return GNUNET_OK;
244 return GNUNET_SYSERR;
245}
246
247/*
213 * Records the current topology (number of connections, time, trial) 248 * Records the current topology (number of connections, time, trial)
214 * 249 *
215 * @param num_connections how many connections are in the topology 250 * @param num_connections how many connections are in the topology
@@ -821,6 +856,7 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
821 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle)); 856 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
822 plugin->dhtlog_api->insert_trial = &add_trial; 857 plugin->dhtlog_api->insert_trial = &add_trial;
823 plugin->dhtlog_api->insert_round = &add_round; 858 plugin->dhtlog_api->insert_round = &add_round;
859 plugin->dhtlog_api->insert_round_details = &add_round_details;
824 plugin->dhtlog_api->insert_stat = &add_stat; 860 plugin->dhtlog_api->insert_stat = &add_stat;
825 plugin->dhtlog_api->insert_query = &add_query; 861 plugin->dhtlog_api->insert_query = &add_query;
826 plugin->dhtlog_api->update_trial = &update_trials; 862 plugin->dhtlog_api->update_trial = &update_trials;
diff --git a/src/dht/plugin_dhtlog_mysql_dump_load.c b/src/dht/plugin_dhtlog_mysql_dump_load.c
index 6fa6ab2c7..956af6bdd 100644
--- a/src/dht/plugin_dhtlog_mysql_dump_load.c
+++ b/src/dht/plugin_dhtlog_mysql_dump_load.c
@@ -132,6 +132,32 @@ int add_round (unsigned int round_type, unsigned int round_count)
132} 132}
133 133
134/* 134/*
135 * Inserts the specified round results into the
136 * dhttests.processed_round_details table
137 *
138 * @param round_type the type of round that is being started
139 * @param round_count counter for the round (if applicable)
140 * @param num_messages the total number of messages initiated
141 * @param num_messages_succeeded the number of messages that succeeded
142 *
143 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
144 */
145int add_round_details (unsigned int round_type, unsigned int round_count,
146 unsigned int num_messages, unsigned int num_messages_succeeded)
147{
148 int ret;
149 if (outfile == NULL)
150 return GNUNET_SYSERR;
151
152 ret = fprintf(outfile, "insert into processed_trial_rounds (trialuid, round_type, round_count, starttime, endtime, num_messages, num_messages_succeeded) values (@temp_trial, \"%u\", \"%u\", \"%s\", \"%s\", \"%u\", \"%u\");\n",
153 round_type, round_count, get_sql_time(), get_sql_time(), num_messages, num_messages_succeeded);
154
155 if (ret >= 0)
156 return GNUNET_OK;
157 return GNUNET_SYSERR;
158}
159
160/*
135 * Records a connection between two peers in the current topology 161 * Records a connection between two peers in the current topology
136 * 162 *
137 * @param first one side of the connection 163 * @param first one side of the connection
@@ -824,6 +850,7 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls)
824 plugin->dhtlog_api->insert_trial = &add_trial; 850 plugin->dhtlog_api->insert_trial = &add_trial;
825 plugin->dhtlog_api->insert_stat = &add_stat; 851 plugin->dhtlog_api->insert_stat = &add_stat;
826 plugin->dhtlog_api->insert_round = &add_round; 852 plugin->dhtlog_api->insert_round = &add_round;
853 plugin->dhtlog_api->insert_round_details = &add_round_details;
827 plugin->dhtlog_api->insert_query = &add_query; 854 plugin->dhtlog_api->insert_query = &add_query;
828 plugin->dhtlog_api->update_trial = &update_trials; 855 plugin->dhtlog_api->update_trial = &update_trials;
829 plugin->dhtlog_api->insert_route = &add_route; 856 plugin->dhtlog_api->insert_route = &add_route;
diff --git a/src/dht/test_dhtlog.c b/src/dht/test_dhtlog.c
index 955781ef2..5c6d5c578 100644
--- a/src/dht/test_dhtlog.c
+++ b/src/dht/test_dhtlog.c
@@ -180,6 +180,8 @@ test (struct GNUNET_DHTLOG_Handle * api)
180#endif 180#endif
181 ret = api->insert_round(401, 507); 181 ret = api->insert_round(401, 507);
182 CHECK(ret); 182 CHECK(ret);
183 ret = api->insert_round_details(402, 507, 1123, 985);
184 CHECK(ret);
183#if VERBOSE 185#if VERBOSE
184 fprintf(stderr, "Insert round succeeded!\n"); 186 fprintf(stderr, "Insert round succeeded!\n");
185#endif 187#endif