aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-08-04 07:53:13 +0000
committerNathan S. Evans <evans@in.tum.de>2010-08-04 07:53:13 +0000
commit404444242b5e12ab53bfbe6604a0f962ff63a486 (patch)
treec17dfb8a2d7f127207ed2f6e23d3b30910c07e4d /src
parent4fbc8730101e3e49c09bba7acdac3a46ebd59632 (diff)
downloadgnunet-404444242b5e12ab53bfbe6604a0f962ff63a486.tar.gz
gnunet-404444242b5e12ab53bfbe6604a0f962ff63a486.zip
add actual date since we aren't inserting data NOW, call for inserting topology information
Diffstat (limited to 'src')
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c113
1 files changed, 106 insertions, 7 deletions
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index ade031c02..188807e4e 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -60,6 +60,13 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
60#define INSERT_NODES_STMT "prepare insert_node from 'INSERT INTO nodes (trialuid, nodeid) "\ 60#define INSERT_NODES_STMT "prepare insert_node from 'INSERT INTO nodes (trialuid, nodeid) "\
61 "VALUES (@temp_trial, ?)'" 61 "VALUES (@temp_trial, ?)'"
62 62
63#define INSERT_TOPOLOGY_STMT "prepare insert_topology from 'INSERT INTO topology (trialuid, date, connections) "\
64 "VALUES (@temp_trial, ?, ?)'"
65
66#define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO extended_topology (topology_uid, uid_first, uid_second) "\
67 "VALUES (@temp_topology, ?, ?)'"
68
69
63#define INSERT_TRIALS_STMT "prepare insert_trial from 'INSERT INTO trials"\ 70#define INSERT_TRIALS_STMT "prepare insert_trial from 'INSERT INTO trials"\
64 "(starttime, numnodes, topology,"\ 71 "(starttime, numnodes, topology,"\
65 "topology_percentage, topology_probability,"\ 72 "topology_percentage, topology_probability,"\
@@ -67,26 +74,49 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
67 "connect_topology_option_modifier, puts, gets, "\ 74 "connect_topology_option_modifier, puts, gets, "\
68 "concurrent, settle_time, num_rounds, malicious_getters,"\ 75 "concurrent, settle_time, num_rounds, malicious_getters,"\
69 "malicious_putters, malicious_droppers, message) "\ 76 "malicious_putters, malicious_droppers, message) "\
70 "VALUES (NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'" 77 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'"
71 78
72#define INSERT_DHTKEY_STMT "prepare insert_dhtkey from 'INSERT ignore INTO dhtkeys (dhtkey, trialuid) "\ 79#define INSERT_DHTKEY_STMT "prepare insert_dhtkey from 'INSERT ignore INTO dhtkeys (dhtkey, trialuid) "\
73 "VALUES (?, @temp_trial)'" 80 "VALUES (?, @temp_trial)'"
74 81
75#define UPDATE_TRIALS_STMT "prepare update_trial from 'UPDATE trials set endtime=NOW(), total_messages_dropped = ?, total_bytes_dropped = ?, unknownPeers = ? where trialuid = @temp_trial'" 82#define UPDATE_TRIALS_STMT "prepare update_trial from 'UPDATE trials set endtime= ?, total_messages_dropped = ?, total_bytes_dropped = ?, unknownPeers = ? where trialuid = @temp_trial'"
76 83
77#define UPDATE_CONNECTIONS_STMT "prepare update_conn from 'UPDATE trials set totalConnections = ? where trialuid = @temp_trial'" 84#define UPDATE_CONNECTIONS_STMT "prepare update_conn from 'UPDATE trials set totalConnections = ? where trialuid = @temp_trial'"
78 85
79#define GET_TRIAL_STMT "prepare select_trial from 'SELECT MAX( trialuid ) FROM trials into @temp_trial'" 86#define GET_TRIAL_STMT "prepare select_trial from 'SELECT MAX( trialuid ) FROM trials into @temp_trial'"
80 87
88#define GET_TOPOLOGY_STMT "prepare select_topology from 'SELECT MAX( topology_uid ) FROM topology into @temp_topology'"
89
81#define GET_DHTKEYUID_STMT "prepare get_dhtkeyuid from 'SELECT dhtkeyuid FROM dhtkeys where dhtkey = ? and trialuid = @temp_trial'" 90#define GET_DHTKEYUID_STMT "prepare get_dhtkeyuid from 'SELECT dhtkeyuid FROM dhtkeys where dhtkey = ? and trialuid = @temp_trial'"
82 91
83#define GET_NODEUID_STMT "prepare get_nodeuid from 'SELECT nodeuid FROM nodes where trialuid = @temp_trial and nodeid = ?'" 92#define GET_NODEUID_STMT "prepare get_nodeuid from 'SELECT nodeuid FROM nodes where trialuid = @temp_trial and nodeid = ?'"
84 93
94#define DATE_STR_SIZE 50
95
85/** 96/**
86 * File to dump all sql statements to. 97 * File to dump all sql statements to.
87 */ 98 */
88FILE *outfile; 99FILE *outfile;
89 100
101
102static char *
103get_sql_time()
104{
105 static char date[DATE_STR_SIZE];
106 time_t timetmp;
107 struct tm *tmptr;
108
109 time (&timetmp);
110 memset (date, 0, DATE_STR_SIZE);
111 tmptr = localtime (&timetmp);
112 if (NULL != tmptr)
113 strftime (date, DATE_STR_SIZE, "%Y-%m-%d %H:%M:%S", tmptr);
114 else
115 strcpy (date, "");
116
117 return date;
118}
119
90/** 120/**
91 * Create a prepared statement. 121 * Create a prepared statement.
92 * 122 *
@@ -127,6 +157,75 @@ iopen ()
127} 157}
128 158
129 159
160
161/*
162 * Records the current topology (number of connections, time, trial)
163 *
164 * @param num_connections how many connections are in the topology
165 *
166 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
167 */
168int
169add_topology (int num_connections)
170{
171 int ret;
172 if (outfile == NULL)
173 return GNUNET_SYSERR;
174
175 ret = fprintf(outfile, "set @date = \"%s\", @num = %d;\n", get_sql_time(), num_connections);
176
177 if (ret < 0)
178 return GNUNET_SYSERR;
179 ret = fprintf(outfile, "execute insert_topology using "
180 "@date, @num;\n");
181
182 ret = fprintf(outfile, "execute select_topology;\n");
183
184 if (ret >= 0)
185 return GNUNET_OK;
186 return GNUNET_SYSERR;
187}
188
189/*
190 * Records a connection between two peers in the current topology
191 *
192 * @param first one side of the connection
193 * @param second other side of the connection
194 *
195 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
196 */
197int
198add_extended_topology (struct GNUNET_PeerIdentity *first, struct GNUNET_PeerIdentity *second)
199{
200 int ret;
201 if (outfile == NULL)
202 return GNUNET_SYSERR;
203
204 if (first != NULL)
205 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_first_node;\n", GNUNET_h2s_full(&first->hashPubKey));
206 else
207 ret = fprintf(outfile, "set @temp_first_node = 0;\n");
208
209 if (ret < 0)
210 return GNUNET_SYSERR;
211
212 if (second != NULL)
213 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_second_node;\n", GNUNET_h2s_full(&second->hashPubKey));
214 else
215 ret = fprintf(outfile, "set @temp_second_node = 0;\n");
216
217 if (ret < 0)
218 return GNUNET_SYSERR;
219
220 ret = fprintf(outfile, "execute extend_topology using "
221 "@temp_first_node, @temp_second_node;\n");
222
223 if (ret >= 0)
224 return GNUNET_OK;
225 return GNUNET_SYSERR;
226}
227
228
130/* 229/*
131 * Inserts the specified trial into the dhttests.trials table 230 * Inserts the specified trial into the dhttests.trials table
132 * 231 *
@@ -166,12 +265,12 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
166 if (outfile == NULL) 265 if (outfile == NULL)
167 return GNUNET_SYSERR; 266 return GNUNET_SYSERR;
168 267
169 ret = fprintf(outfile, "set @num = %d, @topology = %d, @bl = %d, " 268 ret = fprintf(outfile, "set @date = \"%s\", @num = %d, @topology = %d, @bl = %d, "
170 "@connect = %d, @c_t_o = %d, @c_t_o_m = %f, @t_p = %f, " 269 "@connect = %d, @c_t_o = %d, @c_t_o_m = %f, @t_p = %f, "
171 "@t_pr = %f, @puts = %d, @gets = %d, " 270 "@t_pr = %f, @puts = %d, @gets = %d, "
172 "@concurrent = %d, @settle = %d, @rounds = %d, " 271 "@concurrent = %d, @settle = %d, @rounds = %d, "
173 "@m_gets = %d, @m_puts = %d, @m_drops = %d, " 272 "@m_gets = %d, @m_puts = %d, @m_drops = %d, "
174 "@message = \"%s\";\n", num_nodes, topology, 273 "@message = \"%s\";\n", get_sql_time(), num_nodes, topology,
175 blacklist_topology, connect_topology, 274 blacklist_topology, connect_topology,
176 connect_topology_option, connect_topology_option_modifier, 275 connect_topology_option, connect_topology_option_modifier,
177 topology_percentage, topology_probability, 276 topology_percentage, topology_probability,
@@ -182,7 +281,7 @@ add_trial (unsigned long long *trialuid, int num_nodes, int topology,
182 if (ret < 0) 281 if (ret < 0)
183 return GNUNET_SYSERR; 282 return GNUNET_SYSERR;
184 ret = fprintf(outfile, "execute insert_trial using " 283 ret = fprintf(outfile, "execute insert_trial using "
185 "@num, @topology, @t_p, @t_pr," 284 "@date, @num, @topology, @t_p, @t_pr,"
186 " @bl, @connect, @c_t_o," 285 " @bl, @connect, @c_t_o,"
187 "@c_t_o_m, @puts, @gets," 286 "@c_t_o_m, @puts, @gets,"
188 "@concurrent, @settle, @rounds," 287 "@concurrent, @settle, @rounds,"
@@ -292,12 +391,12 @@ update_trials (unsigned long long trialuid,
292 if (outfile == NULL) 391 if (outfile == NULL)
293 return GNUNET_SYSERR; 392 return GNUNET_SYSERR;
294 393
295 ret = fprintf(outfile, "set @m_dropped = %llu, @b_dropped = %llu, @unknown = %llu;\n", totalMessagesDropped, totalBytesDropped, unknownPeers); 394 ret = fprintf(outfile, "set @date = \"%s\", @m_dropped = %llu, @b_dropped = %llu, @unknown = %llu;\n", get_sql_time(), totalMessagesDropped, totalBytesDropped, unknownPeers);
296 395
297 if (ret < 0) 396 if (ret < 0)
298 return GNUNET_SYSERR; 397 return GNUNET_SYSERR;
299 398
300 ret = fprintf(outfile, "execute update_trial using @m_dropped, @b_dropped, @unknown;\n"); 399 ret = fprintf(outfile, "execute update_trial using @date, @m_dropped, @b_dropped, @unknown;\n");
301 400
302 if (ret >= 0) 401 if (ret >= 0)
303 return GNUNET_OK; 402 return GNUNET_OK;