aboutsummaryrefslogtreecommitdiff
path: root/src/dht/plugin_dhtlog_mysql_dump.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-08-19 15:57:37 +0000
committerNathan S. Evans <evans@in.tum.de>2010-08-19 15:57:37 +0000
commit2efbca20329aa7ae70dc8a5f1b36b254159a3da3 (patch)
tree36a35b63c58892e993aa3c37b17b0fcddd65581e /src/dht/plugin_dhtlog_mysql_dump.c
parent3c9f02fc5fa7383d26162841eab530e012c14e8a (diff)
downloadgnunet-2efbca20329aa7ae70dc8a5f1b36b254159a3da3.tar.gz
gnunet-2efbca20329aa7ae70dc8a5f1b36b254159a3da3.zip
dht changes i don't want to have only on my machine
Diffstat (limited to 'src/dht/plugin_dhtlog_mysql_dump.c')
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c79
1 files changed, 78 insertions, 1 deletions
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index 5c13a3a85..f98360e06 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -57,7 +57,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
57#define INSERT_ROUTES_STMT "prepare insert_route from 'INSERT INTO routes (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid, from_node, to_node) "\ 57#define INSERT_ROUTES_STMT "prepare insert_route from 'INSERT INTO routes (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid, from_node, to_node) "\
58 "VALUES (@temp_trial, ?, ?, ?, ?, ?, ?, ?, ?)'" 58 "VALUES (@temp_trial, ?, ?, ?, ?, ?, ?, ?, ?)'"
59 59
60#define INSERT_NODES_STMT "prepare insert_node from 'INSERT INTO nodes (trialuid, nodeid) "\ 60#define INSERT_NODES_STMT "prepare insert_node from 'INSERT ignore 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) "\ 63#define INSERT_TOPOLOGY_STMT "prepare insert_topology from 'INSERT INTO topology (trialuid, date, connections) "\
@@ -68,6 +68,8 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
68 68
69#define UPDATE_TOPOLOGY_STMT "prepare update_topology from 'update topology set connections = ? where topology_uid = @temp_topology'" 69#define UPDATE_TOPOLOGY_STMT "prepare update_topology from 'update topology set connections = ? where topology_uid = @temp_topology'"
70 70
71#define SET_MALICIOUS_STMT "prepare set_malicious from 'update nodes set malicious_dropper = 1 where trialuid = @temp_trial and nodeid = @temp_node'"
72
71#define INSERT_TRIALS_STMT "prepare insert_trial from 'INSERT INTO trials"\ 73#define INSERT_TRIALS_STMT "prepare insert_trial from 'INSERT INTO trials"\
72 "(starttime, numnodes, topology,"\ 74 "(starttime, numnodes, topology,"\
73 "topology_percentage, topology_probability,"\ 75 "topology_percentage, topology_probability,"\
@@ -79,6 +81,10 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
79 "gets_succeeded, message) "\ 81 "gets_succeeded, message) "\
80 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'" 82 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'"
81 83
84#define INSERT_GENERIC_STAT_STMT "prepare insert_generic_stat from 'INSERT INTO generic_stats" \
85 "(trialuid, nodeuid, section, name, value)"\
86 "VALUES (@temp_trial, @temp_node, @temp_section, @temp_stat, @temp_value)'"
87
82#define INSERT_STAT_STMT "prepare insert_stat from 'INSERT INTO node_statistics"\ 88#define INSERT_STAT_STMT "prepare insert_stat from 'INSERT INTO node_statistics"\
83 "(trialuid, nodeuid, route_requests,"\ 89 "(trialuid, nodeuid, route_requests,"\
84 "route_forwards, result_requests,"\ 90 "route_forwards, result_requests,"\
@@ -153,6 +159,8 @@ iopen ()
153 if (PINIT (INSERT_QUERIES_STMT) || 159 if (PINIT (INSERT_QUERIES_STMT) ||
154 PINIT (INSERT_ROUTES_STMT) || 160 PINIT (INSERT_ROUTES_STMT) ||
155 PINIT (INSERT_TRIALS_STMT) || 161 PINIT (INSERT_TRIALS_STMT) ||
162 PINIT (SET_MALICIOUS_STMT) ||
163 PINIT (INSERT_GENERIC_STAT_STMT) ||
156 PINIT (INSERT_STAT_STMT) || 164 PINIT (INSERT_STAT_STMT) ||
157 PINIT (INSERT_NODES_STMT) || 165 PINIT (INSERT_NODES_STMT) ||
158 PINIT (INSERT_DHTKEY_STMT) || 166 PINIT (INSERT_DHTKEY_STMT) ||
@@ -324,6 +332,43 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in
324 return GNUNET_SYSERR; 332 return GNUNET_SYSERR;
325} 333}
326 334
335
336/*
337 * Inserts the specified stats into the dhttests.generic_stats table
338 *
339 * @param peer the peer inserting the statistic
340 * @param name the name of the statistic
341 * @param section the section of the statistic
342 * @param value the value of the statistic
343 *
344 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
345 */
346int
347add_generic_stat (const struct GNUNET_PeerIdentity *peer,
348 const char *name,
349 const char *section, uint64_t value)
350{
351 int ret;
352 if (outfile == NULL)
353 return GNUNET_SYSERR;
354
355 if (peer != NULL)
356 ret = fprintf(outfile, "select nodeuid from nodes where trialuid = @temp_trial and nodeid = \"%s\" into @temp_node;\n", GNUNET_h2s_full(&peer->hashPubKey));
357 else
358 ret = fprintf(outfile, "set @temp_node = 0;\n");
359
360 ret = fprintf(outfile, "set @temp_section = \"%s\", @temp_stat = \"%s\", @temp_value = %llu;\n",
361 section, name, (unsigned long long)value);
362
363 if (ret < 0)
364 return GNUNET_SYSERR;
365
366 ret = fprintf(outfile, "execute insert_generic_stat;\n");
367
368 return GNUNET_OK;
369}
370
371
327/* 372/*
328 * Inserts the specified stats into the dhttests.node_statistics table 373 * Inserts the specified stats into the dhttests.node_statistics table
329 * 374 *
@@ -495,6 +540,36 @@ update_trials (unsigned long long trialuid,
495 540
496 541
497/* 542/*
543 * Update dhttests.nodes table setting the identified
544 * node as a malicious dropper.
545 *
546 * @param peer the peer that was set to be malicious
547 *
548 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
549 */
550int
551set_malicious (struct GNUNET_PeerIdentity *peer)
552{
553 int ret;
554
555 if (outfile == NULL)
556 return GNUNET_SYSERR;
557
558 ret = fprintf(outfile, "set @temp_node = \"%s\";\n", GNUNET_h2s_full(&peer->hashPubKey));
559
560 if (ret < 0)
561 return GNUNET_SYSERR;
562
563 ret = fprintf(outfile, "execute set_malicious;\n");
564
565 if (ret >= 0)
566 return GNUNET_OK;
567 else
568 return GNUNET_SYSERR;
569}
570
571
572/*
498 * Update dhttests.trials table with total connections information 573 * Update dhttests.trials table with total connections information
499 * 574 *
500 * @param trialuid the trialuid to update 575 * @param trialuid the trialuid to update
@@ -744,6 +819,8 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
744 plugin->dhtlog_api->insert_topology = &add_topology; 819 plugin->dhtlog_api->insert_topology = &add_topology;
745 plugin->dhtlog_api->insert_extended_topology = &add_extended_topology; 820 plugin->dhtlog_api->insert_extended_topology = &add_extended_topology;
746 plugin->dhtlog_api->update_topology = &update_topology; 821 plugin->dhtlog_api->update_topology = &update_topology;
822 plugin->dhtlog_api->set_malicious = &set_malicious;
823 plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
747 824
748 return plugin; 825 return plugin;
749} 826}