gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14375 - gnunet/src/dht


From: gnunet
Subject: [GNUnet-SVN] r14375 - gnunet/src/dht
Date: Tue, 8 Feb 2011 15:46:17 +0100

Author: nevans
Date: 2011-02-08 15:46:17 +0100 (Tue, 08 Feb 2011)
New Revision: 14375

Modified:
   gnunet/src/dht/dhtlog.h
   gnunet/src/dht/gnunet-dht-driver.c
   gnunet/src/dht/plugin_dhtlog_dummy.c
   gnunet/src/dht/plugin_dhtlog_mysql.c
   gnunet/src/dht/plugin_dhtlog_mysql_dump.c
   gnunet/src/dht/plugin_dhtlog_mysql_dump_load.c
   gnunet/src/dht/test_dhtlog.c
Log:
enable very minimal dht logging

Modified: gnunet/src/dht/dhtlog.h
===================================================================
--- gnunet/src/dht/dhtlog.h     2011-02-08 11:23:24 UTC (rev 14374)
+++ gnunet/src/dht/dhtlog.h     2011-02-08 14:46:17 UTC (rev 14375)
@@ -278,6 +278,20 @@
   int (*insert_round) (unsigned int round_type, unsigned int round_count);
 
   /*
+   * 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 (*insert_round_details) (unsigned int round_type, unsigned int 
round_count,
+                               unsigned int num_messages, unsigned int 
num_messages_succeeded);
+
+  /*
    * Update dhttests.trials table with total connections information
    *
    * @param totalConnections the number of connections

Modified: gnunet/src/dht/gnunet-dht-driver.c
===================================================================
--- gnunet/src/dht/gnunet-dht-driver.c  2011-02-08 11:23:24 UTC (rev 14374)
+++ gnunet/src/dht/gnunet-dht-driver.c  2011-02-08 14:46:17 UTC (rev 14375)
@@ -42,7 +42,7 @@
 #define DEFAULT_TIMEOUT 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5)
 
 /* Timeout for waiting for (individual) replies to get requests */
-#define DEFAULT_GET_TIMEOUT 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90)
+#define DEFAULT_GET_TIMEOUT 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
 
 #define DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT 
GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 90)
 
@@ -292,8 +292,6 @@
   /**
    * How long to send find peer requests, once the settle time
    * is over don't send any more out!
-   *
-   * TODO: Add option for settle time and find peer sending time?
    */
   struct GNUNET_TIME_Absolute endtime;
 
@@ -701,6 +699,12 @@
  */
 static unsigned int failed_connections;
 
+/**
+ * If GNUNET_YES, only log PUT/GET round data to mysql, otherwise
+ * log everything (including each dht service logging).
+ */
+static unsigned int dhtlog_minimal;
+
 /* Task handle to use to schedule shutdown if something goes wrong */
 GNUNET_SCHEDULER_TaskIdentifier die_task;
 
@@ -920,15 +924,13 @@
   struct TopologyIteratorContext *topo_ctx = cls;
   if ((first != NULL) && (second != NULL))
     {
-      /* GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "According to CORE, peer %s is 
connected to %s\n", GNUNET_i2s(first), GNUNET_h2s(&second->hashPubKey));*/
       if ((topo_ctx->peers_seen != NULL) && (GNUNET_NO == 
GNUNET_CONTAINER_multihashmap_contains(topo_ctx->peers_seen, 
&first->hashPubKey)))
         {
           GNUNET_CONTAINER_multihashmap_put(topo_ctx->peers_seen, 
&first->hashPubKey, NULL, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
           topo_ctx->total_peers++;
         }
       topo_ctx->total_connections++;
-      if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(config, 
"dht_testing", "mysql_logging")) ||
-          (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(config, 
"dht_testing", "mysql_logging_extended")))
+      if ((GNUNET_NO == dhtlog_minimal) && (dhtlog_handle != NULL))
         dhtlog_handle->insert_extended_topology(first, second);
     }
   else
@@ -1571,7 +1573,6 @@
         }
       GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Added %d peers to heap, total 
size %d\n", count_added, 
GNUNET_CONTAINER_heap_get_size(find_peer_context->peer_min_heap));
       GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, 
&schedule_churn_get_topology, find_peer_context);
-      //GNUNET_TESTING_get_topology (pg, &count_peers_churn_cb, 
find_peer_context);
     }
   else
     {
@@ -1589,6 +1590,7 @@
           die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout,
                                                    &end_badly, "from do gets 
(churn_complete)");
           GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, 
&capture_current_topology, topo_ctx);
+          dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished);
         }
       else
         {
@@ -1596,8 +1598,6 @@
           calc_timeout = GNUNET_TIME_relative_add(calc_timeout, 
DEFAULT_PEER_DISCONNECT_TIMEOUT);
           die_task = GNUNET_SCHEDULER_add_delayed (calc_timeout,
                                                    &end_badly, "from do gets 
(churn_complete)");
-          if (dhtlog_handle != NULL)
-            dhtlog_handle->insert_round(DHT_ROUND_GET, rounds_finished);
           GNUNET_SCHEDULER_add_delayed(DEFAULT_PEER_DISCONNECT_TIMEOUT, 
&do_get, all_gets);
         }
     }
