aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-09-16 14:11:49 +0000
committerNathan S. Evans <evans@in.tum.de>2010-09-16 14:11:49 +0000
commit79453be1daf8fbda661a2bd1f701a9733f0ba8c8 (patch)
tree82ea5ccd3551772717165e27b2fc1cbe440bd4fa /src
parentd60d07a2d5bab8f7df54508356cdde5d95665425 (diff)
downloadgnunet-79453be1daf8fbda661a2bd1f701a9733f0ba8c8.tar.gz
gnunet-79453be1daf8fbda661a2bd1f701a9733f0ba8c8.zip
feature creep
Diffstat (limited to 'src')
-rw-r--r--src/dht/plugin_dhtlog_dummy.c14
-rw-r--r--src/dht/plugin_dhtlog_mysql.c42
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c27
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump_load.c23
4 files changed, 100 insertions, 6 deletions
diff --git a/src/dht/plugin_dhtlog_dummy.c b/src/dht/plugin_dhtlog_dummy.c
index 856d119c7..803ad92ac 100644
--- a/src/dht/plugin_dhtlog_dummy.c
+++ b/src/dht/plugin_dhtlog_dummy.c
@@ -46,6 +46,19 @@ int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info)
46} 46}
47 47
48/* 48/*
49 * Inserts the specified round into the dhttests.rounds table
50 *
51 * @param round_type the type of round that is being started
52 * @param round_count counter for the round (if applicable)
53 *
54 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
55 */
56int add_round (unsigned int round_type, unsigned int round_count)
57{
58 return GNUNET_OK;
59}
60
61/*
49 * Inserts the specified dhtkey into the dhttests.dhtkeys table, 62 * Inserts the specified dhtkey into the dhttests.dhtkeys table,
50 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid 63 * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
51 * 64 *
@@ -282,6 +295,7 @@ libgnunet_plugin_dhtlog_dummy_init (void * cls)
282 GNUNET_assert(plugin->dhtlog_api == NULL); 295 GNUNET_assert(plugin->dhtlog_api == NULL);
283 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle)); 296 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
284 plugin->dhtlog_api->add_generic_stat = &add_generic_stat; 297 plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
298 plugin->dhtlog_api->insert_round = &add_round;
285 plugin->dhtlog_api->insert_stat = &insert_stat; 299 plugin->dhtlog_api->insert_stat = &insert_stat;
286 plugin->dhtlog_api->insert_trial = &add_trial; 300 plugin->dhtlog_api->insert_trial = &add_trial;
287 plugin->dhtlog_api->insert_query = &add_query; 301 plugin->dhtlog_api->insert_query = &add_query;
diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c
index 5e47ec2f5..465a987e0 100644
--- a/src/dht/plugin_dhtlog_mysql.c
+++ b/src/dht/plugin_dhtlog_mysql.c
@@ -103,6 +103,11 @@ static struct StatementHandle *insert_route;
103 "VALUES (?, ?, ?)" 103 "VALUES (?, ?, ?)"
104static struct StatementHandle *insert_node; 104static struct StatementHandle *insert_node;
105 105
106#define INSERT_ROUNDS_STMT "INSERT INTO rounds (trialuid, round_type, round_count, starttime) "\
107 "VALUES (?, ?, ?, NOW())"
108
109static struct StatementHandle *insert_round;
110
106#define INSERT_TRIALS_STMT "INSERT INTO trials"\ 111#define INSERT_TRIALS_STMT "INSERT INTO trials"\
107 "(starttime, other_trial_identifier, numnodes, topology,"\ 112 "(starttime, other_trial_identifier, numnodes, topology,"\
108 "topology_percentage, topology_probability,"\ 113 "topology_percentage, topology_probability,"\
@@ -448,6 +453,7 @@ iopen (struct GNUNET_DHTLOG_Plugin *plugin)
448 if (PINIT (insert_query, INSERT_QUERIES_STMT) || 453 if (PINIT (insert_query, INSERT_QUERIES_STMT) ||
449 PINIT (insert_route, INSERT_ROUTES_STMT) || 454 PINIT (insert_route, INSERT_ROUTES_STMT) ||
450 PINIT (insert_trial, INSERT_TRIALS_STMT) || 455 PINIT (insert_trial, INSERT_TRIALS_STMT) ||
456 PINIT (insert_round, INSERT_ROUNDS_STMT) ||
451 PINIT (insert_stat, INSERT_STAT_STMT) || 457 PINIT (insert_stat, INSERT_STAT_STMT) ||
452 PINIT (insert_generic_stat, INSERT_GENERIC_STAT_STMT) || 458 PINIT (insert_generic_stat, INSERT_GENERIC_STAT_STMT) ||
453 PINIT (insert_node, INSERT_NODES_STMT) || 459 PINIT (insert_node, INSERT_NODES_STMT) ||
@@ -885,6 +891,31 @@ int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info)
885 return GNUNET_OK; 891 return GNUNET_OK;
886} 892}
887 893
894/*
895 * Inserts the specified round into the dhttests.rounds table
896 *
897 * @param round_type the type of round that is being started
898 * @param round_count counter for the round (if applicable)
899 *
900 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
901 */
902int add_round (unsigned int round_type, unsigned int round_count)
903{
904
905 MYSQL_STMT *stmt;
906 int ret;
907
908 stmt = mysql_stmt_init(conn);
909 ret = prepared_statement_run (insert_round,
910 NULL,
911 MYSQL_TYPE_LONGLONG, &current_trial, GNUNET_YES,
912 MYSQL_TYPE_LONG, &round_type, GNUNET_YES,
913 MYSQL_TYPE_LONG, &round_count, GNUNET_YES, -1);
914 mysql_stmt_close(stmt);
915 if (ret != GNUNET_OK)
916 return GNUNET_SYSERR;
917 return ret;
918}
888 919
889/* 920/*
890 * Inserts the specified stats into the dhttests.node_statistics table 921 * Inserts the specified stats into the dhttests.node_statistics table
@@ -1445,12 +1476,9 @@ add_topology (int num_connections)
1445 if (GNUNET_OK != 1476 if (GNUNET_OK !=
1446 (ret = prepared_statement_run (insert_topology, 1477 (ret = prepared_statement_run (insert_topology,
1447 NULL, 1478 NULL,
1448 MYSQL_TYPE_LONGLONG, 1479 MYSQL_TYPE_LONGLONG, &current_trial, GNUNET_YES,
1449 &current_trial, 1480 MYSQL_TYPE_LONG, &num_connections, GNUNET_YES,
1450 GNUNET_YES, 1481 -1)))
1451 MYSQL_TYPE_LONG,
1452 &num_connections,
1453 GNUNET_YES, -1)))
1454 { 1482 {
1455 if (ret == GNUNET_SYSERR) 1483 if (ret == GNUNET_SYSERR)
1456 { 1484 {
@@ -1542,6 +1570,7 @@ libgnunet_plugin_dhtlog_mysql_init (void * cls)
1542 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle)); 1570 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
1543 plugin->dhtlog_api->insert_trial = &add_trial; 1571 plugin->dhtlog_api->insert_trial = &add_trial;
1544 plugin->dhtlog_api->insert_stat = &add_stat; 1572 plugin->dhtlog_api->insert_stat = &add_stat;
1573 plugin->dhtlog_api->insert_round = &add_round;
1545 plugin->dhtlog_api->add_generic_stat = &add_generic_stat; 1574 plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
1546 plugin->dhtlog_api->insert_query = &add_query; 1575 plugin->dhtlog_api->insert_query = &add_query;
1547 plugin->dhtlog_api->update_trial = &update_trials; 1576 plugin->dhtlog_api->update_trial = &update_trials;
@@ -1573,6 +1602,7 @@ libgnunet_plugin_dhtlog_mysql_done (void * cls)
1573 prepared_statement_close(insert_query); 1602 prepared_statement_close(insert_query);
1574 prepared_statement_close(insert_route); 1603 prepared_statement_close(insert_route);
1575 prepared_statement_close(insert_trial); 1604 prepared_statement_close(insert_trial);
1605 prepared_statement_close(insert_round);
1576 prepared_statement_close(insert_node); 1606 prepared_statement_close(insert_node);
1577 prepared_statement_close(insert_dhtkey); 1607 prepared_statement_close(insert_dhtkey);
1578 prepared_statement_close(update_trial); 1608 prepared_statement_close(update_trial);
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index f58d6782a..2582bca41 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -63,6 +63,8 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
63#define INSERT_TOPOLOGY_STMT "prepare insert_topology from 'INSERT INTO topology (trialuid, date, connections) "\ 63#define INSERT_TOPOLOGY_STMT "prepare insert_topology from 'INSERT INTO topology (trialuid, date, connections) "\
64 "VALUES (@temp_trial, ?, ?)'" 64 "VALUES (@temp_trial, ?, ?)'"
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)'"
67
66#define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO extended_topology (topology_uid, uid_first, uid_second) "\ 68#define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO extended_topology (topology_uid, uid_first, uid_second) "\
67 "VALUES (@temp_topology, ?, ?)'" 69 "VALUES (@temp_topology, ?, ?)'"
68 70
@@ -158,6 +160,7 @@ iopen ()
158#define PINIT(a) (GNUNET_OK != (prepared_statement_create(a))) 160#define PINIT(a) (GNUNET_OK != (prepared_statement_create(a)))
159 if (PINIT (INSERT_QUERIES_STMT) || 161 if (PINIT (INSERT_QUERIES_STMT) ||
160 PINIT (INSERT_ROUTES_STMT) || 162 PINIT (INSERT_ROUTES_STMT) ||
163 PINIT (INSERT_ROUND_STMT) ||
161 PINIT (INSERT_TRIALS_STMT) || 164 PINIT (INSERT_TRIALS_STMT) ||
162 PINIT (SET_MALICIOUS_STMT) || 165 PINIT (SET_MALICIOUS_STMT) ||
163 PINIT (INSERT_GENERIC_STAT_STMT) || 166 PINIT (INSERT_GENERIC_STAT_STMT) ||
@@ -181,7 +184,30 @@ iopen ()
181 return GNUNET_OK; 184 return GNUNET_OK;
182} 185}
183 186
187/*
188 * Inserts the specified round into the dhttests.rounds table
189 *
190 * @param round_type the type of round that is being started
191 * @param round_count counter for the round (if applicable)
192 *
193 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
194 */
195int add_round (unsigned int round_type, unsigned int round_count)
196{
197 int ret;
198 if (outfile == NULL)
199 return GNUNET_SYSERR;
200
201 ret = fprintf(outfile, "set @curr_time = \"%s\", @rtype = \"%u\", @rcount = \"%u\";\n", get_sql_time(), round_type, round_count);
202
203 if (ret < 0)
204 return GNUNET_SYSERR;
205 ret = fprintf(outfile, "execute insert_round;\n");
184 206
207 if (ret >= 0)
208 return GNUNET_OK;
209 return GNUNET_SYSERR;
210}
185 211
186/* 212/*
187 * Records the current topology (number of connections, time, trial) 213 * Records the current topology (number of connections, time, trial)
@@ -813,6 +839,7 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
813 GNUNET_assert(plugin->dhtlog_api == NULL); 839 GNUNET_assert(plugin->dhtlog_api == NULL);
814 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle)); 840 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
815 plugin->dhtlog_api->insert_trial = &add_trial; 841 plugin->dhtlog_api->insert_trial = &add_trial;
842 plugin->dhtlog_api->insert_round = &add_round;
816 plugin->dhtlog_api->insert_stat = &add_stat; 843 plugin->dhtlog_api->insert_stat = &add_stat;
817 plugin->dhtlog_api->insert_query = &add_query; 844 plugin->dhtlog_api->insert_query = &add_query;
818 plugin->dhtlog_api->update_trial = &update_trials; 845 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 32733d03a..e1c1e6580 100644
--- a/src/dht/plugin_dhtlog_mysql_dump_load.c
+++ b/src/dht/plugin_dhtlog_mysql_dump_load.c
@@ -110,6 +110,28 @@ add_topology (int num_connections)
110} 110}
111 111
112/* 112/*
113 * Inserts the specified round into the dhttests.rounds table
114 *
115 * @param round_type the type of round that is being started
116 * @param round_count counter for the round (if applicable)
117 *
118 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
119 */
120int add_round (unsigned int round_type, unsigned int round_count)
121{
122 int ret;
123 if (outfile == NULL)
124 return GNUNET_SYSERR;
125
126 ret = fprintf(outfile, "insert into rounds (trialuid, round_type, round_count, starttime) values (@temp_trial, \"%u\", \"%u\", \"%s\");\n", round_type, round_count, get_sql_time());
127
128 if (ret >= 0)
129 return GNUNET_OK;
130 return GNUNET_SYSERR;
131
132}
133
134/*
113 * Records a connection between two peers in the current topology 135 * Records a connection between two peers in the current topology
114 * 136 *
115 * @param first one side of the connection 137 * @param first one side of the connection
@@ -808,6 +830,7 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls)
808 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle)); 830 plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
809 plugin->dhtlog_api->insert_trial = &add_trial; 831 plugin->dhtlog_api->insert_trial = &add_trial;
810 plugin->dhtlog_api->insert_stat = &add_stat; 832 plugin->dhtlog_api->insert_stat = &add_stat;
833 plugin->dhtlog_api->insert_round = &add_round;
811 plugin->dhtlog_api->insert_query = &add_query; 834 plugin->dhtlog_api->insert_query = &add_query;
812 plugin->dhtlog_api->update_trial = &update_trials; 835 plugin->dhtlog_api->update_trial = &update_trials;
813 plugin->dhtlog_api->insert_route = &add_route; 836 plugin->dhtlog_api->insert_route = &add_route;