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