#include "dhtlog.h"
-#define DEBUG_DHTLOG GNUNET_NO
+#define DEBUG_DHTLOG GNUNET_YES
/**
* Maximum number of supported parameters for a prepared
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;
+
+}
+
+/*
+ * Inserts the specified round results into the
+ * dhttests.processed_round_details table
+ *
+ * @param round_type the type of round that is being started
+ * @param round_count counter for the round (if applicable)
+ * @param num_messages the total number of messages initiated
+ * @param num_messages_succeeded the number of messages that succeeded
+ *
+ * @return GNUNET_OK on success, GNUNET_SYSERR on failure
+ */
+int add_round_details (unsigned int round_type, unsigned int round_count,
+ unsigned int num_messages, unsigned int num_messages_succeeded)
+{
+ int ret;
+ if (outfile == NULL)
+ return GNUNET_SYSERR;
+
+ ret = fprintf(outfile, "insert into processed_trial_rounds (trialuid, round_type, round_count, starttime, endtime, num_messages, num_messages_succeeded) values (@temp_trial, \"%u\", \"%u\", \"%s\", \"%s\", \"%u\", \"%u\");\n",
+ round_type, round_count, get_sql_time(), get_sql_time(), num_messages, num_messages_succeeded);
+
+ if (ret >= 0)
+ return GNUNET_OK;
+ return GNUNET_SYSERR;
+}
+
/*
* Records a connection between two peers in the current topology
*
/*
* Inserts the specified trial into the dhttests.trials table
*
- * @param trialuid return the trialuid of the newly inserted trial
- * @param num_nodes how many nodes are in the trial
- * @param topology integer representing topology for this trial
- * @param blacklist_topology integer representing blacklist topology for this trial
- * @param connect_topology integer representing connect topology for this trial
- * @param connect_topology_option integer representing connect topology option
- * @param connect_topology_option_modifier float to modify connect option
- * @param topology_percentage percentage modifier for certain topologies
- * @param topology_probability probability modifier for certain topologies
- * @param puts number of puts to perform
- * @param gets number of gets to perform
- * @param concurrent number of concurrent requests
- * @param settle_time time to wait between creating topology and starting testing
- * @param num_rounds number of times to repeat the trial
- * @param malicious_getters number of malicious GET peers in the trial
- * @param malicious_putters number of malicious PUT peers in the trial
- * @param malicious_droppers number of malicious DROP peers in the trial
- * @param malicious_get_frequency how often malicious gets are sent
- * @param malicious_put_frequency how often malicious puts are sent
- * @param stop_closest stop forwarding PUTs if closest node found
- * @param stop_found stop forwarding GETs if data found
- * @param strict_kademlia test used kademlia routing algorithm
- * @param gets_succeeded how many gets did the test driver report success on
- * @param message string to put into DB for this trial
+ * @param trial_info struct containing the data to insert about this trial
*
* @return GNUNET_OK on success, GNUNET_SYSERR on failure
*/
-int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology,
- unsigned int blacklist_topology, unsigned int connect_topology,
- unsigned int connect_topology_option, float connect_topology_option_modifier,
- float topology_percentage, float topology_probability,
- unsigned int puts, unsigned int gets, unsigned int concurrent, unsigned int settle_time,
- unsigned int num_rounds, unsigned int malicious_getters, unsigned int malicious_putters,
- unsigned int malicious_droppers, unsigned int malicious_get_frequency,
- unsigned int malicious_put_frequency, unsigned int stop_closest, unsigned int stop_found,
- unsigned int strict_kademlia, unsigned int gets_succeeded,
- char *message)
+int add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info)
{
int ret;
- if (trialuid != NULL)
- *trialuid = 0;
if (outfile == NULL)
return GNUNET_SYSERR;
ret = fprintf(outfile, "INSERT INTO trials "
- "(starttime, numnodes, topology,"
+ "(starttime, other_trial_identifier, numnodes, topology,"
"blacklist_topology, connect_topology, connect_topology_option,"
"connect_topology_option_modifier, topology_percentage, topology_probability,"
"puts, gets, "
"malicious_putters, malicious_droppers, malicious_get_frequency,"
"malicious_put_frequency, stop_closest, stop_found, strict_kademlia, "
"gets_succeeded, message) "
- "VALUES (\"%s\", %u, %u, %u, %u, %u, %f, %f, %f, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, \"%s\");\n",
- get_sql_time(), num_nodes, topology,
- blacklist_topology, connect_topology,
- connect_topology_option, connect_topology_option_modifier,
- topology_percentage, topology_probability,
- puts, gets, concurrent, settle_time,
- num_rounds, malicious_getters, malicious_putters,
- malicious_droppers, malicious_get_frequency, malicious_put_frequency,
- stop_closest, stop_found, strict_kademlia, gets_succeeded, message);
+ "VALUES (\"%s\", %u, %u, %u, %u, %u, %u, %f, %f, %f, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, \"%s\");\n",
+ get_sql_time(), trial_info->other_identifier, trial_info->num_nodes, trial_info->topology,
+ trial_info->blacklist_topology, trial_info->connect_topology,
+ trial_info->connect_topology_option, trial_info->connect_topology_option_modifier,
+ trial_info->topology_percentage, trial_info->topology_probability,
+ trial_info->puts, trial_info->gets, trial_info->concurrent, trial_info->settle_time,
+ trial_info->num_rounds, trial_info->malicious_getters, trial_info->malicious_putters,
+ trial_info->malicious_droppers, trial_info->malicious_get_frequency, trial_info->malicious_put_frequency,
+ trial_info->stop_closest, trial_info->stop_found, trial_info->strict_kademlia, trial_info->gets_succeeded, trial_info->message);
if (ret < 0)
return GNUNET_SYSERR;
return GNUNET_SYSERR;
ret = fprintf(node_outfile, "TRIALUID\t%s\n", GNUNET_h2s_full(&node->hashPubKey));
-
+ fflush(node_outfile);
if (ret >= 0)
return GNUNET_OK;
return GNUNET_SYSERR;
/*
* Update dhttests.trials table with current server time as end time
*
- * @param trialuid trial to update
* @param gets_succeeded how many gets did the testcase report as successful
*
* @return GNUNET_OK on success, GNUNET_SYSERR on failure.
*/
int
-update_trials (unsigned long long trialuid,
- unsigned int gets_succeeded)
+update_trials (unsigned int gets_succeeded)
{
int ret;
-#if DEBUG_DHTLOG
- if (trialuid != current_trial)
- {
- fprintf (stderr,
- _("Trialuid to update is not equal to current_trial\n"));
- }
-#endif
if (outfile == NULL)
return GNUNET_SYSERR;
ret = fprintf(outfile, "update trials set endtime=\"%s\", gets_succeeded=%u where trialuid = @temp_trial;\n", get_sql_time(), gets_succeeded);
-
+ fflush(node_outfile);
if (ret >= 0)
return GNUNET_OK;
else
return GNUNET_SYSERR;
ret = fprintf(outfile, "update nodes set malicious_dropper = 1 where trialuid = @temp_trial and nodeid = \"%s\";\n", GNUNET_h2s_full(&peer->hashPubKey));
-
+ fflush(node_outfile);
if (ret >= 0)
return GNUNET_OK;
else
/*
* Update dhttests.trials table with total connections information
*
- * @param trialuid the trialuid to update
* @param totalConnections the number of connections
*
* @return GNUNET_OK on success, GNUNET_SYSERR on failure.
*/
int
-add_connections (unsigned long long trialuid, unsigned int totalConnections)
+add_connections (unsigned int totalConnections)
{
int ret;
-#if DEBUG_DHTLOG
- if (trialuid != current_trial)
- {
- fprintf (stderr,
- _("Trialuid to update is not equal to current_trial(!)(?)\n"));
- }
-#endif
+
if (outfile == NULL)
return GNUNET_SYSERR;
ret = fprintf(outfile, "update trials set totalConnections = %u where trialuid = @temp_trial;\n", totalConnections);
-
+ fflush(node_outfile);
if (ret >= 0)
return GNUNET_OK;
else
if (ret < 0)
return GNUNET_SYSERR;
- ret = fprintf(query_outfile, "%s\t%llu\t%u\t%u\t%u\n", GNUNET_h2s_full(&node->hashPubKey), queryid, type, hops, succeeded);
+ ret = fprintf(query_outfile, "%s\t%llu\t%u\t%u\t%u\t%s\n", GNUNET_h2s_full(&node->hashPubKey), queryid, type, hops, succeeded, get_sql_time());
if (ret >= 0)
return GNUNET_OK;
return NULL;
}
+ GNUNET_free(outfile_name);
GNUNET_asprintf (&outfile_name,
"%s%s-%d",
outfile_path,
"mysqldump_nodes",
getpid());
-
+ GNUNET_free(fn);
fn = GNUNET_STRINGS_filename_expand (outfile_name);
if (fn == NULL)
return NULL;
}
+ GNUNET_free(outfile_name);
GNUNET_asprintf (&outfile_name,
"%s%s-%d",
outfile_path,
"mysqldump_routes",
getpid());
+ GNUNET_free(fn);
fn = GNUNET_STRINGS_filename_expand (outfile_name);
if (fn == NULL)
return NULL;
}
+ GNUNET_free(outfile_name);
GNUNET_asprintf (&outfile_name,
"%s%s-%d",
outfile_path,
"mysqldump_queries",
getpid());
+ GNUNET_free(fn);
fn = GNUNET_STRINGS_filename_expand (outfile_name);
if (fn == NULL)
return NULL;
}
+ GNUNET_free(outfile_name);
GNUNET_asprintf (&outfile_name,
"%s%s-%d",
outfile_path,
"mysqldump_stats",
getpid());
+ GNUNET_free(fn);
fn = GNUNET_STRINGS_filename_expand (outfile_name);
if (fn == NULL)
return NULL;
}
+ GNUNET_free(outfile_name);
GNUNET_asprintf (&outfile_name,
"%s%s-%d",
outfile_path,
"mysqldump_generic_stats",
getpid());
-
+ GNUNET_free(fn);
fn = GNUNET_STRINGS_filename_expand (outfile_name);
if (fn == NULL)
return NULL;
}
+ GNUNET_free(outfile_name);
GNUNET_asprintf (&outfile_name,
"%s%s-%d",
outfile_path,
"mysqldump_dhtkey",
getpid());
-
+ GNUNET_free(fn);
fn = GNUNET_STRINGS_filename_expand (outfile_name);
if (fn == NULL)
return NULL;
}
+ GNUNET_free(outfile_name);
GNUNET_asprintf (&outfile_name,
"%s%s-%d",
outfile_path,
"mysqldump_extended_topology",
getpid());
-
+ GNUNET_free(fn);
fn = GNUNET_STRINGS_filename_expand (outfile_name);
if (fn == NULL)
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_round_details = &add_round_details;
plugin->dhtlog_api->insert_query = &add_query;
plugin->dhtlog_api->update_trial = &update_trials;
plugin->dhtlog_api->insert_route = &add_route;