[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34252 - gnunet/src/sensor
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34252 - gnunet/src/sensor |
Date: |
Mon, 1 Sep 2014 14:18:59 +0200 |
Author: otarabai
Date: 2014-09-01 14:18:58 +0200 (Mon, 01 Sep 2014)
New Revision: 34252
Modified:
gnunet/src/sensor/gnunet-sensor-profiler.c
gnunet/src/sensor/gnunet-sensor-profiler.conf
Log:
sensor: profiler reads topology from file
Modified: gnunet/src/sensor/gnunet-sensor-profiler.c
===================================================================
--- gnunet/src/sensor/gnunet-sensor-profiler.c 2014-09-01 09:08:41 UTC (rev
34251)
+++ gnunet/src/sensor/gnunet-sensor-profiler.c 2014-09-01 12:18:58 UTC (rev
34252)
@@ -90,6 +90,11 @@
static unsigned int sensors_interval = 0;
/**
+ * Path to topology file (Option -t)
+ */
+static char *topology_file;
+
+/**
* Array of peer info for all peers
*/
static struct PeerInfo *all_peers_info;
@@ -187,8 +192,6 @@
GNUNET_asprintf (&dst, "%s%s%s", dst_dir, DIR_SEPARATOR_STR,
GNUNET_STRINGS_get_short_name (filename));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Copying `%s' to `%s'.\n", filename,
- dst);
if (GNUNET_YES == GNUNET_DISK_directory_test (filename, GNUNET_YES))
copy_result = copy_dir (filename, dst);
else
@@ -212,8 +215,6 @@
static int
copy_dir (const char *src, const char *dst)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Copying directory `%s' to `%s'.\n",
src,
- dst);
if (GNUNET_YES != GNUNET_DISK_directory_test (src, GNUNET_YES))
return GNUNET_SYSERR;
if (GNUNET_OK != GNUNET_DISK_directory_create (dst))
@@ -249,9 +250,8 @@
}
else
{
- sensor_name = GNUNET_strdup(file_basename);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Saving sensor name `%s'.\n",
sensor_name);
- GNUNET_array_append(sensor_names, sensor_names_size, sensor_name);
+ sensor_name = GNUNET_strdup (file_basename);
+ GNUNET_array_append (sensor_names, sensor_names_size, sensor_name);
sensor_cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_parse (sensor_cfg, filename));
@@ -322,7 +322,7 @@
*/
static int
peerstore_watch_cb (void *cls, struct GNUNET_PEERSTORE_Record *record,
- char *emsg)
+ char *emsg)
{
struct PeerInfo *peer = cls;
struct GNUNET_SENSOR_DashboardAnomalyEntry *anomaly;
@@ -337,14 +337,11 @@
anomaly = record->value;
GNUNET_assert (0 ==
GNUNET_CRYPTO_cmp_peer_identity (&peer->peer_id,
- record->peer));
- printf ("Anomaly report:\n"
- " Peer: `%s'\n"
- " Sensor: `%s'\n"
- " Anomalous: `%d'\n"
- " Anomalous neighbors: %f.\n\n",
- GNUNET_i2s (&peer->peer_id),
- record->key, anomaly->anomalous, anomaly->anomalous_neighbors);
+ record->peer));
+ printf ("Anomaly report:\n" " Peer: `%s'\n" " Sensor: `%s'\n"
+ " Anomalous: `%d'\n" " Anomalous neighbors: %f.\n\n",
+ GNUNET_i2s (&peer->peer_id), record->key, anomaly->anomalous,
+ anomaly->anomalous_neighbors);
return GNUNET_YES;
}
@@ -378,8 +375,9 @@
peer = &all_peers_info[i];
for (j = 0; j < sensor_names_size; j++)
{
- GNUNET_PEERSTORE_watch (peerstore, "sensordashboard-anomalies",
&peer->peer_id,
- sensor_names[j], &peerstore_watch_cb, peer);
+ GNUNET_PEERSTORE_watch (peerstore, "sensordashboard-anomalies",
+ &peer->peer_id, sensor_names[j],
+ &peerstore_watch_cb, peer);
}
}
}
@@ -441,7 +439,9 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sensor service started on peer
`%s'.\n",
GNUNET_i2s (&peer->peer_id));
GNUNET_TESTBED_operation_done (op);
- sensor_services_started ++;
+ sensor_services_started++;
+ if (sensor_services_started == num_peers) //TODO: remove
+ do_shutdown ();
//TODO
}
@@ -548,6 +548,13 @@
("Invalid or missing number of peers. Set at least 3
peers.\n"));
return GNUNET_SYSERR;
}
+ if (NULL == topology_file ||
+ GNUNET_YES != GNUNET_DISK_file_test (topology_file))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Missing or invalid topology file.\n"));
+ return GNUNET_SYSERR;
+ }
return GNUNET_OK;
}
@@ -565,7 +572,6 @@
const struct GNUNET_CONFIGURATION_Handle *c)
{
struct GNUNET_CONFIGURATION_Handle *cfg;
- double links;
if (GNUNET_OK != verify_args ())
{
@@ -574,10 +580,10 @@
}
cfg = GNUNET_CONFIGURATION_create ();
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, cfg_filename));
- links = log (num_peers) * log (num_peers) * num_peers / 2;
- GNUNET_CONFIGURATION_set_value_number ((struct GNUNET_CONFIGURATION_Handle *)
- cfg, "TESTBED",
"OVERLAY_RANDOM_LINKS",
- (unsigned long long int) links);
+ GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle *)
+ cfg, "TESTBED",
+ "OVERLAY_TOPOLOGY_FILE",
+ topology_file);
GNUNET_TESTBED_run (NULL, cfg, num_peers, 0, NULL, NULL, &test_master, NULL);
GNUNET_CONFIGURATION_destroy (cfg);
}
@@ -594,6 +600,8 @@
static struct GNUNET_GETOPT_CommandLineOption options[] = {
{'p', "peers", "COUNT", gettext_noop ("Number of peers to run"),
GNUNET_YES,
&GNUNET_GETOPT_set_uint, &num_peers},
+ {'t', "topology-file", "FILEPATH", gettext_noop ("Path to topology file"),
+ GNUNET_YES, &GNUNET_GETOPT_set_filename, &topology_file},
{'i', "sensors-interval", "INTERVAL",
gettext_noop ("Change the interval or running sensors to given value"),
GNUNET_YES, &GNUNET_GETOPT_set_uint, &sensors_interval},
Modified: gnunet/src/sensor/gnunet-sensor-profiler.conf
===================================================================
--- gnunet/src/sensor/gnunet-sensor-profiler.conf 2014-09-01 09:08:41 UTC
(rev 34251)
+++ gnunet/src/sensor/gnunet-sensor-profiler.conf 2014-09-01 12:18:58 UTC
(rev 34252)
@@ -1,6 +1,5 @@
[testbed]
-OVERLAY_TOPOLOGY = RANDOM
-#OVERLAY_RANDOM_LINKS = 1000
+OVERLAY_TOPOLOGY = FROM_FILE
[arm]
DEFAULTSERVICES = topology dht cadet
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34252 - gnunet/src/sensor,
gnunet <=