From 4e401e3ef3ed0027275f366c11f5b67df52ef67d Mon Sep 17 00:00:00 2001 From: "Nathan S. Evans" Date: Thu, 16 Sep 2010 15:20:40 +0000 Subject: [PATCH] debug messages in driver, correct time (even for mysql_dump), change dhtlog testcase so it doesn't leave files after running --- src/dht/gnunet-dht-driver.c | 23 +++++++++++++++-------- src/dht/plugin_dhtlog_mysql.c | 4 ++-- src/dht/plugin_dhtlog_mysql_dump.c | 8 ++++---- src/dht/plugin_dhtlog_mysql_dump_load.c | 2 +- src/dht/test_dhtlog_data.conf | 4 ++-- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index cdd5e7c16..e343e911f 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c @@ -1305,7 +1305,7 @@ void count_peers_churn_cb (void *cls, */ if ((peer_count->count == 0) && (GNUNET_TIME_absolute_get_remaining(find_peer_context->endtime).value > 0)) { - GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found peer with no connections, will choose some peers at random to connect to!\n"); + GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); GNUNET_CONTAINER_heap_iterate (find_peer_context->peer_min_heap, &iterate_min_heap_peers, find_peer_context); GNUNET_SCHEDULER_add_now(sched, &schedule_churn_find_peer_requests, find_peer_context); } @@ -1368,6 +1368,7 @@ static void churn_complete (void *cls, const char *emsg) */ if (find_peer_context != NULL) { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "We have churned on some peers, so we must schedule find peer requests for them!\n"); for (i = 0; i < num_peers; i ++) { temp_daemon = GNUNET_TESTING_daemon_get(pg, i); @@ -1380,6 +1381,7 @@ static void churn_complete (void *cls, const char *emsg) } else { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Only churned off peers, no find peer requests, scheduling more gets...\n"); if (dhtlog_handle != NULL) { topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext)); @@ -1988,12 +1990,17 @@ continue_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * t GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time), &setup_puts_and_gets, NULL); if (GNUNET_YES == do_find_peer) - { - find_peer_context = GNUNET_malloc(sizeof(struct FindPeerContext)); - find_peer_context->count_peers_cb = &count_peers_cb; - find_peer_context->endtime = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time)); - GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, find_peer_context); - } + { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Scheduling find peer requests during \"settle\" time.\n"); + find_peer_context = GNUNET_malloc(sizeof(struct FindPeerContext)); + find_peer_context->count_peers_cb = &count_peers_cb; + find_peer_context->endtime = GNUNET_TIME_relative_to_absolute(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, settle_time)); + GNUNET_SCHEDULER_add_now(sched, &schedule_find_peer_requests, find_peer_context); + } + else + { + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Assuming automatic DHT find peer requests.\n"); + } } /** @@ -2432,7 +2439,7 @@ run (void *cls, churn_data = NULL; /** Check for a churn file to do churny simulation */ if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "churn_file", + GNUNET_CONFIGURATION_get_value_string(cfg, "dht_testing", "churn_file", &churn_filename)) { GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Reading churn data from %s\n", churn_filename); diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c index 465a987e0..b31a41f4c 100644 --- a/src/dht/plugin_dhtlog_mysql.c +++ b/src/dht/plugin_dhtlog_mysql.c @@ -91,8 +91,8 @@ static unsigned long long current_trial = 0; /* I like to assign 0, just to r */ static MYSQL *conn; -#define INSERT_QUERIES_STMT "INSERT INTO queries (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid) "\ - "VALUES (?, ?, ?, ?, ?, ?, ?)" +#define INSERT_QUERIES_STMT "INSERT INTO queries (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid, time) "\ + "VALUES (?, ?, ?, ?, ?, ?, ?, NOW())" static struct StatementHandle *insert_query; #define INSERT_ROUTES_STMT "INSERT INTO routes (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid, from_node, to_node) "\ diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c index 2582bca41..8b16c155d 100644 --- a/src/dht/plugin_dhtlog_mysql_dump.c +++ b/src/dht/plugin_dhtlog_mysql_dump.c @@ -51,8 +51,8 @@ static unsigned long max_varchar_len; */ static const struct GNUNET_CONFIGURATION_Handle *cfg; -#define INSERT_QUERIES_STMT "prepare insert_query from 'INSERT INTO queries (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid) "\ - "VALUES (@temp_trial, ?, ?, ?, ?, ?, ?)'" +#define INSERT_QUERIES_STMT "prepare insert_query from 'INSERT INTO queries (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid, time) "\ + "VALUES (@temp_trial, ?, ?, ?, ?, ?, ?, ?)'" #define INSERT_ROUTES_STMT "prepare insert_route from 'INSERT INTO routes (trialuid, querytype, hops, dhtkeyuid, dhtqueryid, succeeded, nodeuid, from_node, to_node) "\ "VALUES (@temp_trial, ?, ?, ?, ?, ?, ?, ?, ?)'" @@ -678,12 +678,12 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, if (ret < 0) return GNUNET_SYSERR; - ret = fprintf(outfile, "set @qid = %llu, @type = %u, @hops = %u, @succ = %d;\n", queryid, type, hops, succeeded); + ret = fprintf(outfile, "set @qid = %llu, @type = %u, @hops = %u, @succ = %d, @time = \"%s\";\n", queryid, type, hops, succeeded, get_sql_time()); if (ret < 0) return GNUNET_SYSERR; - ret = fprintf(outfile, "execute insert_query using @type, @hops, @temp_dhtkey, @qid, @succ, @temp_node;\n"); + ret = fprintf(outfile, "execute insert_query using @type, @hops, @temp_dhtkey, @qid, @succ, @temp_node, @time;\n"); if (ret >= 0) return GNUNET_OK; diff --git a/src/dht/plugin_dhtlog_mysql_dump_load.c b/src/dht/plugin_dhtlog_mysql_dump_load.c index e1c1e6580..ac4b91301 100644 --- a/src/dht/plugin_dhtlog_mysql_dump_load.c +++ b/src/dht/plugin_dhtlog_mysql_dump_load.c @@ -475,7 +475,7 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, 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; diff --git a/src/dht/test_dhtlog_data.conf b/src/dht/test_dhtlog_data.conf index 2cb9af38a..22ef427aa 100644 --- a/src/dht/test_dhtlog_data.conf +++ b/src/dht/test_dhtlog_data.conf @@ -36,8 +36,8 @@ DEFAULTCONFIG = test_dhtlog_data.conf SERVICEHOME = /tmp/test-dhtlog/ [DHTLOG] -PLUGIN = mysql_dump -#PLUGIN = dummy +#PLUGIN = mysql_dump +PLUGIN = dummy #PLUGIN = mysql [MYSQL] -- 2.25.1