@@ -1692,6 +1692,8 @@
   if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0))
     {
       fprintf(stderr, "Canceling die task (get_stop_finished) %llu gets 
completed, %llu gets failed\n", gets_completed, gets_failed);
+      if ((GNUNET_YES == dhtlog_minimal) && (NULL != dhtlog_handle))
+        dhtlog_handle->insert_round_details(DHT_ROUND_GET, rounds_finished, 
num_gets, gets_completed);
       GNUNET_SCHEDULER_cancel(die_task);
       reset_meter(put_meter);
       reset_meter(get_meter);
@@ -1703,7 +1705,7 @@
        */
       if (rounds_finished == total_rounds - 1) /* Everything is finished, end 
testing */
         {
-          if (dhtlog_handle != NULL)
+          if ((dhtlog_handle != NULL) && (GNUNET_NO == dhtlog_minimal))
             {
               topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext));
               topo_ctx->cont = &log_dht_statistics;
@@ -1907,7 +1909,7 @@
     {
       GNUNET_assert(outstanding_puts == 0);
       GNUNET_SCHEDULER_cancel (die_task);
-      if (dhtlog_handle != NULL)
+      if ((dhtlog_handle != NULL) && (GNUNET_NO == dhtlog_minimal))
         {
           topo_ctx = GNUNET_malloc(sizeof(struct TopologyIteratorContext));
           topo_ctx->cont = &do_get;
@@ -2265,7 +2267,7 @@
   struct TopologyIteratorContext *topo_ctx;
   struct FindPeerContext *find_peer_context;
   GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "In continue_puts_and_gets\n");
-  if (dhtlog_handle != NULL)
+  if ((dhtlog_handle != NULL) && (GNUNET_NO == dhtlog_minimal))
     {
       if (settle_time >= 180 * 2)
         max = (settle_time / 180) - 2;
@@ -2818,8 +2820,12 @@
    * Get DHT specific testing options.
    */
   if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", 
"mysql_logging")) ||
-      (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", 
"mysql_logging_extended")))
+      (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", 
"mysql_logging_extended")) ||
+      (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, "dht_testing", 
"mysql_logging_minimal")))
     {
+      if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno(cfg, 
"dht_testing", "mysql_logging_minimal"))
+        dhtlog_minimal = GNUNET_YES;
+
       dhtlog_handle = GNUNET_DHTLOG_connect(cfg);
       if (dhtlog_handle == NULL)
         {

Modified: gnunet/src/dht/plugin_dhtlog_dummy.c
===================================================================
--- gnunet/src/dht/plugin_dhtlog_dummy.c        2011-02-08 11:23:24 UTC (rev 
14374)
+++ gnunet/src/dht/plugin_dhtlog_dummy.c        2011-02-08 14:46:17 UTC (rev 
14375)
@@ -58,6 +58,23 @@
 }
 
 /*
+ * 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_succeded)
+{
+  return GNUNET_OK;
+}
+
+/*
  * Inserts the specified dhtkey into the dhttests.dhtkeys table,
  * stores return value of dhttests.dhtkeys.dhtkeyuid into dhtkeyuid
  *
@@ -292,6 +309,7 @@
   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_round_details = &add_round_details;
   plugin->dhtlog_api->insert_stat = &insert_stat;
   plugin->dhtlog_api->insert_trial = &add_trial;
   plugin->dhtlog_api->insert_query = &add_query;

Modified: gnunet/src/dht/plugin_dhtlog_mysql.c
===================================================================
--- gnunet/src/dht/plugin_dhtlog_mysql.c        2011-02-08 11:23:24 UTC (rev 
14374)
+++ gnunet/src/dht/plugin_dhtlog_mysql.c        2011-02-08 14:46:17 UTC (rev 
14375)
@@ -108,6 +108,11 @@
 
 static struct StatementHandle *insert_round;
 
+#define INSERT_ROUND_DETAILS_STMT "INSERT INTO rounds (trialuid, round_type, 
round_count, starttime, endtime, num_messages, num_messages_succeeded) "\
+                          "VALUES (?, ?, ?, NOW(), NOW(), ?, ?)"
+
+static struct StatementHandle *insert_round_details;
+
 #define INSERT_TRIALS_STMT "INSERT INTO trials"\
                             "(starttime, other_trial_identifier, numnodes, 
topology,"\
                             "topology_percentage, topology_probability,"\
@@ -454,6 +459,7 @@
       PINIT (insert_route, INSERT_ROUTES_STMT) ||
       PINIT (insert_trial, INSERT_TRIALS_STMT) ||
       PINIT (insert_round, INSERT_ROUNDS_STMT) ||
+      PINIT (insert_round, INSERT_ROUND_DETAILS_STMT) ||
       PINIT (insert_stat, INSERT_STAT_STMT) ||
       PINIT (insert_generic_stat, INSERT_GENERIC_STAT_STMT) ||
       PINIT (insert_node, INSERT_NODES_STMT) ||
@@ -918,6 +924,38 @@
 }
 
 /*
+ * 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)
+{
+  MYSQL_STMT *stmt;
+  int ret;
+
+  stmt = mysql_stmt_init(conn);
+  ret = prepared_statement_run (insert_round_details,
+                                NULL,
+                                MYSQL_TYPE_LONGLONG, &current_trial, 
GNUNET_YES,
+                                MYSQL_TYPE_LONG, &round_type, GNUNET_YES,
+                                MYSQL_TYPE_LONG, &round_count, GNUNET_YES,
+                                MYSQL_TYPE_LONG, &num_messages, GNUNET_YES,
+                                MYSQL_TYPE_LONG, &num_messages_succeeded, 
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
  *
  * @param peer the peer inserting the statistic
@@ -1561,6 +1599,7 @@
   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->add_generic_stat = &add_generic_stat;
   plugin->dhtlog_api->insert_query = &add_query;
   plugin->dhtlog_api->update_trial = &update_trials;
@@ -1593,6 +1632,7 @@
   prepared_statement_close(insert_route);
   prepared_statement_close(insert_trial);
   prepared_statement_close(insert_round);
+  prepared_statement_close(insert_round_details);
   prepared_statement_close(insert_node);
   prepared_statement_close(insert_dhtkey);
   prepared_statement_close(update_trial);

Modified: gnunet/src/dht/plugin_dhtlog_mysql_dump.c
===================================================================
--- gnunet/src/dht/plugin_dhtlog_mysql_dump.c   2011-02-08 11:23:24 UTC (rev 
14374)
+++ gnunet/src/dht/plugin_dhtlog_mysql_dump.c   2011-02-08 14:46:17 UTC (rev 
14375)
@@ -65,6 +65,10 @@
 
 #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 INSERT_ROUND_DETAILS_STMT "prepare insert_round_details from 'INSERT 
INTO processed_trial_rounds "\
+                                  "(trialuid, round_type, round_count, 
starttime, endtime, num_messages, num_messages_succeeded)"\
+                                  "VALUES (@temp_trial, @rtype, @rcount, 
@curr_time, @curr_time, @totalmsgs, @msgssucceeded)'"
+
 #define EXTEND_TOPOLOGY_STMT "prepare extend_topology from 'INSERT INTO 
extended_topology (topology_uid, uid_first, uid_second) "\
                              "VALUES (@temp_topology, ?, ?)'"
 
@@ -161,6 +165,7 @@
   if (PINIT (INSERT_QUERIES_STMT) ||
       PINIT (INSERT_ROUTES_STMT) ||
       PINIT (INSERT_ROUND_STMT) ||
+      PINIT (INSERT_ROUND_DETAILS_STMT) ||
       PINIT (INSERT_TRIALS_STMT) ||
       PINIT (SET_MALICIOUS_STMT) ||
       PINIT (INSERT_GENERIC_STAT_STMT) ||
@@ -210,6 +215,36 @@
 }
 
 /*
+ * 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, "set @curr_time = \"%s\", @rtype = \"%u\", @rcount = 
\"%u\", @totalmsgs = \"%u\", @msgssucceeded = \"%u\";\n",
+                          get_sql_time(), round_type, round_count, 
num_messages, num_messages_succeeded);
+
+  if (ret < 0)
+    return GNUNET_SYSERR;
+  ret = fprintf(outfile, "execute insert_round_details;\n");
+
+  if (ret >= 0)
+    return GNUNET_OK;
+  return GNUNET_SYSERR;
+}
+
+/*
  * Records the current topology (number of connections, time, trial)
  *
  * @param num_connections how many connections are in the topology
@@ -821,6 +856,7 @@
   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_round_details = &add_round_details;
   plugin->dhtlog_api->insert_stat = &add_stat;
   plugin->dhtlog_api->insert_query = &add_query;
   plugin->dhtlog_api->update_trial = &update_trials;

Modified: gnunet/src/dht/plugin_dhtlog_mysql_dump_load.c
===================================================================
--- gnunet/src/dht/plugin_dhtlog_mysql_dump_load.c      2011-02-08 11:23:24 UTC 
(rev 14374)
+++ gnunet/src/dht/plugin_dhtlog_mysql_dump_load.c      2011-02-08 14:46:17 UTC 
(rev 14375)
@@ -132,6 +132,32 @@
 }
 
 /*
+ * 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
  *
  * @param first one side of the connection
@@ -824,6 +850,7 @@
   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;

Modified: gnunet/src/dht/test_dhtlog.c
===================================================================
--- gnunet/src/dht/test_dhtlog.c        2011-02-08 11:23:24 UTC (rev 14374)
+++ gnunet/src/dht/test_dhtlog.c        2011-02-08 14:46:17 UTC (rev 14375)
@@ -180,6 +180,8 @@
 #endif
   ret = api->insert_round(401, 507);
   CHECK(ret);
+  ret = api->insert_round_details(402, 507, 1123, 985);
+  CHECK(ret);
 #if VERBOSE
   fprintf(stderr, "Insert round succeeded!\n");
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]