diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-05-27 15:09:30 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-05-27 15:09:30 +0000 |
commit | 547cc56fa3676c125430b317be820a4f82b0842d (patch) | |
tree | 4c55aeab6b4fcb700b0831f8a64b571573ee58b8 | |
parent | eb697b546071ec7e18f31f28f135a9b397c345ec (diff) | |
download | gnunet-547cc56fa3676c125430b317be820a4f82b0842d.tar.gz gnunet-547cc56fa3676c125430b317be820a4f82b0842d.zip |
experimentation timing
-rw-r--r-- | src/experimentation/gnunet-daemon-experimentation.h | 23 | ||||
-rw-r--r-- | src/experimentation/gnunet-daemon-experimentation_experiments.c | 151 |
2 files changed, 137 insertions, 37 deletions
diff --git a/src/experimentation/gnunet-daemon-experimentation.h b/src/experimentation/gnunet-daemon-experimentation.h index a8bfc3523..d61b61251 100644 --- a/src/experimentation/gnunet-daemon-experimentation.h +++ b/src/experimentation/gnunet-daemon-experimentation.h | |||
@@ -36,6 +36,15 @@ | |||
36 | */ | 36 | */ |
37 | #define EXP_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 37 | #define EXP_RESPONSE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) |
38 | 38 | ||
39 | /** | ||
40 | * Default experiment frequency | ||
41 | */ | ||
42 | #define EXP_DEFAULT_EXP_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | ||
43 | |||
44 | /** | ||
45 | * Default experiment duration | ||
46 | */ | ||
47 | #define EXP_DEFAULT_EXP_DUR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) | ||
39 | 48 | ||
40 | /** | 49 | /** |
41 | * Statistics handle shared between components | 50 | * Statistics handle shared between components |
@@ -195,6 +204,20 @@ GNUNET_EXPERIMENTATION_experiments_stop (); | |||
195 | 204 | ||
196 | 205 | ||
197 | /** | 206 | /** |
207 | * Start the scheduler component | ||
208 | */ | ||
209 | void | ||
210 | GNUNET_EXPERIMENTATION_scheduler_start (); | ||
211 | |||
212 | |||
213 | /** | ||
214 | * Stop the scheduler component | ||
215 | */ | ||
216 | void | ||
217 | GNUNET_EXPERIMENTATION_scheduler_stop (); | ||
218 | |||
219 | |||
220 | /** | ||
198 | * Start the storage component | 221 | * Start the storage component |
199 | */ | 222 | */ |
200 | void | 223 | void |
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c index 046e85a98..300b37d28 100644 --- a/src/experimentation/gnunet-daemon-experimentation_experiments.c +++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c | |||
@@ -38,6 +38,7 @@ | |||
38 | struct Experiment | 38 | struct Experiment |
39 | { | 39 | { |
40 | /* Header */ | 40 | /* Header */ |
41 | /* ----------------- */ | ||
41 | char *name; | 42 | char *name; |
42 | 43 | ||
43 | /* Experiment issuer */ | 44 | /* Experiment issuer */ |
@@ -52,7 +53,24 @@ struct Experiment | |||
52 | /* Required capabilities */ | 53 | /* Required capabilities */ |
53 | uint32_t required_capabilities; | 54 | uint32_t required_capabilities; |
54 | 55 | ||
56 | /* Experiment timing */ | ||
57 | /* ----------------- */ | ||
58 | |||
59 | /* When to start experiment */ | ||
60 | struct GNUNET_TIME_Absolute start; | ||
61 | |||
62 | /* When to end experiment */ | ||
63 | struct GNUNET_TIME_Absolute stop; | ||
64 | |||
65 | /* How often to run experiment */ | ||
66 | struct GNUNET_TIME_Relative frequency; | ||
67 | |||
68 | /* How long to run each execution */ | ||
69 | struct GNUNET_TIME_Relative duration; | ||
70 | |||
71 | |||
55 | /* Experiment itself */ | 72 | /* Experiment itself */ |
73 | /* ----------------- */ | ||
56 | 74 | ||
57 | /* TBD */ | 75 | /* TBD */ |
58 | }; | 76 | }; |
@@ -144,90 +162,149 @@ GNUNET_EXPERIMENTATION_experiments_issuer_accepted (struct GNUNET_PeerIdentity * | |||
144 | 162 | ||
145 | 163 | ||
146 | /** | 164 | /** |
165 | * Add a new experiment | ||
166 | */ | ||
167 | int GNUNET_EXPERIMENTATION_experiments_add (struct Issuer *i, | ||
168 | const char *name, | ||
169 | struct GNUNET_PeerIdentity issuer_id, | ||
170 | struct GNUNET_TIME_Absolute version, | ||
171 | char *description, | ||
172 | uint32_t required_capabilities, | ||
173 | struct GNUNET_TIME_Absolute start, | ||
174 | struct GNUNET_TIME_Relative frequency, | ||
175 | struct GNUNET_TIME_Relative duration, | ||
176 | struct GNUNET_TIME_Absolute stop) | ||
177 | { | ||
178 | struct Experiment *e; | ||
179 | e = GNUNET_malloc (sizeof (struct Experiment)); | ||
180 | |||
181 | e->name = GNUNET_strdup (name); | ||
182 | e->issuer = issuer_id; | ||
183 | e->version = version; | ||
184 | if (NULL != description) | ||
185 | e->description = GNUNET_strdup (description); | ||
186 | e->required_capabilities = required_capabilities; | ||
187 | e->start = start; | ||
188 | e->frequency = frequency; | ||
189 | e->duration = duration; | ||
190 | e->stop = stop; | ||
191 | |||
192 | |||
193 | |||
194 | /* verify experiment */ | ||
195 | if (GNUNET_SYSERR == experiment_verify (i, e)) | ||
196 | { | ||
197 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Experiment signature is invalid\n"), name); | ||
198 | GNUNET_free (e); | ||
199 | GNUNET_free_non_null (e->name); | ||
200 | GNUNET_free_non_null (e->description); | ||
201 | return GNUNET_SYSERR; | ||
202 | } | ||
203 | |||
204 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Adding experiment `%s' running from `%s' to `%s' every %llu sec. for %llu sec. \n"), | ||
205 | e->name, | ||
206 | GNUNET_STRINGS_absolute_time_to_string (start), | ||
207 | GNUNET_STRINGS_absolute_time_to_string (stop), | ||
208 | (long long unsigned int) frequency.rel_value / 1000, | ||
209 | (long long unsigned int) duration.rel_value / 1000); | ||
210 | GNUNET_CONTAINER_multihashmap_put (experiments, &e->issuer.hashPubKey, e, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
211 | GNUNET_STATISTICS_set (GSE_stats, "# experiments", GNUNET_CONTAINER_multihashmap_size (experiments), GNUNET_NO); | ||
212 | |||
213 | return GNUNET_OK; | ||
214 | } | ||
215 | |||
216 | |||
217 | /** | ||
147 | * Parse a configuration section containing experiments | 218 | * Parse a configuration section containing experiments |
148 | * | 219 | * |
149 | * @param cls configuration handle | 220 | * @param cls configuration handle |
150 | * @param section section name | 221 | * @param section section name |
151 | */ | 222 | */ |
152 | void exp_file_iterator (void *cls, | 223 | void exp_file_iterator (void *cls, |
153 | const char *section) | 224 | const char *name) |
154 | { | 225 | { |
155 | struct GNUNET_CONFIGURATION_Handle *exp = cls; | 226 | struct GNUNET_CONFIGURATION_Handle *exp = cls; |
156 | struct Experiment *e; | ||
157 | struct Issuer *i; | 227 | struct Issuer *i; |
158 | 228 | ||
159 | char *val; | 229 | char *val; |
160 | unsigned long long number; | 230 | unsigned long long number; |
161 | 231 | ||
162 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Parsing section `%s'\n", section); | 232 | /* Experiment values */ |
233 | struct GNUNET_PeerIdentity issuer; | ||
234 | struct GNUNET_TIME_Absolute version; | ||
235 | char *description; | ||
236 | uint32_t required_capabilities; | ||
237 | struct GNUNET_TIME_Absolute start ; | ||
238 | struct GNUNET_TIME_Absolute stop; | ||
239 | struct GNUNET_TIME_Relative frequency; | ||
240 | struct GNUNET_TIME_Relative duration; | ||
241 | |||
242 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Parsing section `%s'\n", name); | ||
163 | 243 | ||
164 | e = GNUNET_malloc (sizeof (struct Experiment)); | ||
165 | /* Mandatory fields */ | 244 | /* Mandatory fields */ |
166 | 245 | ||
167 | /* Issuer */ | 246 | /* Issuer */ |
168 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (exp, section, "ISSUER", &val)) | 247 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (exp, name, "ISSUER", &val)) |
169 | { | 248 | { |
170 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer missing\n"), section); | 249 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer missing\n"), name); |
171 | GNUNET_free (e); | ||
172 | return; | 250 | return; |
173 | } | 251 | } |
174 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (val, &e->issuer.hashPubKey)) | 252 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string (val, &issuer.hashPubKey)) |
175 | { | 253 | { |
176 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer invalid\n"), section); | 254 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer invalid\n"), name); |
177 | GNUNET_free (val); | 255 | GNUNET_free (val); |
178 | GNUNET_free (e); | ||
179 | return; | 256 | return; |
180 | } | 257 | } |
181 | if (NULL == (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &e->issuer.hashPubKey))) | 258 | if (NULL == (i = GNUNET_CONTAINER_multihashmap_get (valid_issuers, &issuer.hashPubKey))) |
182 | { | 259 | { |
183 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer not accepted!\n"), section); | 260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Issuer not accepted!\n"), name); |
184 | GNUNET_free (val); | 261 | GNUNET_free (val); |
185 | GNUNET_free (e); | ||
186 | return; | 262 | return; |
187 | } | 263 | } |
188 | GNUNET_free (val); | 264 | GNUNET_free (val); |
189 | 265 | ||
190 | /* Version */ | 266 | /* Version */ |
191 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, section, "VERSION", &number)) | 267 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "VERSION", &number)) |
192 | { | 268 | { |
193 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Version missing or invalid \n"), section); | 269 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Version missing or invalid \n"), name); |
194 | GNUNET_free (e); | ||
195 | return; | 270 | return; |
196 | } | 271 | } |
197 | e->version.abs_value = number; | 272 | version.abs_value = number; |
198 | 273 | ||
199 | /* Required capabilities */ | 274 | /* Required capabilities */ |
200 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, section, "CAPABILITIES", &number)) | 275 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "CAPABILITIES", &number)) |
201 | { | 276 | { |
202 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Required capabilities missing \n"), section); | 277 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Required capabilities missing \n"), name); |
203 | GNUNET_free (e); | ||
204 | return; | 278 | return; |
205 | } | 279 | } |
206 | if (number > UINT32_MAX) | 280 | if (number > UINT32_MAX) |
207 | { | 281 | { |
208 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Required capabilities invalid \n"), section); | 282 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Required capabilities invalid \n"), name); |
209 | GNUNET_free (e); | ||
210 | return; | 283 | return; |
211 | } | 284 | } |
212 | e->required_capabilities = number; | 285 | required_capabilities = number; |
213 | e->name = GNUNET_strdup (section); | ||
214 | 286 | ||
215 | /* Optional fields */ | 287 | /* Optional fields */ |
288 | |||
216 | /* Description */ | 289 | /* Description */ |
217 | GNUNET_CONFIGURATION_get_value_string (exp, section, "DESCRIPTION", &e->description); | 290 | GNUNET_CONFIGURATION_get_value_string (exp, name, "DESCRIPTION", &description); |
218 | 291 | ||
219 | /* verify experiment */ | 292 | |
220 | if (GNUNET_SYSERR == experiment_verify (i, e)) | 293 | |
221 | { | 294 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "START", (long long unsigned int *) &start.abs_value)) |
222 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Experiment `%s': Experiment signature is invalid\n"), section); | 295 | start = GNUNET_TIME_UNIT_ZERO_ABS; |
223 | GNUNET_free (e); | 296 | |
224 | GNUNET_free_non_null (e->name); | 297 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (exp, name, "FREQUENCY", &frequency)) |
225 | GNUNET_free_non_null (e->description); | 298 | frequency = EXP_DEFAULT_EXP_FREQ; |
226 | return; | 299 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (exp, name, "DURATION", &duration)) |
227 | } | 300 | duration = EXP_DEFAULT_EXP_DUR; |
228 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Adding experiment `%s'\n"), e->name); | 301 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (exp, name, "STOP", (long long unsigned int *)&stop.abs_value)) |
229 | GNUNET_CONTAINER_multihashmap_put (experiments, &e->issuer.hashPubKey, e, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 302 | stop = GNUNET_TIME_UNIT_FOREVER_ABS; |
230 | GNUNET_STATISTICS_set (GSE_stats, "# experiments", GNUNET_CONTAINER_multihashmap_size (experiments), GNUNET_NO); | 303 | |
304 | GNUNET_EXPERIMENTATION_experiments_add (i, name, issuer, version, | ||
305 | description, required_capabilities, | ||
306 | start, frequency, duration, stop); | ||
307 | GNUNET_free_non_null (description); | ||
231 | } | 308 | } |
232 | 309 | ||
233 | 310 | ||