aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-11-06 18:16:56 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-11-06 18:16:56 +0000
commit443873668be6734af6924066511bfa710637da08 (patch)
tree54f18f8d2d55d7d73a922abdbecca7b725579b70
parentc4f0fe86c25a22369bed82ce0259389df9e9d39b (diff)
downloadgnunet-443873668be6734af6924066511bfa710637da08.tar.gz
gnunet-443873668be6734af6924066511bfa710637da08.zip
Added regex prefix to config for regex profiler.
-rw-r--r--contrib/regex_profiler_infiniband.conf16
-rw-r--r--src/mesh/gnunet-regex-profiler.c52
-rw-r--r--src/mesh/gnunet-service-regexprofiler.c23
3 files changed, 76 insertions, 15 deletions
diff --git a/contrib/regex_profiler_infiniband.conf b/contrib/regex_profiler_infiniband.conf
index f5547328d..5996582e2 100644
--- a/contrib/regex_profiler_infiniband.conf
+++ b/contrib/regex_profiler_infiniband.conf
@@ -11,15 +11,17 @@ MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 50
11[regexprofiler] 11[regexprofiler]
12AUTOSTART = YES 12AUTOSTART = YES
13PORT = 12000 13PORT = 12000
14BINARY = /home/szengel/gnunet/src/mesh/gnunet-service-regexprofiler 14BINARY = /home/szengel/gnunet/src/mesh/.libs/gnunet-service-regexprofiler
15REGEX_PREFIX = "GNVPN-0001-PADP"
15 16
16[mesh] 17[mesh]
17AUTOSTART = YES 18AUTOSTART = YES
18ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24; 19ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24;
19APP_ANNOUNCE_TIME = 10 s 20APP_ANNOUNCE_TIME = 30 s
20ID_ANNOUNCE_TIME = 10 s 21ID_ANNOUNCE_TIME = 30 s
21CONNECT_TIMEOUT = 10 m 22CONNECT_TIMEOUT = 30 s
22PORT = 12001 23PORT = 12001
24DHT_REPLICATION_LEVEL = 10
23 25
24[dht] 26[dht]
25AUTOSTART = YES 27AUTOSTART = YES
@@ -28,6 +30,10 @@ PORT = 12002
28HOSTNAME = localhost 30HOSTNAME = localhost
29DISABLE_TRY_CONNECT = YES 31DISABLE_TRY_CONNECT = YES
30 32
33[dhtcache]
34DATABASE = sqlite
35QUOTA = 10 MB
36
31[arm] 37[arm]
32DEFAULTSERVICES = core mesh dht statistics regexprofiler 38DEFAULTSERVICES = core mesh dht statistics regexprofiler
33PORT = 12003 39PORT = 12003
@@ -43,7 +49,7 @@ plugins = dht mesh
43 49
44[transport] 50[transport]
45AUTOSTART = YES 51AUTOSTART = YES
46PLUGINS = udp 52PLUGINS = tcp
47ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24; 53ACCEPT_FROM = 127.0.0.1; 192.168.1.0/24;
48ACCEPT_FROM6 = ::1; 54ACCEPT_FROM6 = ::1;
49NEIGHBOUR_LIMIT = 50 55NEIGHBOUR_LIMIT = 50
diff --git a/src/mesh/gnunet-regex-profiler.c b/src/mesh/gnunet-regex-profiler.c
index 1157149e3..6b3566823 100644
--- a/src/mesh/gnunet-regex-profiler.c
+++ b/src/mesh/gnunet-regex-profiler.c
@@ -362,6 +362,20 @@ static char *data_filename;
362 */ 362 */
363static unsigned int max_path_compression; 363static unsigned int max_path_compression;
364 364
365/**
366 * If we should distribute the search evenly throught all peers (each
367 * peer searches for a string) or if only one peer should search for
368 * all strings.
369 */
370static int no_distributed_search;
371
372/**
373 * Prefix used for regex announcing. We need to prefix the search
374 * strings with it, in order to find something.
375 */
376static char * regex_prefix;
377
378
365/******************************************************************************/ 379/******************************************************************************/
366/****************************** DECLARATIONS ********************************/ 380/****************************** DECLARATIONS ********************************/
367/******************************************************************************/ 381/******************************************************************************/
@@ -641,6 +655,8 @@ stats_cb (void *cls,
641 return; 655 return;
642 } 656 }
643 657
658 GNUNET_assert (NULL != peer->stats_op_handle);
659
644 GNUNET_TESTBED_operation_done (peer->stats_op_handle); 660 GNUNET_TESTBED_operation_done (peer->stats_op_handle);
645 peer->stats_op_handle = NULL; 661 peer->stats_op_handle = NULL;
646 662
@@ -815,9 +831,6 @@ mesh_peer_connect_handler (void *cls,
815 } 831 }
816 } 832 }
817 833
818 GNUNET_TESTBED_operation_done (peer->mesh_op_handle);
819 peer->mesh_op_handle = NULL;
820
821 peer->stats_op_handle = 834 peer->stats_op_handle =
822 GNUNET_TESTBED_service_connect (NULL, 835 GNUNET_TESTBED_service_connect (NULL,
823 peer->peer_handle, 836 peer->peer_handle,
@@ -828,6 +841,9 @@ mesh_peer_connect_handler (void *cls,
828 &stats_da, 841 &stats_da,
829 peer); 842 peer);
830 843
844 GNUNET_TESTBED_operation_done (peer->mesh_op_handle);
845 peer->mesh_op_handle = NULL;
846
831 if (peers_found == num_search_strings) 847 if (peers_found == num_search_strings)
832 { 848 {
833 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time); 849 prof_time = GNUNET_TIME_absolute_get_duration (prof_start_time);
@@ -860,6 +876,10 @@ do_connect_by_string_timeout (void *cls,
860 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 876 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
861 "Found %i of %i strings\n", peers_found, num_search_strings); 877 "Found %i of %i strings\n", peers_found, num_search_strings);
862 878
879 printf ("Search timed out after %s. Shutting down.\n",
880 GNUNET_STRINGS_relative_time_to_string (search_timeout, GNUNET_NO));
881 fflush (stdout);
882
863 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 883 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
864} 884}
865 885
@@ -917,9 +937,9 @@ static void
917mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, 937mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
918 void *ca_result, const char *emsg) 938 void *ca_result, const char *emsg)
919{ 939{
940 struct RegexPeer *peer = (struct RegexPeer *) cls;
920 static unsigned int peer_cnt; 941 static unsigned int peer_cnt;
921 unsigned int next_p; 942 unsigned int next_p;
922 struct RegexPeer *peer = (struct RegexPeer *) cls;
923 943
924 if (NULL != emsg || NULL == op || NULL == ca_result) 944 if (NULL != emsg || NULL == op || NULL == ca_result)
925 { 945 {
@@ -944,9 +964,12 @@ mesh_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
944 GNUNET_MESH_peer_request_connect_by_string (peer->mesh_tunnel_handle, 964 GNUNET_MESH_peer_request_connect_by_string (peer->mesh_tunnel_handle,
945 peer->search_str); 965 peer->search_str);
946 966
947 if (peer_cnt < num_search_strings) 967 if (peer_cnt < (num_search_strings - 1))
948 { 968 {
949 next_p = ((++peer_cnt) % num_peers); 969 if (GNUNET_YES == no_distributed_search)
970 next_p = 0;
971 else
972 next_p = (++peer_cnt % num_peers);
950 973
951 peers[next_p].search_str = search_strings[next_p]; 974 peers[next_p].search_str = search_strings[next_p];
952 peers[next_p].search_str_matched = GNUNET_NO; 975 peers[next_p].search_str_matched = GNUNET_NO;
@@ -1607,8 +1630,8 @@ load_search_strings (const char *filename, char ***strings, unsigned int limit)
1607 offset = 0; 1630 offset = 0;
1608 for (i = 0; i < str_cnt; i++) 1631 for (i = 0; i < str_cnt; i++)
1609 { 1632 {
1610 (*strings)[i] = GNUNET_strdup (&data[offset]); 1633 GNUNET_asprintf (&(*strings)[i], "%s%s", regex_prefix, &data[offset]);
1611 offset += strlen ((*strings)[i]) + 1; 1634 offset += strlen (&data[offset]) + 1;
1612 } 1635 }
1613 free (data); 1636 free (data);
1614 return str_cnt; 1637 return str_cnt;
@@ -1667,6 +1690,16 @@ run (void *cls, char *const *args, const char *cfgfile,
1667 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 1690 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1668 return; 1691 return;
1669 } 1692 }
1693
1694 if (GNUNET_OK !=
1695 GNUNET_CONFIGURATION_get_value_string (config, "REGEXPROFILER", "REGEX_PREFIX",
1696 &regex_prefix))
1697 {
1698 fprintf (stderr, _("Configuration option (regex_prefix) missing. Exiting\n"));
1699 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
1700 return;
1701 }
1702
1670 if ( (NULL != data_filename) && 1703 if ( (NULL != data_filename) &&
1671 (NULL == (data_file = 1704 (NULL == (data_file =
1672 GNUNET_DISK_file_open (data_filename, 1705 GNUNET_DISK_file_open (data_filename,
@@ -1752,6 +1785,9 @@ main (int argc, char *const *argv)
1752 {'p', "max-path-compression", "MAX_PATH_COMPRESSION", 1785 {'p', "max-path-compression", "MAX_PATH_COMPRESSION",
1753 gettext_noop ("maximum path compression length"), 1786 gettext_noop ("maximum path compression length"),
1754 1, &GNUNET_GETOPT_set_uint, &max_path_compression}, 1787 1, &GNUNET_GETOPT_set_uint, &max_path_compression},
1788 {'i', "no-distributed-search", "",
1789 gettext_noop ("if this option is set, only one peer is responsible for searching all strings"),
1790 0, &GNUNET_GETOPT_set_one, &no_distributed_search},
1755 GNUNET_GETOPT_OPTION_END 1791 GNUNET_GETOPT_OPTION_END
1756 }; 1792 };
1757 int ret; 1793 int ret;
diff --git a/src/mesh/gnunet-service-regexprofiler.c b/src/mesh/gnunet-service-regexprofiler.c
index b155cb783..f794e236d 100644
--- a/src/mesh/gnunet-service-regexprofiler.c
+++ b/src/mesh/gnunet-service-regexprofiler.c
@@ -66,6 +66,11 @@ static unsigned long long max_path_compression;
66 */ 66 */
67static char * policy_filename; 67static char * policy_filename;
68 68
69/**
70 * Prefix to add before every regex we're announcing.
71 */
72static char * regex_prefix;
73
69 74
70/** 75/**
71 * Task run during shutdown. 76 * Task run during shutdown.
@@ -166,6 +171,19 @@ run (void *cls,
166 return; 171 return;
167 } 172 }
168 173
174 if (GNUNET_OK !=
175 GNUNET_CONFIGURATION_get_value_string (cfg, "REGEXPROFILER", "REGEX_PREFIX",
176 &regex_prefix))
177 {
178 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
179 _
180 ("%s service is lacking key configuration settings (%s). Exiting.\n"),
181 "regexprofiler", "regex_prefix");
182 global_ret = GNUNET_SYSERR;
183 GNUNET_SCHEDULER_shutdown ();
184 return;
185 }
186
169 stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg); 187 stats_handle = GNUNET_STATISTICS_create ("regexprofiler", cfg);
170 188
171 app = (GNUNET_MESH_ApplicationType)0; 189 app = (GNUNET_MESH_ApplicationType)0;
@@ -212,9 +230,10 @@ run (void *cls,
212 if (((data[offset] == '\n')) && (buf != &data[offset])) 230 if (((data[offset] == '\n')) && (buf != &data[offset]))
213 { 231 {
214 data[offset] = '\0'; 232 data[offset] = '\0';
215 regex = buf; 233 GNUNET_assert (NULL != buf);
216 GNUNET_assert (NULL != regex); 234 GNUNET_asprintf (&regex, "%s%s", regex_prefix, buf);
217 announce_regex (regex); 235 announce_regex (regex);
236 GNUNET_free (regex);
218 buf = &data[offset + 1]; 237 buf = &data[offset + 1];
219 } 238 }
220 else if ((data[offset] == '\n') || (data[offset] == '\0')) 239 else if ((data[offset] == '\n') || (data[offset] == '\0'))