From: Nathan S. Evans Date: Tue, 7 Sep 2010 10:03:45 +0000 (+0000) Subject: dhtlog updates X-Git-Tag: initial-import-from-subversion-38251~20424 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e674423144e969eb701cf72f7b0c660c2f5406ca;p=oweals%2Fgnunet.git dhtlog updates --- diff --git a/src/dht/dhtlog.h b/src/dht/dhtlog.h index 7c39528e0..1ea044174 100644 --- a/src/dht/dhtlog.h +++ b/src/dht/dhtlog.h @@ -95,6 +95,8 @@ struct GNUNET_DHTLOG_Handle * Inserts the specified trial into the dhttests.trials table * * @param trialuid return the trialuid of the newly inserted trial + * @param other_identifier identifier for the trial from another source + * (for joining later) * @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 @@ -121,7 +123,7 @@ struct GNUNET_DHTLOG_Handle * * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ - int (*insert_trial) (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology, + int (*insert_trial) (unsigned long long *trialuid, unsigned int other_identifier, 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, diff --git a/src/dht/plugin_dhtlog_dummy.c b/src/dht/plugin_dhtlog_dummy.c index 7be199a76..1ea2ac596 100644 --- a/src/dht/plugin_dhtlog_dummy.c +++ b/src/dht/plugin_dhtlog_dummy.c @@ -36,6 +36,8 @@ * Inserts the specified trial into the dhttests.trials table * * @param trialuid return the trialuid of the newly inserted trial + * @param other_identifier identifier for the trial from another source + * (for joining later) * @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 @@ -62,7 +64,7 @@ * * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ -int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology, +int add_trial (unsigned long long *trialuid, unsigned int other_identifier, 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, @@ -246,6 +248,56 @@ update_topology (unsigned int connections) return GNUNET_OK; } +/* + * Update dhttests.nodes table setting the identified + * node as a malicious dropper. + * + * @param peer the peer that was set to be malicious + * + * @return GNUNET_OK on success, GNUNET_SYSERR on failure. + */ +int +set_malicious (struct GNUNET_PeerIdentity *peer) +{ + return GNUNET_OK; +} + +/* + * Inserts the specified stats into the dhttests.node_statistics table + * + * @param peer the peer inserting the statistic + * @param route_requests route requests seen + * @param route_forwards route requests forwarded + * @param result_requests route result requests seen + * @param client_requests client requests initiated + * @param result_forwards route results forwarded + * @param gets get requests handled + * @param puts put requests handle + * @param data_inserts data inserted at this node + * @param find_peer_requests find peer requests seen + * @param find_peers_started find peer requests initiated at this node + * @param gets_started get requests initiated at this node + * @param puts_started put requests initiated at this node + * @param find_peer_responses_received find peer responses received locally + * @param get_responses_received get responses received locally + * @param find_peer_responses_sent find peer responses sent from this node + * @param get_responses_sent get responses sent from this node + * + * @return GNUNET_OK on success, GNUNET_SYSERR on failure + */ +int insert_stat + (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, + unsigned int route_forwards, unsigned int result_requests, + unsigned int client_requests, unsigned int result_forwards, + unsigned int gets, unsigned int puts, + unsigned int data_inserts, unsigned int find_peer_requests, + unsigned int find_peers_started, unsigned int gets_started, + unsigned int puts_started, unsigned int find_peer_responses_received, + unsigned int get_responses_received, unsigned int find_peer_responses_sent, + unsigned int get_responses_sent) +{ + return GNUNET_OK; +} /* * Provides the dhtlog api @@ -264,9 +316,11 @@ 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_stat = &insert_stat; plugin->dhtlog_api->insert_trial = &add_trial; plugin->dhtlog_api->insert_query = &add_query; plugin->dhtlog_api->update_trial = &update_trials; + plugin->dhtlog_api->set_malicious = &set_malicious; plugin->dhtlog_api->insert_route = &add_route; plugin->dhtlog_api->insert_node = &add_node; plugin->dhtlog_api->insert_dhtkey = &add_dhtkey; diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c index 32eb07853..c1029b11b 100644 --- a/src/dht/plugin_dhtlog_mysql.c +++ b/src/dht/plugin_dhtlog_mysql.c @@ -32,7 +32,7 @@ #include -#define DEBUG_DHTLOG GNUNET_NO +#define DEBUG_DHTLOG GNUNET_YES /** * Maximum number of supported parameters for a prepared @@ -104,7 +104,7 @@ static struct StatementHandle *insert_route; static struct StatementHandle *insert_node; #define INSERT_TRIALS_STMT "INSERT INTO trials"\ - "(starttime, numnodes, topology,"\ + "(starttime, other_trial_identifier, numnodes, topology,"\ "topology_percentage, topology_probability,"\ "blacklist_topology, connect_topology, connect_topology_option,"\ "connect_topology_option_modifier, puts, gets, "\ @@ -112,7 +112,7 @@ static struct StatementHandle *insert_node; "malicious_putters, malicious_droppers, malicious_get_frequency,"\ "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, "\ "gets_succeeded, message) "\ - "VALUES (NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" + "VALUES (NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" static struct StatementHandle *insert_trial; @@ -243,30 +243,38 @@ itable () return GNUNET_SYSERR; if (MRUNS ("CREATE TABLE IF NOT EXISTS `trials` (" - "`trialuid` int(10) unsigned NOT NULL auto_increment," - "`numnodes` int(10) unsigned NOT NULL," - "`topology` int(10) NOT NULL," - "`starttime` datetime NOT NULL," - "`endtime` datetime NOT NULL," - "`puts` int(10) unsigned NOT NULL," - "`gets` int(10) unsigned NOT NULL," - "`concurrent` int(10) unsigned NOT NULL," - "`settle_time` int(10) unsigned NOT NULL," - "`totalConnections` int(10) unsigned NOT NULL," - "`message` text NOT NULL," - "`num_rounds` int(10) unsigned NOT NULL," - "`malicious_getters` int(10) unsigned NOT NULL," - "`malicious_putters` int(10) unsigned NOT NULL," - "`malicious_droppers` int(10) unsigned NOT NULL," - "`totalMessagesDropped` int(10) unsigned NOT NULL," - "`totalBytesDropped` int(10) unsigned NOT NULL," - "`topology_modifier` double NOT NULL," - "`logNMultiplier` double NOT NULL," - "`maxnetbps` bigint(20) unsigned NOT NULL," - "`unknownPeers` int(10) unsigned NOT NULL," - "PRIMARY KEY (`trialuid`)," - "UNIQUE KEY `trialuid` (`trialuid`)" - ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) + "`trialuid` int(10) unsigned NOT NULL auto_increment," + "`other_trial_identifier` int(10) unsigned NOT NULL default '0'," + "`numnodes` int(10) unsigned NOT NULL," + "`topology` int(10) NOT NULL," + "`blacklist_topology` int(11) NOT NULL," + "`connect_topology` int(11) NOT NULL," + "`connect_topology_option` int(11) NOT NULL," + "`topology_percentage` float NOT NULL," + "`topology_probability` float NOT NULL," + "`connect_topology_option_modifier` float NOT NULL," + "`starttime` datetime NOT NULL," + "`endtime` datetime NOT NULL," + "`puts` int(10) unsigned NOT NULL," + "`gets` int(10) unsigned NOT NULL," + "`concurrent` int(10) unsigned NOT NULL," + "`settle_time` int(10) unsigned NOT NULL," + "`totalConnections` int(10) unsigned NOT NULL," + "`message` text NOT NULL," + "`num_rounds` int(10) unsigned NOT NULL," + "`malicious_getters` int(10) unsigned NOT NULL," + "`malicious_putters` int(10) unsigned NOT NULL," + "`malicious_droppers` int(10) unsigned NOT NULL," + "`topology_modifier` double NOT NULL," + "`malicious_get_frequency` int(10) unsigned NOT NULL," + "`malicious_put_frequency` int(10) unsigned NOT NULL," + "`stop_closest` int(10) unsigned NOT NULL," + "`stop_found` int(10) unsigned NOT NULL," + "`strict_kademlia` int(10) unsigned NOT NULL," + "`gets_succeeded` int(10) unsigned NOT NULL," + "PRIMARY KEY (`trialuid`)," + "UNIQUE KEY `trialuid` (`trialuid`)" + ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) return GNUNET_SYSERR; if (MRUNS ("CREATE TABLE IF NOT EXISTS `topology` (" @@ -750,7 +758,9 @@ get_dhtkey_uid (unsigned long long *dhtkeyuid, const GNUNET_HashCode * key) rbind[0].buffer = dhtkeyuid; GNUNET_CRYPTO_hash_to_enc (key, &encKey); k_len = strlen ((char *) &encKey); - +#if DEBUG_DHTLOG + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Searching for dhtkey `%s' in trial %llu\n", GNUNET_h2s(key), current_trial); +#endif if ((GNUNET_OK != prepared_statement_run_select (get_dhtkeyuid, 1, @@ -818,6 +828,8 @@ prepared_statement_run (struct StatementHandle *s, * Inserts the specified trial into the dhttests.trials table * * @param trialuid return the trialuid of the newly inserted trial + * @param other_identifier identifier for the trial from another source + * (for joining later) * @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 @@ -844,7 +856,7 @@ prepared_statement_run (struct StatementHandle *s, * * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ -int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology, +int add_trial (unsigned long long *trialuid, unsigned int other_identifier, 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, @@ -863,6 +875,7 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in stmt = mysql_stmt_init(conn); if (GNUNET_OK != (ret = prepared_statement_run (insert_trial, trialuid, + MYSQL_TYPE_LONG, &other_identifier, GNUNET_YES, MYSQL_TYPE_LONG, &num_nodes, GNUNET_YES, MYSQL_TYPE_LONG, &topology, GNUNET_YES, MYSQL_TYPE_FLOAT, &topology_percentage, @@ -1062,7 +1075,11 @@ add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) return GNUNET_OK; } else if (ret == GNUNET_SYSERR) - return GNUNET_SYSERR; + { +#if DEBUG_DHTLOG + GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Failed to get dhtkeyuid!\n"); +#endif + } if (GNUNET_OK != (ret = prepared_statement_run (insert_dhtkey, diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c index 21ddc238e..2fa31d297 100644 --- a/src/dht/plugin_dhtlog_mysql_dump.c +++ b/src/dht/plugin_dhtlog_mysql_dump.c @@ -71,7 +71,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; #define SET_MALICIOUS_STMT "prepare set_malicious from 'update nodes set malicious_dropper = 1 where trialuid = @temp_trial and nodeid = @temp_node'" #define INSERT_TRIALS_STMT "prepare insert_trial from 'INSERT INTO trials"\ - "(starttime, numnodes, topology,"\ + "(starttime, other_trial_identifier, numnodes, topology,"\ "topology_percentage, topology_probability,"\ "blacklist_topology, connect_topology, connect_topology_option,"\ "connect_topology_option_modifier, puts, gets, "\ @@ -79,7 +79,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; "malicious_putters, malicious_droppers, malicious_get_frequency,"\ "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, "\ "gets_succeeded, message) "\ - "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'" + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'" #define INSERT_GENERIC_STAT_STMT "prepare insert_generic_stat from 'INSERT INTO generic_stats" \ "(trialuid, nodeuid, section, name, value)"\ @@ -257,6 +257,8 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU * Inserts the specified trial into the dhttests.trials table * * @param trialuid return the trialuid of the newly inserted trial + * @param other_identifier identifier for the trial from another source + * (for joining later) * @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 @@ -283,7 +285,7 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU * * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ -int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology, +int add_trial (unsigned long long *trialuid, unsigned int other_identifier, 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, @@ -300,14 +302,14 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in if (outfile == NULL) return GNUNET_SYSERR; - ret = fprintf(outfile, "set @date = \"%s\", @num = %u, @topology = %u, @bl = %u, " + ret = fprintf(outfile, "set @date = \"%s\", @oid = %u, @num = %u, @topology = %u, @bl = %u, " "@connect = %u, @c_t_o = %u, @c_t_o_m = %f, @t_p = %f, " "@t_pr = %f, @puts = %u, @gets = %u, " "@concurrent = %u, @settle = %u, @rounds = %u, " "@m_gets = %u, @m_puts = %u, @m_drops = %u, " "@m_g_f = %u, @m_p_f = %u, @s_c = %u, @s_f = %u," "@s_k = %u, @g_s = %u, @message = \"%s\";\n", - get_sql_time(), num_nodes, topology, + get_sql_time(), other_identifier, num_nodes, topology, blacklist_topology, connect_topology, connect_topology_option, connect_topology_option_modifier, topology_percentage, topology_probability, @@ -319,7 +321,7 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in if (ret < 0) return GNUNET_SYSERR; ret = fprintf(outfile, "execute insert_trial using " - "@date, @num, @topology, @t_p, @t_pr," + "@date, @oid, @num, @topology, @t_p, @t_pr," " @bl, @connect, @c_t_o," "@c_t_o_m, @puts, @gets," "@concurrent, @settle, @rounds," diff --git a/src/dht/plugin_dhtlog_mysql_dump_load.c b/src/dht/plugin_dhtlog_mysql_dump_load.c index 5e0abca1b..7072c4b52 100644 --- a/src/dht/plugin_dhtlog_mysql_dump_load.c +++ b/src/dht/plugin_dhtlog_mysql_dump_load.c @@ -139,6 +139,8 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU * Inserts the specified trial into the dhttests.trials table * * @param trialuid return the trialuid of the newly inserted trial + * @param other_identifier identifier for the trial from another source + * (for joining later) * @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 @@ -165,7 +167,7 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, const struct GNU * * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ -int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned int topology, +int add_trial (unsigned long long *trialuid, unsigned int other_identifier, 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, @@ -183,7 +185,7 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in 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, " @@ -191,8 +193,8 @@ int add_trial (unsigned long long *trialuid, unsigned int num_nodes, unsigned in "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, + "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(), other_identifier, num_nodes, topology, blacklist_topology, connect_topology, connect_topology_option, connect_topology_option_modifier, topology_percentage, topology_probability,