aboutsummaryrefslogtreecommitdiff
path: root/src/datastore/perf_plugin_datastore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datastore/perf_plugin_datastore.c')
-rw-r--r--src/datastore/perf_plugin_datastore.c587
1 files changed, 302 insertions, 285 deletions
diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c
index a051f27ca..a1604d441 100644
--- a/src/datastore/perf_plugin_datastore.c
+++ b/src/datastore/perf_plugin_datastore.c
@@ -59,7 +59,8 @@ static const char *plugin_name;
59 59
60static int ok; 60static int ok;
61 61
62enum RunPhase { 62enum RunPhase
63{
63 RP_ERROR = 0, 64 RP_ERROR = 0,
64 RP_PUT, 65 RP_PUT,
65 RP_REP_GET, 66 RP_REP_GET,
@@ -69,7 +70,8 @@ enum RunPhase {
69}; 70};
70 71
71 72
72struct CpsRunContext { 73struct CpsRunContext
74{
73 unsigned int i; 75 unsigned int i;
74 struct GNUNET_TIME_Absolute start; 76 struct GNUNET_TIME_Absolute start;
75 struct GNUNET_TIME_Absolute end; 77 struct GNUNET_TIME_Absolute end;
@@ -91,13 +93,13 @@ struct CpsRunContext {
91 * 0 for "reset to empty" 93 * 0 for "reset to empty"
92 */ 94 */
93static void 95static void
94disk_utilization_change_cb(void *cls, int delta) 96disk_utilization_change_cb (void *cls, int delta)
95{ 97{
96} 98}
97 99
98 100
99static void 101static void
100test(void *cls); 102test (void *cls);
101 103
102 104
103/** 105/**
@@ -110,30 +112,30 @@ test(void *cls);
110 * @param msg error message on error 112 * @param msg error message on error
111 */ 113 */
112static void 114static void
113put_continuation(void *cls, 115put_continuation (void *cls,
114 const struct GNUNET_HashCode *key, 116 const struct GNUNET_HashCode *key,
115 uint32_t size, 117 uint32_t size,
116 int status, 118 int status,
117 const char *msg) 119 const char *msg)
118{ 120{
119 struct CpsRunContext *crc = cls; 121 struct CpsRunContext *crc = cls;
120 122
121 if (GNUNET_OK != status) 123 if (GNUNET_OK != status)
122 { 124 {
123 fprintf(stderr, "ERROR: `%s'\n", msg); 125 fprintf (stderr, "ERROR: `%s'\n", msg);
124 } 126 }
125 else 127 else
126 { 128 {
127 stored_bytes += size; 129 stored_bytes += size;
128 stored_ops++; 130 stored_ops++;
129 stored_entries++; 131 stored_entries++;
130 } 132 }
131 GNUNET_SCHEDULER_add_now(&test, crc); 133 GNUNET_SCHEDULER_add_now (&test, crc);
132} 134}
133 135
134 136
135static void 137static void
136do_put(struct CpsRunContext *crc) 138do_put (struct CpsRunContext *crc)
137{ 139{
138 char value[65536]; 140 char value[65536];
139 size_t size; 141 size_t size;
@@ -142,123 +144,69 @@ do_put(struct CpsRunContext *crc)
142 unsigned int prio; 144 unsigned int prio;
143 145
144 if (0 == i) 146 if (0 == i)
145 crc->start = GNUNET_TIME_absolute_get(); 147 crc->start = GNUNET_TIME_absolute_get ();
146 if (PUT_10 == i) 148 if (PUT_10 == i)
149 {
150 i = 0;
151 crc->end = GNUNET_TIME_absolute_get ();
147 { 152 {
148 i = 0; 153 printf ("%s took %s for %llu items\n", "Storing an item",
149 crc->end = GNUNET_TIME_absolute_get(); 154 GNUNET_STRINGS_relative_time_to_string (
150 { 155 GNUNET_TIME_absolute_get_difference (crc->start,
151 printf("%s took %s for %llu items\n", "Storing an item", 156 crc
152 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_difference(crc->start, 157 ->end),
153 crc->end), 158 GNUNET_YES),
154 GNUNET_YES), 159 PUT_10);
155 PUT_10); 160 if (PUT_10 > 0)
156 if (PUT_10 > 0) 161 GAUGER (category, "Storing an item",
157 GAUGER(category, "Storing an item", 162 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL
158 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / PUT_10, 163 / PUT_10,
159 "ms/item"); 164 "ms/item");
160 }
161 crc->i++;
162 crc->start = GNUNET_TIME_absolute_get();
163 crc->phase++;
164 GNUNET_SCHEDULER_add_now(&test, crc);
165 return;
166 } 165 }
166 crc->i++;
167 crc->start = GNUNET_TIME_absolute_get ();
168 crc->phase++;
169 GNUNET_SCHEDULER_add_now (&test, crc);
170 return;
171 }
167 /* most content is 32k */ 172 /* most content is 32k */
168 size = 32 * 1024; 173 size = 32 * 1024;
169 if (GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */ 174 if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 16) == 0) /* but some of it is less! */
170 size = 8 + GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024); 175 size = 8 + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 32 * 1024);
171 size = size - (size & 7); /* always multiple of 8 */ 176 size = size - (size & 7); /* always multiple of 8 */
172 177
173 /* generate random key */ 178 /* generate random key */
174 key.bits[0] = (unsigned int)GNUNET_TIME_absolute_get().abs_value_us; 179 key.bits[0] = (unsigned int) GNUNET_TIME_absolute_get ().abs_value_us;
175 GNUNET_CRYPTO_hash(&key, sizeof(struct GNUNET_HashCode), &key); 180 GNUNET_CRYPTO_hash (&key, sizeof(struct GNUNET_HashCode), &key);
176 memset(value, i, size); 181 memset (value, i, size);
177 if (i > 255) 182 if (i > 255)
178 memset(value, i - 255, size / 2); 183 memset (value, i - 255, size / 2);
179 value[0] = crc->i; 184 value[0] = crc->i;
180 GNUNET_memcpy(&value[4], &i, sizeof(i)); 185 GNUNET_memcpy (&value[4], &i, sizeof(i));
181 prio = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 100); 186 prio = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100);
182 crc->api->put(crc->api->cls, 187 crc->api->put (crc->api->cls,
183 &key, 188 &key,
184 false /* absent */, 189 false /* absent */,
185 size, 190 size,
186 value, 191 value,
187 1 + i % 4 /* type */, 192 1 + i % 4 /* type */,
188 prio, 193 prio,
189 i % 4 /* anonymity */, 194 i % 4 /* anonymity */,
190 0 /* replication */, 195 0 /* replication */,
191 GNUNET_TIME_relative_to_absolute 196 GNUNET_TIME_relative_to_absolute
192 (GNUNET_TIME_relative_multiply 197 (GNUNET_TIME_relative_multiply
193 (GNUNET_TIME_UNIT_MILLISECONDS, 198 (GNUNET_TIME_UNIT_MILLISECONDS,
194 60 * 60 * 60 * 1000 + 199 60 * 60 * 60 * 1000
195 GNUNET_CRYPTO_random_u32 200 + GNUNET_CRYPTO_random_u32
196 (GNUNET_CRYPTO_QUALITY_WEAK, 1000))), 201 (GNUNET_CRYPTO_QUALITY_WEAK, 1000))),
197 put_continuation, 202 put_continuation,
198 crc); 203 crc);
199 i++; 204 i++;
200} 205}
201 206
202 207
203static int 208static int
204iterate_zeros(void *cls, 209iterate_zeros (void *cls,
205 const struct GNUNET_HashCode *key,
206 uint32_t size,
207 const void *data,
208 enum GNUNET_BLOCK_Type type,
209 uint32_t priority,
210 uint32_t anonymity,
211 uint32_t replication,
212 struct GNUNET_TIME_Absolute expiration,
213 uint64_t uid)
214{
215 struct CpsRunContext *crc = cls;
216 int i;
217 const char *cdata = data;
218
219 GNUNET_assert(key != NULL);
220 GNUNET_assert(size >= 8);
221 GNUNET_memcpy(&i, &cdata[4], sizeof(i));
222 hits[i / 8] |= (1 << (i % 8));
223
224 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
225 "Found result %d type=%u, priority=%u, size=%u, expire=%s\n",
226 i,
227 type, priority, size,
228 GNUNET_STRINGS_absolute_time_to_string(expiration));
229 crc->cnt++;
230 if (crc->cnt == PUT_10 / 4 - 1)
231 {
232 unsigned int bc;
233
234 bc = 0;
235 for (i = 0; i < PUT_10; i++)
236 if (0 != (hits[i / 8] & (1 << (i % 8))))
237 bc++;
238
239 crc->end = GNUNET_TIME_absolute_get();
240 printf("%s took %s yielding %u/%u items\n",
241 "Select random zero-anonymity item",
242 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_difference(crc->start,
243 crc->end),
244 GNUNET_YES),
245 bc, crc->cnt);
246 if (crc->cnt > 0)
247 GAUGER(category, "Select random zero-anonymity item",
248 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt,
249 "ms/item");
250 memset(hits, 0, sizeof(hits));
251 crc->phase++;
252 crc->cnt = 0;
253 crc->start = GNUNET_TIME_absolute_get();
254 }
255 GNUNET_SCHEDULER_add_now(&test, crc);
256 return GNUNET_OK;
257}
258
259
260static int
261expiration_get(void *cls,
262 const struct GNUNET_HashCode *key, 210 const struct GNUNET_HashCode *key,
263 uint32_t size, 211 uint32_t size,
264 const void *data, 212 const void *data,
@@ -273,45 +221,52 @@ expiration_get(void *cls,
273 int i; 221 int i;
274 const char *cdata = data; 222 const char *cdata = data;
275 223
276 GNUNET_assert(size >= 8); 224 GNUNET_assert (key != NULL);
277 GNUNET_memcpy(&i, &cdata[4], sizeof(i)); 225 GNUNET_assert (size >= 8);
226 GNUNET_memcpy (&i, &cdata[4], sizeof(i));
278 hits[i / 8] |= (1 << (i % 8)); 227 hits[i / 8] |= (1 << (i % 8));
228
229 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
230 "Found result %d type=%u, priority=%u, size=%u, expire=%s\n",
231 i,
232 type, priority, size,
233 GNUNET_STRINGS_absolute_time_to_string (expiration));
279 crc->cnt++; 234 crc->cnt++;
280 if (PUT_10 <= crc->cnt) 235 if (crc->cnt == PUT_10 / 4 - 1)
281 { 236 {
282 unsigned int bc; 237 unsigned int bc;
283 238
284 bc = 0; 239 bc = 0;
285 for (i = 0; i < PUT_10; i++) 240 for (i = 0; i < PUT_10; i++)
286 if (0 != (hits[i / 8] & (1 << (i % 8)))) 241 if (0 != (hits[i / 8] & (1 << (i % 8))))
287 bc++; 242 bc++;
288 243
289 crc->end = GNUNET_TIME_absolute_get(); 244 crc->end = GNUNET_TIME_absolute_get ();
290 printf("%s took %s yielding %u/%u items\n", 245 printf ("%s took %s yielding %u/%u items\n",
291 "Selecting and deleting by expiration", 246 "Select random zero-anonymity item",
292 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_difference(crc->start, 247 GNUNET_STRINGS_relative_time_to_string (
293 crc->end), 248 GNUNET_TIME_absolute_get_difference (crc->start,
294 GNUNET_YES), 249 crc
295 bc, (unsigned int)PUT_10); 250 ->end),
296 if (crc->cnt > 0) 251 GNUNET_YES),
297 GAUGER(category, "Selecting and deleting by expiration", 252 bc, crc->cnt);
298 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt, 253 if (crc->cnt > 0)
299 "ms/item"); 254 GAUGER (category, "Select random zero-anonymity item",
300 memset(hits, 0, sizeof(hits)); 255 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL
301 if (++crc->iter == ITERATIONS) 256 / crc->cnt,
302 crc->phase++; 257 "ms/item");
303 else 258 memset (hits, 0, sizeof(hits));
304 crc->phase = RP_PUT; 259 crc->phase++;
305 crc->cnt = 0; 260 crc->cnt = 0;
306 crc->start = GNUNET_TIME_absolute_get(); 261 crc->start = GNUNET_TIME_absolute_get ();
307 } 262 }
308 GNUNET_SCHEDULER_add_now(&test, crc); 263 GNUNET_SCHEDULER_add_now (&test, crc);
309 return GNUNET_NO; 264 return GNUNET_OK;
310} 265}
311 266
312 267
313static int 268static int
314replication_get(void *cls, 269expiration_get (void *cls,
315 const struct GNUNET_HashCode *key, 270 const struct GNUNET_HashCode *key,
316 uint32_t size, 271 uint32_t size,
317 const void *data, 272 const void *data,
@@ -326,39 +281,98 @@ replication_get(void *cls,
326 int i; 281 int i;
327 const char *cdata = data; 282 const char *cdata = data;
328 283
329 GNUNET_assert(NULL != key); 284 GNUNET_assert (size >= 8);
330 GNUNET_assert(size >= 8); 285 GNUNET_memcpy (&i, &cdata[4], sizeof(i));
331 GNUNET_memcpy(&i, &cdata[4], sizeof(i));
332 hits[i / 8] |= (1 << (i % 8)); 286 hits[i / 8] |= (1 << (i % 8));
333 crc->cnt++; 287 crc->cnt++;
334 if (PUT_10 <= crc->cnt) 288 if (PUT_10 <= crc->cnt)
335 { 289 {
336 unsigned int bc; 290 unsigned int bc;
337 291
338 bc = 0; 292 bc = 0;
339 for (i = 0; i < PUT_10; i++) 293 for (i = 0; i < PUT_10; i++)
340 if (0 != (hits[i / 8] & (1 << (i % 8)))) 294 if (0 != (hits[i / 8] & (1 << (i % 8))))
341 bc++; 295 bc++;
342 296
343 crc->end = GNUNET_TIME_absolute_get(); 297 crc->end = GNUNET_TIME_absolute_get ();
344 printf("%s took %s yielding %u/%u items\n", 298 printf ("%s took %s yielding %u/%u items\n",
345 "Selecting random item for replication", 299 "Selecting and deleting by expiration",
346 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_difference(crc->start, 300 GNUNET_STRINGS_relative_time_to_string (
347 crc->end), 301 GNUNET_TIME_absolute_get_difference (crc->start,
348 GNUNET_YES), 302 crc
349 bc, (unsigned int)PUT_10); 303 ->end),
350 if (crc->cnt > 0) 304 GNUNET_YES),
351 GAUGER(category, "Selecting random item for replication", 305 bc, (unsigned int) PUT_10);
352 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL / crc->cnt, 306 if (crc->cnt > 0)
353 "ms/item"); 307 GAUGER (category, "Selecting and deleting by expiration",
354 memset(hits, 0, sizeof(hits)); 308 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL
309 / crc->cnt,
310 "ms/item");
311 memset (hits, 0, sizeof(hits));
312 if (++crc->iter == ITERATIONS)
355 crc->phase++; 313 crc->phase++;
356 crc->offset = 0; 314 else
357 crc->cnt = 0; 315 crc->phase = RP_PUT;
358 crc->start = GNUNET_TIME_absolute_get(); 316 crc->cnt = 0;
359 } 317 crc->start = GNUNET_TIME_absolute_get ();
318 }
319 GNUNET_SCHEDULER_add_now (&test, crc);
320 return GNUNET_NO;
321}
322
323
324static int
325replication_get (void *cls,
326 const struct GNUNET_HashCode *key,
327 uint32_t size,
328 const void *data,
329 enum GNUNET_BLOCK_Type type,
330 uint32_t priority,
331 uint32_t anonymity,
332 uint32_t replication,
333 struct GNUNET_TIME_Absolute expiration,
334 uint64_t uid)
335{
336 struct CpsRunContext *crc = cls;
337 int i;
338 const char *cdata = data;
360 339
361 GNUNET_SCHEDULER_add_now(&test, crc); 340 GNUNET_assert (NULL != key);
341 GNUNET_assert (size >= 8);
342 GNUNET_memcpy (&i, &cdata[4], sizeof(i));
343 hits[i / 8] |= (1 << (i % 8));
344 crc->cnt++;
345 if (PUT_10 <= crc->cnt)
346 {
347 unsigned int bc;
348
349 bc = 0;
350 for (i = 0; i < PUT_10; i++)
351 if (0 != (hits[i / 8] & (1 << (i % 8))))
352 bc++;
353
354 crc->end = GNUNET_TIME_absolute_get ();
355 printf ("%s took %s yielding %u/%u items\n",
356 "Selecting random item for replication",
357 GNUNET_STRINGS_relative_time_to_string (
358 GNUNET_TIME_absolute_get_difference (crc->start,
359 crc
360 ->end),
361 GNUNET_YES),
362 bc, (unsigned int) PUT_10);
363 if (crc->cnt > 0)
364 GAUGER (category, "Selecting random item for replication",
365 (crc->end.abs_value_us - crc->start.abs_value_us) / 1000LL
366 / crc->cnt,
367 "ms/item");
368 memset (hits, 0, sizeof(hits));
369 crc->phase++;
370 crc->offset = 0;
371 crc->cnt = 0;
372 crc->start = GNUNET_TIME_absolute_get ();
373 }
374
375 GNUNET_SCHEDULER_add_now (&test, crc);
362 return GNUNET_OK; 376 return GNUNET_OK;
363} 377}
364 378
@@ -371,25 +385,26 @@ replication_get(void *cls,
371 * @param cfg configuration to use 385 * @param cfg configuration to use
372 */ 386 */
373static void 387static void
374unload_plugin(struct GNUNET_DATASTORE_PluginFunctions *api, 388unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api,
375 const struct GNUNET_CONFIGURATION_Handle *cfg) 389 const struct GNUNET_CONFIGURATION_Handle *cfg)
376{ 390{
377 char *name; 391 char *name;
378 char *libname; 392 char *libname;
379 393
380 if (GNUNET_OK != 394 if (GNUNET_OK !=
381 GNUNET_CONFIGURATION_get_value_string(cfg, "DATASTORE", "DATABASE", 395 GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE",
382 &name)) 396 &name))
383 { 397 {
384 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 398 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
385 _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", 399 _ ("No `%s' specified for `%s' in configuration!\n"),
386 "DATASTORE"); 400 "DATABASE",
387 return; 401 "DATASTORE");
388 } 402 return;
389 GNUNET_asprintf(&libname, "libgnunet_plugin_datastore_%s", name); 403 }
390 GNUNET_break(NULL == GNUNET_PLUGIN_unload(libname, api)); 404 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
391 GNUNET_free(libname); 405 GNUNET_break (NULL == GNUNET_PLUGIN_unload (libname, api));
392 GNUNET_free(name); 406 GNUNET_free (libname);
407 GNUNET_free (name);
393} 408}
394 409
395 410
@@ -399,56 +414,56 @@ unload_plugin(struct GNUNET_DATASTORE_PluginFunctions *api,
399 * the transport and core. 414 * the transport and core.
400 */ 415 */
401static void 416static void
402cleaning_task(void *cls) 417cleaning_task (void *cls)
403{ 418{
404 struct CpsRunContext *crc = cls; 419 struct CpsRunContext *crc = cls;
405 420
406 unload_plugin(crc->api, crc->cfg); 421 unload_plugin (crc->api, crc->cfg);
407 GNUNET_free(crc); 422 GNUNET_free (crc);
408} 423}
409 424
410 425
411static void 426static void
412test(void *cls) 427test (void *cls)
413{ 428{
414 struct CpsRunContext *crc = cls; 429 struct CpsRunContext *crc = cls;
415 430
416 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 431 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
417 "In phase %d, iteration %u\n", crc->phase, crc->cnt); 432 "In phase %d, iteration %u\n", crc->phase, crc->cnt);
418 switch (crc->phase) 433 switch (crc->phase)
419 { 434 {
420 case RP_ERROR: 435 case RP_ERROR:
421 GNUNET_break(0); 436 GNUNET_break (0);
422 crc->api->drop(crc->api->cls); 437 crc->api->drop (crc->api->cls);
423 ok = 1; 438 ok = 1;
424 GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_IDLE, 439 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
425 &cleaning_task, crc); 440 &cleaning_task, crc);
426 break; 441 break;
427 442
428 case RP_PUT: 443 case RP_PUT:
429 do_put(crc); 444 do_put (crc);
430 break; 445 break;
431 446
432 case RP_REP_GET: 447 case RP_REP_GET:
433 crc->api->get_replication(crc->api->cls, &replication_get, crc); 448 crc->api->get_replication (crc->api->cls, &replication_get, crc);
434 break; 449 break;
435 450
436 case RP_ZA_GET: 451 case RP_ZA_GET:
437 crc->api->get_zero_anonymity(crc->api->cls, crc->offset++, 1, 452 crc->api->get_zero_anonymity (crc->api->cls, crc->offset++, 1,
438 &iterate_zeros, crc); 453 &iterate_zeros, crc);
439 break; 454 break;
440 455
441 case RP_EXP_GET: 456 case RP_EXP_GET:
442 crc->api->get_expiration(crc->api->cls, &expiration_get, crc); 457 crc->api->get_expiration (crc->api->cls, &expiration_get, crc);
443 break; 458 break;
444 459
445 case RP_DONE: 460 case RP_DONE:
446 crc->api->drop(crc->api->cls); 461 crc->api->drop (crc->api->cls);
447 ok = 0; 462 ok = 0;
448 GNUNET_SCHEDULER_add_with_priority(GNUNET_SCHEDULER_PRIORITY_IDLE, 463 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
449 &cleaning_task, crc); 464 &cleaning_task, crc);
450 break; 465 break;
451 } 466 }
452} 467}
453 468
454 469
@@ -456,7 +471,7 @@ test(void *cls)
456 * Load the datastore plugin. 471 * Load the datastore plugin.
457 */ 472 */
458static struct GNUNET_DATASTORE_PluginFunctions * 473static struct GNUNET_DATASTORE_PluginFunctions *
459load_plugin(const struct GNUNET_CONFIGURATION_Handle *cfg) 474load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
460{ 475{
461 static struct GNUNET_DATASTORE_PluginEnvironment env; 476 static struct GNUNET_DATASTORE_PluginEnvironment env;
462 struct GNUNET_DATASTORE_PluginFunctions *ret; 477 struct GNUNET_DATASTORE_PluginFunctions *ret;
@@ -464,63 +479,65 @@ load_plugin(const struct GNUNET_CONFIGURATION_Handle *cfg)
464 char *libname; 479 char *libname;
465 480
466 if (GNUNET_OK != 481 if (GNUNET_OK !=
467 GNUNET_CONFIGURATION_get_value_string(cfg, "DATASTORE", "DATABASE", 482 GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE",
468 &name)) 483 &name))
469 { 484 {
470 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 485 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
471 _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", 486 _ ("No `%s' specified for `%s' in configuration!\n"),
472 "DATASTORE"); 487 "DATABASE",
473 return NULL; 488 "DATASTORE");
474 } 489 return NULL;
490 }
475 env.cfg = cfg; 491 env.cfg = cfg;
476 env.duc = &disk_utilization_change_cb; 492 env.duc = &disk_utilization_change_cb;
477 env.cls = NULL; 493 env.cls = NULL;
478 GNUNET_log(GNUNET_ERROR_TYPE_INFO, _("Loading `%s' datastore plugin\n"), 494 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Loading `%s' datastore plugin\n"),
479 name); 495 name);
480 GNUNET_asprintf(&libname, "libgnunet_plugin_datastore_%s", name); 496 GNUNET_asprintf (&libname, "libgnunet_plugin_datastore_%s", name);
481 if (NULL == (ret = GNUNET_PLUGIN_load(libname, &env))) 497 if (NULL == (ret = GNUNET_PLUGIN_load (libname, &env)))
482 { 498 {
483 fprintf(stderr, "Failed to load plugin `%s'!\n", name); 499 fprintf (stderr, "Failed to load plugin `%s'!\n", name);
484 GNUNET_free(name); 500 GNUNET_free (name);
485 GNUNET_free(libname); 501 GNUNET_free (libname);
486 return NULL; 502 return NULL;
487 } 503 }
488 GNUNET_free(libname); 504 GNUNET_free (libname);
489 GNUNET_free(name); 505 GNUNET_free (name);
490 return ret; 506 return ret;
491} 507}
492 508
493 509
494static void 510static void
495run(void *cls, char *const *args, const char *cfgfile, 511run (void *cls, char *const *args, const char *cfgfile,
496 const struct GNUNET_CONFIGURATION_Handle *c) 512 const struct GNUNET_CONFIGURATION_Handle *c)
497{ 513{
498 struct GNUNET_DATASTORE_PluginFunctions *api; 514 struct GNUNET_DATASTORE_PluginFunctions *api;
499 struct CpsRunContext *crc; 515 struct CpsRunContext *crc;
500 516
501 if (NULL == c) 517 if (NULL == c)
502 { 518 {
503 GNUNET_break(0); 519 GNUNET_break (0);
504 return; 520 return;
505 } 521 }
506 api = load_plugin(c); 522 api = load_plugin (c);
507 if (api == NULL) 523 if (api == NULL)
508 { 524 {
509 fprintf(stderr, 525 fprintf (stderr,
510 "%s", "Could not initialize plugin, assuming database not configured. Test not run!\n"); 526 "%s",
511 return; 527 "Could not initialize plugin, assuming database not configured. Test not run!\n");
512 } 528 return;
513 crc = GNUNET_new(struct CpsRunContext); 529 }
530 crc = GNUNET_new (struct CpsRunContext);
514 crc->api = api; 531 crc->api = api;
515 crc->cfg = c; 532 crc->cfg = c;
516 crc->phase = RP_PUT; 533 crc->phase = RP_PUT;
517 ok = 2; 534 ok = 2;
518 GNUNET_SCHEDULER_add_now(&test, crc); 535 GNUNET_SCHEDULER_add_now (&test, crc);
519} 536}
520 537
521 538
522int 539int
523main(int argc, char *argv[]) 540main (int argc, char *argv[])
524{ 541{
525 char dir_name[PATH_MAX]; 542 char dir_name[PATH_MAX];
526 char cfg_name[PATH_MAX]; 543 char cfg_name[PATH_MAX];
@@ -534,21 +551,21 @@ main(int argc, char *argv[])
534 GNUNET_GETOPT_OPTION_END 551 GNUNET_GETOPT_OPTION_END
535 }; 552 };
536 553
537 plugin_name = GNUNET_TESTING_get_testname_from_underscore(argv[0]); 554 plugin_name = GNUNET_TESTING_get_testname_from_underscore (argv[0]);
538 GNUNET_snprintf(dir_name, sizeof(dir_name), "/tmp/perf-gnunet-datastore-%s", 555 GNUNET_snprintf (dir_name, sizeof(dir_name), "/tmp/perf-gnunet-datastore-%s",
539 plugin_name); 556 plugin_name);
540 GNUNET_DISK_directory_remove(dir_name); 557 GNUNET_DISK_directory_remove (dir_name);
541 GNUNET_log_setup("perf-plugin-datastore", 558 GNUNET_log_setup ("perf-plugin-datastore",
542 "WARNING", 559 "WARNING",
543 NULL); 560 NULL);
544 GNUNET_snprintf(category, sizeof(category), "DATASTORE-%s", plugin_name); 561 GNUNET_snprintf (category, sizeof(category), "DATASTORE-%s", plugin_name);
545 GNUNET_snprintf(cfg_name, sizeof(cfg_name), 562 GNUNET_snprintf (cfg_name, sizeof(cfg_name),
546 "perf_plugin_datastore_data_%s.conf", plugin_name); 563 "perf_plugin_datastore_data_%s.conf", plugin_name);
547 GNUNET_PROGRAM_run((sizeof(xargv) / sizeof(char *)) - 1, xargv, 564 GNUNET_PROGRAM_run ((sizeof(xargv) / sizeof(char *)) - 1, xargv,
548 "perf-plugin-datastore", "nohelp", options, &run, NULL); 565 "perf-plugin-datastore", "nohelp", options, &run, NULL);
549 if (ok != 0) 566 if (ok != 0)
550 fprintf(stderr, "Missed some testcases: %u\n", ok); 567 fprintf (stderr, "Missed some testcases: %u\n", ok);
551 GNUNET_DISK_directory_remove(dir_name); 568 GNUNET_DISK_directory_remove (dir_name);
552 569
553 return ok; 570 return ok;
554} 571}