diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-07 12:52:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-07 12:52:52 +0000 |
commit | 3fa5361da7754b5080ae52963c99eb9dc848221f (patch) | |
tree | 3597b83da98cc03e294340d314fe3b7fafe4a39e /src | |
parent | fd0e0fcaa261ceb79897263fd037328d61e46a98 (diff) | |
download | gnunet-3fa5361da7754b5080ae52963c99eb9dc848221f.tar.gz gnunet-3fa5361da7754b5080ae52963c99eb9dc848221f.zip |
simplify logic: just use string directly for the plugin name
Diffstat (limited to 'src')
-rw-r--r-- | src/ats/gnunet-service-ats_plugins.c | 62 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_plugins.h | 31 |
2 files changed, 7 insertions, 86 deletions
diff --git a/src/ats/gnunet-service-ats_plugins.c b/src/ats/gnunet-service-ats_plugins.c index 8cc6af46f..53f12ec10 100644 --- a/src/ats/gnunet-service-ats_plugins.c +++ b/src/ats/gnunet-service-ats_plugins.c | |||
@@ -35,11 +35,6 @@ | |||
35 | 35 | ||
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Configured ATS solver | ||
39 | */ | ||
40 | static int ats_mode; | ||
41 | |||
42 | /** | ||
43 | * Solver handle. | 38 | * Solver handle. |
44 | */ | 39 | */ |
45 | static struct GNUNET_ATS_SolverFunctions *sf; | 40 | static struct GNUNET_ATS_SolverFunctions *sf; |
@@ -416,45 +411,16 @@ GAS_plugins_init (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
416 | unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; | 411 | unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount]; |
417 | unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; | 412 | unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount]; |
418 | char *mode_str; | 413 | char *mode_str; |
419 | char *plugin_short; | 414 | unsigned int c; |
420 | int c; | ||
421 | 415 | ||
422 | /* Figure out configured solution method */ | 416 | /* Figure out configured solution method */ |
423 | if (GNUNET_SYSERR == | 417 | if (GNUNET_SYSERR == |
424 | GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str)) | 418 | GNUNET_CONFIGURATION_get_value_string (cfg, "ats", "MODE", &mode_str)) |
425 | { | 419 | { |
426 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 420 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
427 | "No resource assignment method configured, using proportional approach\n"); | 421 | "No resource assignment method configured, using proportional approach\n"); |
428 | ats_mode = MODE_PROPORTIONAL; | 422 | mode_str = GNUNET_strdup ("proportional"); |
429 | } | ||
430 | else | ||
431 | { | ||
432 | for (c = 0; c < strlen (mode_str); c++) | ||
433 | mode_str[c] = toupper (mode_str[c]); | ||
434 | if (0 == strcmp (mode_str, "PROPORTIONAL")) | ||
435 | ats_mode = MODE_PROPORTIONAL; | ||
436 | else if (0 == strcmp (mode_str, "MLP")) | ||
437 | { | ||
438 | ats_mode = MODE_MLP; | ||
439 | #if !HAVE_LIBGLPK | ||
440 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
441 | "Assignment method `%s' configured, but GLPK is not available, please install \n", | ||
442 | mode_str); | ||
443 | ats_mode = MODE_PROPORTIONAL; | ||
444 | #endif | ||
445 | } | ||
446 | else if (0 == strcmp (mode_str, "RIL")) | ||
447 | ats_mode = MODE_RIL; | ||
448 | else | ||
449 | { | ||
450 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
451 | "Invalid resource assignment method `%s' configured, using proportional approach\n", | ||
452 | mode_str); | ||
453 | ats_mode = MODE_PROPORTIONAL; | ||
454 | } | ||
455 | GNUNET_free(mode_str); | ||
456 | } | 423 | } |
457 | |||
458 | load_quotas (cfg, | 424 | load_quotas (cfg, |
459 | quotas_out, | 425 | quotas_out, |
460 | quotas_in, | 426 | quotas_in, |
@@ -474,27 +440,13 @@ GAS_plugins_init (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
474 | env.in_quota[c] = quotas_in[c]; | 440 | env.in_quota[c] = quotas_in[c]; |
475 | } | 441 | } |
476 | 442 | ||
477 | switch (ats_mode) { | ||
478 | case MODE_PROPORTIONAL: | ||
479 | plugin_short = "proportional"; | ||
480 | break; | ||
481 | case MODE_MLP: | ||
482 | plugin_short = "mlp"; | ||
483 | break; | ||
484 | case MODE_RIL: | ||
485 | plugin_short = "ril"; | ||
486 | break; | ||
487 | default: | ||
488 | plugin_short = NULL; | ||
489 | break; | ||
490 | } | ||
491 | GNUNET_asprintf (&plugin, | 443 | GNUNET_asprintf (&plugin, |
492 | "libgnunet_plugin_ats_%s", | 444 | "libgnunet_plugin_ats_%s", |
493 | plugin_short); | 445 | mode_str); |
494 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 446 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
495 | "Initializing solver `%s '`%s'\n", | 447 | "Initializing solver `%s'\n", |
496 | plugin_short, | 448 | mode_str); |
497 | plugin); | 449 | GNUNET_free (mode_str); |
498 | if (NULL == (sf = GNUNET_PLUGIN_load (plugin, &env))) | 450 | if (NULL == (sf = GNUNET_PLUGIN_load (plugin, &env))) |
499 | { | 451 | { |
500 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 452 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/ats/gnunet-service-ats_plugins.h b/src/ats/gnunet-service-ats_plugins.h index 46a1d29fb..e93ca23ee 100644 --- a/src/ats/gnunet-service-ats_plugins.h +++ b/src/ats/gnunet-service-ats_plugins.h | |||
@@ -31,37 +31,6 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | /** | 33 | /** |
34 | * Available ressource assignment modes | ||
35 | */ | ||
36 | enum ATS_Mode | ||
37 | { | ||
38 | /** | ||
39 | * proportional mode: | ||
40 | * | ||
41 | * Assign each peer an equal amount of bandwidth (bw) | ||
42 | * | ||
43 | * bw_per_peer = bw_total / #active addresses | ||
44 | */ | ||
45 | MODE_PROPORTIONAL, | ||
46 | |||
47 | /** | ||
48 | * MLP mode: | ||
49 | * | ||
50 | * Solve ressource assignment as an optimization problem | ||
51 | * Uses an mixed integer programming solver | ||
52 | */ | ||
53 | MODE_MLP, | ||
54 | |||
55 | /** | ||
56 | * Reinforcement Learning mode: | ||
57 | * | ||
58 | * Solve resource assignment using a learning agent | ||
59 | */ | ||
60 | MODE_RIL | ||
61 | }; | ||
62 | |||
63 | |||
64 | /** | ||
65 | * Initialize address subsystem. The addresses subsystem manages the addresses | 34 | * Initialize address subsystem. The addresses subsystem manages the addresses |
66 | * known and current performance information. It has a solver component | 35 | * known and current performance information. It has a solver component |
67 | * responsible for the resource allocation. It tells the solver about changes | 36 | * responsible for the resource allocation. It tells the solver about changes |