feature creep
authorNathan S. Evans <evans@in.tum.de>
Thu, 16 Sep 2010 14:11:49 +0000 (14:11 +0000)
committerNathan S. Evans <evans@in.tum.de>
Thu, 16 Sep 2010 14:11:49 +0000 (14:11 +0000)
src/dht/plugin_dhtlog_dummy.c
src/dht/plugin_dhtlog_mysql.c
src/dht/plugin_dhtlog_mysql_dump.c
src/dht/plugin_dhtlog_mysql_dump_load.c

index 856d119c7a442c65c9f9ff11300bb0871428016a..803ad92ac731d9134dccb4624123f111db28b6ac 100644 (file)
@@ -45,6 +45,19 @@ int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info)
   return GNUNET_OK;
 }
 
+/*
+ * Inserts the specified round into the dhttests.rounds table
+ *
+ * @param round_type the type of round that is being started
+ * @param round_count counter for the round (if applicable)
+ *
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int add_round (unsigned int round_type, unsigned int round_count)
+{
+  return GNUNET_OK;
+}
+
 /*
  * Inserts the specified dhtkey into the dhttests.dhtkeys table,
  * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
@@ -282,6 +295,7 @@ libgnunet_plugin_dhtlog_dummy_init (void * cls)
   GNUNET_assert(plugin->dhtlog_api == NULL);
   plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
   plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
+  plugin->dhtlog_api->insert_round = &add_round;
   plugin->dhtlog_api->insert_stat = &insert_stat;
   plugin->dhtlog_api->insert_trial = &add_trial;
   plugin->dhtlog_api->insert_query = &add_query;
index 5e47ec2f5795a5e0f382ab88571a0e742753cd9f..465a987e0f699902ff2711c98f56a9c799e56b4b 100644 (file)
@@ -103,6 +103,11 @@ static struct StatementHandle *insert_route;
                           "VALUES (?, ?, ?)"
 static struct StatementHandle *insert_node;
 
+#define INSERT_ROUNDS_STMT "INSERT INTO rounds (trialuid, round_type, round_count, starttime) "\
+                          "VALUES (?, ?, ?, NOW())"
+
+static struct StatementHandle *insert_round;
+
 #define INSERT_TRIALS_STMT "INSERT INTO trials"\
                             "(starttime, other_trial_identifier, numnodes, topology,"\
                             "topology_percentage, topology_probability,"\
@@ -448,6 +453,7 @@ iopen (struct GNUNET_DHTLOG_Plugin *plugin)
   if (PINIT (insert_query, INSERT_QUERIES_STMT) ||
       PINIT (insert_route, INSERT_ROUTES_STMT) ||
       PINIT (insert_trial, INSERT_TRIALS_STMT) ||
+      PINIT (insert_round, INSERT_ROUNDS_STMT) ||
       PINIT (insert_stat, INSERT_STAT_STMT) ||
       PINIT (insert_generic_stat, INSERT_GENERIC_STAT_STMT) ||
       PINIT (insert_node, INSERT_NODES_STMT) ||
@@ -885,6 +891,31 @@ int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info)
   return GNUNET_OK;
 }
 
+/*
+ * Inserts the specified round into the dhttests.rounds table
+ *
+ * @param round_type the type of round that is being started
+ * @param round_count counter for the round (if applicable)
+ *
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int add_round (unsigned int round_type, unsigned int round_count)
+{
+
+  MYSQL_STMT *stmt;
+  int ret;
+
+  stmt = mysql_stmt_init(conn);
+  ret = prepared_statement_run (insert_round,
+                                NULL,
+                                MYSQL_TYPE_LONGLONG, &current_trial, GNUNET_YES,
+                                MYSQL_TYPE_LONG, &round_type, GNUNET_YES,
+                                MYSQL_TYPE_LONG, &round_count, GNUNET_YES, -1);
+  mysql_stmt_close(stmt);
+  if (ret != GNUNET_OK)
+    return GNUNET_SYSERR;
+  return ret;
+}
 
 /*
  * Inserts the specified stats into the dhttests.node_statistics table
@@ -1445,12 +1476,9 @@ add_topology (int num_connections)
   if (GNUNET_OK !=
       (ret = prepared_statement_run (insert_topology,
                                      NULL,
-                                     MYSQL_TYPE_LONGLONG,
-                                     &current_trial,
-                                     GNUNET_YES,
-                                     MYSQL_TYPE_LONG,
-                                     &num_connections,
-                                     GNUNET_YES, -1)))
+                                     MYSQL_TYPE_LONGLONG, &current_trial, GNUNET_YES,
+                                     MYSQL_TYPE_LONG, &num_connections, GNUNET_YES,
+                                     -1)))
     {
       if (ret == GNUNET_SYSERR)
         {
@@ -1542,6 +1570,7 @@ libgnunet_plugin_dhtlog_mysql_init (void * cls)
   plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
   plugin->dhtlog_api->insert_trial = &add_trial;
   plugin->dhtlog_api->insert_stat = &add_stat;
+  plugin->dhtlog_api->insert_round = &add_round;
   plugin->dhtlog_api->add_generic_stat = &add_generic_stat;
   plugin->dhtlog_api->insert_query = &add_query;
   plugin->dhtlog_api->update_trial = &update_trials;
@@ -1573,6 +1602,7 @@ libgnunet_plugin_dhtlog_mysql_done (void * cls)
   prepared_statement_close(insert_query);
   prepared_statement_close(insert_route);
   prepared_statement_close(insert_trial);
+  prepared_statement_close(insert_round);
   prepared_statement_close(insert_node);
   prepared_statement_close(insert_dhtkey);
   prepared_statement_close(update_trial);
index f58d6782a8b625f77db673999166b136a7b8f301..2582bca41ce34c03cf29034f1f4c3e2b498b424b 100644 (file)
@@ -63,6 +63,8 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
 #define INSERT_TOPOLOGY_STMT "prepare insert_topology from 'INSERT INTO topology (trialuid, date, connections) "\
                              "VALUES (@temp_trial, ?, ?)'"
 
+#define INSERT_ROUND_STMT "prepare insert_round from 'INSERT INTO rounds (trialuid, round_type, round_count, starttime) VALUES (@temp_trial, @rtype, @rcount, @curr_time)'"
+
 #define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO extended_topology (topology_uid, uid_first, uid_second) "\
                              "VALUES (@temp_topology, ?, ?)'"
 
@@ -158,6 +160,7 @@ iopen ()
 #define PINIT(a) (GNUNET_OK != (prepared_statement_create(a)))
   if (PINIT (INSERT_QUERIES_STMT) ||
       PINIT (INSERT_ROUTES_STMT) ||
+      PINIT (INSERT_ROUND_STMT) ||
       PINIT (INSERT_TRIALS_STMT) ||
       PINIT (SET_MALICIOUS_STMT) ||
       PINIT (INSERT_GENERIC_STAT_STMT) ||
@@ -181,7 +184,30 @@ iopen ()
   return GNUNET_OK;
 }
 
+/*
+ * Inserts the specified round into the dhttests.rounds table
+ *
+ * @param round_type the type of round that is being started
+ * @param round_count counter for the round (if applicable)
+ *
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int add_round (unsigned int round_type, unsigned int round_count)
+{
+  int ret;
+  if (outfile == NULL)
+    return GNUNET_SYSERR;
+
+  ret = fprintf(outfile, "set @curr_time = \"%s\", @rtype = \"%u\", @rcount = \"%u\";\n", get_sql_time(), round_type, round_count);
+
+  if (ret < 0)
+    return GNUNET_SYSERR;
+  ret = fprintf(outfile, "execute insert_round;\n");
 
+  if (ret >= 0)
+    return GNUNET_OK;
+  return GNUNET_SYSERR;
+}
 
 /*
  * Records the current topology (number of connections, time, trial)
@@ -813,6 +839,7 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void * cls)
   GNUNET_assert(plugin->dhtlog_api == NULL);
   plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
   plugin->dhtlog_api->insert_trial = &add_trial;
+  plugin->dhtlog_api->insert_round = &add_round;
   plugin->dhtlog_api->insert_stat = &add_stat;
   plugin->dhtlog_api->insert_query = &add_query;
   plugin->dhtlog_api->update_trial = &update_trials;
index 32733d03ac1fb79e62cc1047d42a9308ce3639b6..e1c1e65801a6480477526635a172ba662c000e5b 100644 (file)
@@ -109,6 +109,28 @@ add_topology (int num_connections)
   return GNUNET_SYSERR;
 }
 
+/*
+ * Inserts the specified round into the dhttests.rounds table
+ *
+ * @param round_type the type of round that is being started
+ * @param round_count counter for the round (if applicable)
+ *
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int add_round (unsigned int round_type, unsigned int round_count)
+{
+  int ret;
+  if (outfile == NULL)
+    return GNUNET_SYSERR;
+
+  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());
+
+  if (ret >= 0)
+    return GNUNET_OK;
+  return GNUNET_SYSERR;
+
+}
+
 /*
  * Records a connection between two peers in the current topology
  *
@@ -808,6 +830,7 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void * cls)
   plugin->dhtlog_api = GNUNET_malloc(sizeof(struct GNUNET_DHTLOG_Handle));
   plugin->dhtlog_api->insert_trial = &add_trial;
   plugin->dhtlog_api->insert_stat = &add_stat;
+  plugin->dhtlog_api->insert_round = &add_round;
   plugin->dhtlog_api->insert_query = &add_query;
   plugin->dhtlog_api->update_trial = &update_trials;
   plugin->dhtlog_api->insert_route = &add_route;