aboutsummaryrefslogtreecommitdiff
path: root/src/dht/plugin_dhtlog_mysql_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/plugin_dhtlog_mysql_dump.c')
-rw-r--r--src/dht/plugin_dhtlog_mysql_dump.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c
index 188807e4e..603e592e7 100644
--- a/src/dht/plugin_dhtlog_mysql_dump.c
+++ b/src/dht/plugin_dhtlog_mysql_dump.c
@@ -66,6 +66,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
66#define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO extended_topology (topology_uid, uid_first, uid_second) "\ 66#define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO extended_topology (topology_uid, uid_first, uid_second) "\
67 "VALUES (@temp_topology, ?, ?)'" 67 "VALUES (@temp_topology, ?, ?)'"
68 68
69#define UPDATE_TOPOLOGY_STMT "prepare update_topology from 'update topology set connections = ? where topology_uid = @temp_topology'"
69 70
70#define INSERT_TRIALS_STMT "prepare insert_trial from 'INSERT INTO trials"\ 71#define INSERT_TRIALS_STMT "prepare insert_trial from 'INSERT INTO trials"\
71 "(starttime, numnodes, topology,"\ 72 "(starttime, numnodes, topology,"\
@@ -147,7 +148,11 @@ iopen ()
147 PINIT (GET_DHTKEYUID_STMT) || 148 PINIT (GET_DHTKEYUID_STMT) ||
148 PINIT (GET_NODEUID_STMT) || 149 PINIT (GET_NODEUID_STMT) ||
149 PINIT (UPDATE_CONNECTIONS_STMT) || 150 PINIT (UPDATE_CONNECTIONS_STMT) ||
150 PINIT (GET_TRIAL_STMT)) 151 PINIT (INSERT_TOPOLOGY_STMT) ||
152 PINIT (EXTEND_TOPOLOGY_STMT) ||
153 PINIT (UPDATE_TOPOLOGY_STMT) ||
154 PINIT (GET_TRIAL_STMT) ||
155 PINIT (GET_TOPOLOGY_STMT))
151 { 156 {
152 return GNUNET_SYSERR; 157 return GNUNET_SYSERR;
153 } 158 }
@@ -440,6 +445,34 @@ add_connections (unsigned long long trialuid, unsigned int totalConnections)
440 return GNUNET_SYSERR; 445 return GNUNET_SYSERR;
441} 446}
442 447
448
449/*
450 * Update dhttests.topology table with total connections information
451 *
452 * @param totalConnections the number of connections
453 *
454 * @return GNUNET_OK on success, GNUNET_SYSERR on failure.
455 */
456int
457update_topology (unsigned int connections)
458{
459 int ret;
460 if (outfile == NULL)
461 return GNUNET_SYSERR;
462
463 ret = fprintf(outfile, "set @temp_conns = %u;\n", connections);
464
465 if (ret < 0)
466 return GNUNET_SYSERR;
467
468 ret = fprintf(outfile, "execute update_topology using @temp_conns;\n");
469
470 if (ret >= 0)
471 return GNUNET_OK;
472 else
473 return GNUNET_SYSERR;
474}
475
443/* 476/*
444 * Inserts the specified query into the dhttests.queries table 477 * Inserts the specified query into the dhttests.queries table
445 * 478 *
@@ -625,6 +658,9 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
625 plugin->dhtlog_api->insert_node = &add_node; 658 plugin->dhtlog_api->insert_node = &add_node;
626 plugin->dhtlog_api->insert_dhtkey = &add_dhtkey; 659 plugin->dhtlog_api->insert_dhtkey = &add_dhtkey;
627 plugin->dhtlog_api->update_connections = &add_connections; 660 plugin->dhtlog_api->update_connections = &add_connections;
661 plugin->dhtlog_api->insert_topology = &add_topology;
662 plugin->dhtlog_api->insert_extended_topology = &add_extended_topology;
663 plugin->dhtlog_api->update_topology = &update_topology;
628 664
629 return NULL; 665 return NULL;
630} 666}